karma-qunit 0.1.5 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +22 -0
  2. package/lib/adapter.js +41 -19
  3. package/package.json +9 -6
package/README.md CHANGED
@@ -34,6 +34,28 @@ module.exports = function (config) {
34
34
  }
35
35
  ```
36
36
 
37
+ You can also pass options for `QUnit.config` (documented [here](https://api.qunitjs.com/QUnit.config/)) as such:
38
+
39
+ ```js
40
+ /// karma.conf.js
41
+ module.exports = function (config) {
42
+ config.set({
43
+ frameworks: ['qunit'],
44
+ plugins: ['karma-qunit'],
45
+ files: [
46
+ '*.js'
47
+ ],
48
+
49
+ // client configuration
50
+ client: {
51
+ qunit: {
52
+ testTimeout: 5000
53
+ }
54
+ }
55
+ })
56
+ }
57
+ ```
58
+
37
59
  ----
38
60
 
39
61
  For more information on Karma see the [homepage]. If you're using `karma-qunit` to test Ember.js, you might find Karma's [Ember guide](http://karma-runner.github.io/0.12/plus/emberjs.html) helpful.
package/lib/adapter.js CHANGED
@@ -1,5 +1,19 @@
1
1
  (function(window) {
2
2
 
3
+ function createQUnitConfig (karma, defaultConfig) { // eslint-disable-line no-unused-vars
4
+ var config = defaultConfig || {}
5
+
6
+ if (!karma.config || !karma.config.qunit) {
7
+ return config
8
+ }
9
+
10
+ for (var key in karma.config.qunit) {
11
+ config[key] = karma.config.qunit[key]
12
+ }
13
+
14
+ return config
15
+ }
16
+
3
17
  function createQUnitStartFn (tc, runnerPassedIn) { // eslint-disable-line no-unused-vars
4
18
  return function () {
5
19
  var FIXTURE_ID = 'qunit-fixture'
@@ -33,22 +47,24 @@ function createQUnitStartFn (tc, runnerPassedIn) { // eslint-disable-line no-unu
33
47
  timer = new Date().getTime()
34
48
  testResult = { success: true, errors: [] }
35
49
 
36
- // create a qunit-fixture element to match behaviour of regular qunit
37
- // runner. The fixture is only removed at the start of a subsequent test
38
- // so it can be inspected after a test run.
39
- var fixture = document.getElementById(FIXTURE_ID)
40
- if (fixture) {
41
- fixture.parentNode.removeChild(fixture)
50
+ if (typeof document !== 'undefined' && document.getElementById && document.createElement && document.body) {
51
+ // create a qunit-fixture element to match behaviour of regular qunit
52
+ // runner. The fixture is only removed at the start of a subsequent test
53
+ // so it can be inspected after a test run.
54
+ var fixture = document.getElementById(FIXTURE_ID)
55
+ if (fixture) {
56
+ fixture.parentNode.removeChild(fixture)
57
+ }
58
+ fixture = document.createElement('div')
59
+ fixture.id = FIXTURE_ID
60
+ // style to match qunit runner's CSS
61
+ fixture.style.position = 'absolute'
62
+ fixture.style.left = '-10000px'
63
+ fixture.style.top = '-10000px'
64
+ fixture.style.width = '1000px'
65
+ fixture.style.height = '1000px'
66
+ document.body.appendChild(fixture)
42
67
  }
43
- fixture = document.createElement('div')
44
- fixture.id = FIXTURE_ID
45
- // style to match qunit runner's CSS
46
- fixture.style.position = 'absolute'
47
- fixture.style.left = '-10000px'
48
- fixture.style.top = '-10000px'
49
- fixture.style.width = '1000px'
50
- fixture.style.height = '1000px'
51
- document.body.appendChild(fixture)
52
68
  })
53
69
 
54
70
  runner.log(function (details) {
@@ -60,7 +76,7 @@ function createQUnitStartFn (tc, runnerPassedIn) { // eslint-disable-line no-unu
60
76
  }
61
77
 
62
78
  if (typeof details.expected !== 'undefined') {
63
- msg += 'Expected: ' + details.expected + '\n' + 'Actual: ' + details.actual + '\n'
79
+ msg += 'Expected: ' + runner.dump.parse(details.expected) + '\n' + 'Actual: ' + runner.dump.parse(details.actual) + '\n'
64
80
  }
65
81
 
66
82
  if (details.source) {
@@ -89,13 +105,19 @@ function createQUnitStartFn (tc, runnerPassedIn) { // eslint-disable-line no-unu
89
105
  }
90
106
  }
91
107
 
92
- window.QUnit.config.autostart = false;
108
+ var config = createQUnitConfig(window.__karma__, {
109
+ autostart: false
110
+ });
111
+
112
+ for (var key in config) {
113
+ window.QUnit.config[key] = config[key];
114
+ }
93
115
 
94
116
  if (window.removeEventListener) {
95
117
  window.removeEventListener('load', window.QUnit.load, false);
96
- } else {
118
+ } else if (window.detachEvent) {
97
119
  window.detachEvent('onload', window.QUnit.load);
98
120
  }
99
121
 
100
122
  window.__karma__.start = createQUnitStartFn(window.__karma__);
101
- })(window);
123
+ })(typeof window !== 'undefined' ? window : global);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karma-qunit",
3
- "version": "0.1.5",
3
+ "version": "0.1.9",
4
4
  "description": "A Karma plugin. Adapter for QUnit testing framework.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -42,17 +42,20 @@
42
42
  },
43
43
  "license": "MIT",
44
44
  "contributors": [
45
+ "dignifiedquire <dignifiedquire@gmail.com>",
46
+ "Friedel Ziegelmayer <dignifiedquire@gmail.com>",
47
+ "Matt DuVall <matt@stripe.com>",
45
48
  "Friedel Ziegelmayer <friedel.ziegelmayer@gmail.com>",
46
49
  "Aymeric Beaumet <aymeric@beaumet.me>",
47
- "Friedel Ziegelmayer <dignifiedquire@gmail.com>",
48
- "Marcin Szczepanski <mszczepanski@atlassian.com>",
49
- "Sahat Yalkabov <sakhat@gmail.com>",
50
+ "Stefan Dragnev <dragnev@telerik.com>",
51
+ "Tim Robertson <trobertson@spredfast.com>",
50
52
  "Timo Tijhof <krinklemail@gmail.com>",
51
- "dignifiedquire <dignifiedquire@gmail.com>",
52
53
  "Aymeric Beaumet <aymeric.beaumet@gmail.com>",
53
54
  "thenickcox <nick@nickcox.me>",
54
55
  "Brian Donovan <donovan@squareup.com>",
55
56
  "Daniel Herman <daniel.c.herman@gmail.com>",
56
- "Kristof Neirynck <k.neirynck@gmail.com>"
57
+ "Kristof Neirynck <k.neirynck@gmail.com>",
58
+ "Marcin Szczepanski <mszczepanski@atlassian.com>",
59
+ "Sahat Yalkabov <sakhat@gmail.com>"
57
60
  ]
58
61
  }