diff --git a/.gitignore b/.gitignore index 6047e1c2..cf8fabd3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ bower_components tmp dist build +*.log diff --git a/bower.json b/bower.json index a7043a45..6bcfdbad 100644 --- a/bower.json +++ b/bower.json @@ -19,7 +19,7 @@ "ember-test-helpers": "^0.5.14" }, "devDependencies": { - "qunit": "^1.17.1", + "qunit": "^1.20.0", "loader": "stefanpenner/loader.js#1.0.1", "ember-cli-shims": "stefanpenner/ember-cli-shims#0.0.3", "ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4", diff --git a/lib/ember-qunit.js b/lib/ember-qunit.js index cd2982c5..2ed32594 100644 --- a/lib/ember-qunit.js +++ b/lib/ember-qunit.js @@ -2,6 +2,7 @@ import moduleFor from 'ember-qunit/module-for'; import moduleForComponent from 'ember-qunit/module-for-component'; import moduleForModel from 'ember-qunit/module-for-model'; import test from 'ember-qunit/test'; +import only from 'ember-qunit/only'; import { setResolver } from 'ember-test-helpers'; export { @@ -9,5 +10,6 @@ export { moduleForComponent, moduleForModel, test, + only, setResolver }; diff --git a/lib/ember-qunit/only.js b/lib/ember-qunit/only.js new file mode 100644 index 00000000..5e70e171 --- /dev/null +++ b/lib/ember-qunit/only.js @@ -0,0 +1,6 @@ +import testWrapper from 'ember-qunit/test-wrapper'; +import { only as qunitOnly } from 'qunit'; + +export default function only(testName, callback) { + testWrapper(testName, callback, qunitOnly); +} diff --git a/lib/ember-qunit/test-wrapper.js b/lib/ember-qunit/test-wrapper.js new file mode 100644 index 00000000..4131846a --- /dev/null +++ b/lib/ember-qunit/test-wrapper.js @@ -0,0 +1,32 @@ +import Ember from 'ember'; +import { getContext } from 'ember-test-helpers'; + +export default function testWrapper(testName, callback, qunit) { + function wrapper(assert) { + var context = getContext(); + + var result = callback.call(context, assert); + + function failTestOnPromiseRejection(reason) { + var message; + if (reason instanceof Error) { + message = reason.stack; + if (reason.message && message.indexOf(reason.message) < 0) { + // PhantomJS has a `stack` that does not contain the actual + // exception message. + message = Ember.inspect(reason) + "\n" + message; + } + } else { + message = Ember.inspect(reason); + } + ok(false, message); + } + + Ember.run(function(){ + QUnit.stop(); + Ember.RSVP.Promise.resolve(result)['catch'](failTestOnPromiseRejection)['finally'](QUnit.start); + }); + } + + qunit(testName, wrapper); +} diff --git a/lib/ember-qunit/test.js b/lib/ember-qunit/test.js index d6516052..fd42eb95 100644 --- a/lib/ember-qunit/test.js +++ b/lib/ember-qunit/test.js @@ -1,33 +1,6 @@ -import Ember from 'ember'; -import { getContext } from 'ember-test-helpers'; +import testWrapper from 'ember-qunit/test-wrapper'; import { test as qunitTest } from 'qunit'; export default function test(testName, callback) { - function wrapper(assert) { - var context = getContext(); - - var result = callback.call(context, assert); - - function failTestOnPromiseRejection(reason) { - var message; - if (reason instanceof Error) { - message = reason.stack; - if (reason.message && message.indexOf(reason.message) < 0) { - // PhantomJS has a `stack` that does not contain the actual - // exception message. - message = Ember.inspect(reason) + "\n" + message; - } - } else { - message = Ember.inspect(reason); - } - ok(false, message); - } - - Ember.run(function(){ - QUnit.stop(); - Ember.RSVP.Promise.resolve(result)['catch'](failTestOnPromiseRejection)['finally'](QUnit.start); - }); - } - - qunitTest(testName, wrapper); + testWrapper(testName, callback, qunitTest); } diff --git a/lib/qunit.js b/lib/qunit.js index e91915d4..6535af67 100644 --- a/lib/qunit.js +++ b/lib/qunit.js @@ -3,5 +3,6 @@ export var module = QUnit.module; export var test = QUnit.test; export var skip = QUnit.skip; +export var only = QUnit.only; export default QUnit; diff --git a/tests/qunit-shim-test.js b/tests/qunit-shim-test.js index 9054e51b..889dc7bf 100644 --- a/tests/qunit-shim-test.js +++ b/tests/qunit-shim-test.js @@ -1,7 +1,8 @@ import { module, test, - skip + skip, + only } from 'qunit'; module('qunit-shim test'); @@ -13,3 +14,7 @@ test('should work!', function(assert) { test('imports skips', function(assert) { assert.equal(typeof skip, 'function', 'imports QUnit.skip'); }); + +test('imports only', function(assert) { + assert.equal(typeof only, 'function', 'imports QUnit.only'); +});