karma-qunit 1.1.0 → 2.0.1

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.
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # karma-qunit
2
+
3
+ [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/karma-runner/karma-qunit)
4
+ [![npm version](https://img.shields.io/npm/v/karma-qunit.svg?style=flat-square)](https://www.npmjs.com/package/karma-qunit) [![npm downloads](https://img.shields.io/npm/dm/karma-qunit.svg?style=flat-square)](https://www.npmjs.com/package/karma-qunit)
5
+
6
+ [![Build Status](https://img.shields.io/travis/karma-runner/karma-qunit/master.svg?style=flat-square)](https://travis-ci.org/karma-runner/karma-qunit) [![Dependency Status](https://img.shields.io/david/karma-runner/karma-qunit.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-qunit) [![devDependency Status](https://img.shields.io/david/dev/karma-runner/karma-qunit.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-qunit#info=devDependencies)
7
+
8
+ > Adapter for the [QUnit](http://qunitjs.com/) testing framework.
9
+
10
+ ## Installation
11
+
12
+ The easiest way is to keep `karma-qunit` as a devDependency in your `package.json` by running
13
+
14
+ ```bash
15
+ $ npm install karma-qunit --save-dev
16
+ ```
17
+
18
+ ## Configuration
19
+
20
+ Add `qunit` in the `frameworks` array in your `karma.conf.js` file. Then, in the `plugins`
21
+ array, add `karma-qunit`.
22
+ The following code shows the default configuration:
23
+
24
+ ```js
25
+ // karma.conf.js
26
+ module.exports = function (config) {
27
+ config.set({
28
+ frameworks: ['qunit'],
29
+ plugins: ['karma-qunit'],
30
+ files: [
31
+ '*.js'
32
+ ]
33
+ })
34
+ }
35
+ ```
36
+
37
+ You can also pass options for `QUnit.config` (documented [here](https://api.qunitjs.com/config/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
+ clearContext: false,
52
+ qunit: {
53
+ showUI: true,
54
+ testTimeout: 5000
55
+ }
56
+ }
57
+ })
58
+ }
59
+ ```
60
+
61
+ Note: `showUI: true` needs the `clearContext: false` option to display correctly in non-debug mode.
62
+
63
+ ----
64
+
65
+ 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/latest/plus/emberjs.html) helpful.
66
+
67
+ [homepage]: http://karma-runner.github.com
package/lib/adapter.js CHANGED
@@ -1,5 +1,7 @@
1
1
  (function(window) {
2
2
 
3
+ 'use strict'
4
+
3
5
  function createQUnitConfig (karma, defaultConfig) { // eslint-disable-line no-unused-vars
4
6
  var config = defaultConfig || {}
5
7
 
@@ -22,7 +24,7 @@ function createQUnitStartFn (tc, runnerPassedIn) { // eslint-disable-line no-unu
22
24
  var timer = null
23
25
  var testResult = {}
24
26
  var supportsTestTracking = false
25
- var config = tc.config.qunit || {}
27
+ var config = (tc.config && tc.config.qunit) || {}
26
28
 
27
29
  if (config.showUI) {
28
30
  var ui = document.createElement('div')
@@ -36,6 +38,24 @@ function createQUnitStartFn (tc, runnerPassedIn) { // eslint-disable-line no-unu
36
38
  tc.info({ total: args.totalTests })
37
39
  supportsTestTracking = true
38
40
  }
41
+
42
+ if (typeof document !== 'undefined' && document.getElementById && document.createElement && document.body) {
43
+ // Create a qunit-fixture element to match behaviour of regular qunit runner.
44
+ // The fixture is only created once when the runner begins.
45
+ // Resetting is handled by qunit
46
+ var fixture = document.getElementById(FIXTURE_ID)
47
+ if (!fixture) {
48
+ fixture = document.createElement('div')
49
+ fixture.id = FIXTURE_ID
50
+ // style to match qunit runner's CSS
51
+ fixture.style.position = 'absolute'
52
+ fixture.style.left = '-10000px'
53
+ fixture.style.top = '-10000px'
54
+ fixture.style.width = '1000px'
55
+ fixture.style.height = '1000px'
56
+ document.body.appendChild(fixture)
57
+ }
58
+ }
39
59
  })
40
60
  }
41
61
 
@@ -53,25 +73,6 @@ function createQUnitStartFn (tc, runnerPassedIn) { // eslint-disable-line no-unu
53
73
  totalNumberOfTest += 1
54
74
  timer = new Date().getTime()
55
75
  testResult = { success: true, errors: [] }
56
-
57
- if (typeof document !== 'undefined' && document.getElementById && document.createElement && document.body) {
58
- // create a qunit-fixture element to match behaviour of regular qunit
59
- // runner. The fixture is only removed at the start of a subsequent test
60
- // so it can be inspected after a test run.
61
- var fixture = document.getElementById(FIXTURE_ID)
62
- if (fixture) {
63
- fixture.parentNode.removeChild(fixture)
64
- }
65
- fixture = document.createElement('div')
66
- fixture.id = FIXTURE_ID
67
- // style to match qunit runner's CSS
68
- fixture.style.position = 'absolute'
69
- fixture.style.left = '-10000px'
70
- fixture.style.top = '-10000px'
71
- fixture.style.width = '1000px'
72
- fixture.style.height = '1000px'
73
- document.body.appendChild(fixture)
74
- }
75
76
  })
76
77
 
77
78
  runner.log(function (details) {
@@ -98,18 +99,26 @@ function createQUnitStartFn (tc, runnerPassedIn) { // eslint-disable-line no-unu
98
99
  runner.testDone(function (test) {
99
100
  var result = {
100
101
  description: test.name,
101
- suite: test.module && [test.module] || [],
102
+ suite: (test.module && [test.module]) || [],
102
103
  success: testResult.success,
103
104
  skipped: test.skipped,
104
105
  log: testResult.errors || [],
105
106
  time: new Date().getTime() - timer
106
107
  }
107
108
 
109
+ if (result.description.indexOf('global failure') !== -1) {
110
+ return
111
+ }
112
+
108
113
  tc.result(result)
109
114
  })
110
115
 
111
116
  runner.load()
112
- runner.start()
117
+
118
+ // honor autostart config, useful for tests loaded asynchronously
119
+ if (config.autostart !== false) {
120
+ runner.start()
121
+ }
113
122
  }
114
123
  }
115
124
 
package/lib/index.js CHANGED
@@ -11,9 +11,9 @@ function createPattern (pattern) {
11
11
 
12
12
  function initQUnit (files, qunit) {
13
13
  files.unshift(createPattern(path.join(__dirname, 'adapter.js')))
14
- files.unshift(createPattern(require.resolve('qunitjs')))
14
+ files.unshift(createPattern(require.resolve('qunit')))
15
15
  if (qunit && qunit.showUI) {
16
- files.unshift(createPattern(require.resolve('qunitjs/qunit/qunit.css')))
16
+ files.unshift(createPattern(require.resolve('qunit/qunit/qunit.css')))
17
17
  }
18
18
  }
19
19
 
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "karma-qunit",
3
- "version": "1.1.0",
3
+ "version": "2.0.1",
4
4
  "description": "A Karma plugin. Adapter for QUnit testing framework.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
7
+ "lint": "grunt eslint",
7
8
  "test": "grunt"
8
9
  },
9
10
  "repository": {
@@ -22,37 +23,42 @@
22
23
  "author": "Vojta Jina <vojta.jina@gmail.com>",
23
24
  "dependencies": {},
24
25
  "devDependencies": {
25
- "eslint": "^2.13.1",
26
- "eslint-config-standard": "^5.3.1",
27
- "eslint-plugin-promise": "^1.3.2",
28
- "eslint-plugin-standard": "^1.3.2",
26
+ "eslint": "^4.18.2",
27
+ "eslint-config-standard": "^11.0.0",
28
+ "eslint-plugin-import": "^2.9.0",
29
+ "eslint-plugin-node": "^6.0.1",
30
+ "eslint-plugin-promise": "^3.7.0",
31
+ "eslint-plugin-standard": "^3.0.1",
29
32
  "grunt": "^1.0.1",
30
33
  "grunt-bump": "^0.8.0",
31
- "grunt-eslint": "^18.1.0",
34
+ "grunt-eslint": "^20.1.0",
32
35
  "grunt-karma": "2.x",
33
36
  "grunt-npm": "0.0.2",
34
- "jasmine-core": "^2.3.4",
35
- "karma": "1.x || ^0.13.3",
36
- "karma-chrome-launcher": "1.x || ^0.2.0",
37
+ "jasmine-core": "^3.1.0",
38
+ "karma": "^2.0.0",
39
+ "karma-chrome-launcher": "^2.2.0",
37
40
  "karma-firefox-launcher": "1.x || ^0.1.6",
38
41
  "karma-jasmine": "1.x || ^0.3.6",
39
42
  "load-grunt-tasks": "^3.2.0",
40
- "qunitjs": "^2.0.0"
43
+ "qunit": "^2.5.1"
41
44
  },
42
45
  "peerDependencies": {
43
- "qunitjs": "^1.14.0"
46
+ "qunit": "^2.0.0"
44
47
  },
45
48
  "license": "MIT",
46
49
  "contributors": [
47
- "dignifiedquire <dignifiedquire@gmail.com>",
48
50
  "Friedel Ziegelmayer <dignifiedquire@gmail.com>",
51
+ "dignifiedquire <dignifiedquire@gmail.com>",
49
52
  "Matt DuVall <matt@stripe.com>",
50
- "Mark Ethan Trostler <mark@zzo.com>",
51
53
  "Stefan Sechelmann <stefan@sechel.de>",
54
+ "Timo Tijhof <krinklemail@gmail.com>",
55
+ "masubi <justin.masui@gmail.com>",
56
+ "Mark Ethan Trostler <mark@zzo.com>",
52
57
  "Friedel Ziegelmayer <friedel.ziegelmayer@gmail.com>",
58
+ "Johann-S <johann.servoire@gmail.com>",
53
59
  "Aymeric Beaumet <aymeric@beaumet.me>",
54
- "Timo Tijhof <krinklemail@gmail.com>",
55
- "Aymeric Beaumet <aymeric.beaumet@gmail.com>",
60
+ "masubi <masubi@users.noreply.github.com>",
61
+ "Ulrich Block <u.block@sap.com>",
56
62
  "thenickcox <nick@nickcox.me>",
57
63
  "Brian Donovan <donovan@squareup.com>",
58
64
  "Daniel Herman <daniel.c.herman@gmail.com>",
@@ -60,6 +66,8 @@
60
66
  "Marcin Szczepanski <mszczepanski@atlassian.com>",
61
67
  "Sahat Yalkabov <sakhat@gmail.com>",
62
68
  "Stefan Dragnev <dragnev@telerik.com>",
63
- "Tim Robertson <trobertson@spredfast.com>"
69
+ "Tim Robertson <trobertson@spredfast.com>",
70
+ "pallxk <github@pallxk.com>",
71
+ "Aymeric Beaumet <aymeric.beaumet@gmail.com>"
64
72
  ]
65
73
  }