ember-qunit
Advanced tools
Comparing version 0.4.20 to 0.4.21
@@ -6,2 +6,3 @@ import moduleFor from 'ember-qunit/module-for'; | ||
import only from 'ember-qunit/only'; | ||
import skip from 'ember-qunit/skip'; | ||
import { setResolver } from 'ember-test-helpers'; | ||
@@ -15,3 +16,4 @@ | ||
only, | ||
skip, | ||
setResolver | ||
}; |
import testWrapper from 'ember-qunit/test-wrapper'; | ||
import { only as qunitOnly } from 'qunit'; | ||
export default function only(/* testName, expected, callback, async */) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; ++_key) { | ||
args[_key] = arguments[_key]; | ||
} | ||
export default function only(...args) { | ||
args.unshift(qunitOnly); | ||
testWrapper.apply(null, args); | ||
} |
@@ -50,2 +50,6 @@ import { module as qunitModule } from 'qunit'; | ||
var done = assert.async(); | ||
// provide the test context to the underlying module | ||
module.setContext(this); | ||
return module.setup().then(function() { | ||
@@ -52,0 +56,0 @@ if (beforeEach) { |
@@ -19,3 +19,3 @@ import Ember from 'ember'; | ||
message = reason.stack; | ||
if (reason.message && message.indexOf(reason.message) < 0) { | ||
if (reason.message && message && message.indexOf(reason.message) < 0) { | ||
// PhantomJS has a `stack` that does not contain the actual | ||
@@ -22,0 +22,0 @@ // exception message. |
import testWrapper from 'ember-qunit/test-wrapper'; | ||
import { test as qunitTest } from 'qunit'; | ||
export default function test(/* testName, expected, callback, async */) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; ++_key) { | ||
args[_key] = arguments[_key]; | ||
} | ||
export default function test(...args) { | ||
args.unshift(qunitTest); | ||
testWrapper.apply(null, args); | ||
} |
{ | ||
"name": "ember-qunit", | ||
"version": "0.4.20", | ||
"version": "0.4.21", | ||
"description": "QUnit helpers for testing Ember.js applications", | ||
@@ -19,18 +19,18 @@ "main": "lib/ember-qunit.js", | ||
"dependencies": { | ||
"ember-test-helpers": "^0.5.22" | ||
"ember-test-helpers": "^0.5.32" | ||
}, | ||
"devDependencies": { | ||
"bower": "^1.3.12", | ||
"broccoli": "^0.13.0", | ||
"broccoli": "^0.16.9", | ||
"broccoli-babel-transpiler": "^5.5.0", | ||
"broccoli-funnel": "^0.1.6", | ||
"broccoli-jshint": "^0.5.3", | ||
"broccoli-merge-trees": "^0.1.4", | ||
"broccoli-sourcemap-concat": "^0.4.3", | ||
"broccoli-funnel": "^0.2.15", | ||
"broccoli-jshint": "^0.5.8", | ||
"broccoli-merge-trees": "^0.2.4", | ||
"broccoli-sourcemap-concat": "^0.4.4", | ||
"broccoli-string-replace": "0.0.2", | ||
"ember-cli": "^0.1.12", | ||
"ember-cli-release": "^0.2.7", | ||
"ember-cli": "^0.2.7", | ||
"ember-cli-release": "^0.2.9", | ||
"exists-sync": "0.0.3", | ||
"git-repo-version": "^0.1.2", | ||
"resolve": "^1.1.6" | ||
"git-repo-version": "^0.3.1", | ||
"resolve": "^1.1.7" | ||
}, | ||
@@ -37,0 +37,0 @@ "repository": { |
@@ -14,38 +14,2 @@ # Ember QUnit [![Build Status](https://travis-ci.org/rwjblue/ember-qunit.png)](https://travis-ci.org/rwjblue/ember-qunit) | ||
### Component Unit Tests | ||
[Ember Guide](http://guides.emberjs.com/v1.13.0/testing/testing-components/) | ||
```js | ||
import { test, moduleForComponent } from 'ember-qunit'; | ||
moduleForComponent('x-foo', { | ||
unit: true, | ||
needs: ['helper:pluralize-string'] | ||
}); | ||
// run a test | ||
test('it renders', function(assert) { | ||
assert.expect(1); | ||
// creates the component instance | ||
var subject = this.subject(); | ||
// render the component on the page | ||
this.render(); | ||
assert.equal(this.$('.foo').text(), 'bar'); | ||
}); | ||
``` | ||
Unit tests are currently the default mode for component tests (this will eventually change to integration tests). To flag a test as a unit test, either specify `unit: true` or include `needs: []` in the callbacks object. | ||
Unit tests have the advantage of giving you direct access to the component instance so you can test its internals. Unit tests have the following features: | ||
- You have access to the component instance through `this.subject()`. | ||
- If you want to render the componenet's template, call either `this.render()` or `this.$()`. | ||
- Testing the component's template is through `this.$()`. | ||
- You are required to specify any dependencies other than the component's template in the `needs: []` option. This includes helpers, services, partials, and any other components (with their templates) that are referenced. | ||
- Unit tests do not call most of the Ember lifecycle hooks. `didInsertElement` and `willDestroyElement` will be called, but the remaining hooks introduced in Ember 1.13.x will not be. | ||
- There is no outer context for the component so testing things such as actions will require directly stubbing the actions on the component. | ||
### Component Integration Tests | ||
@@ -81,3 +45,3 @@ | ||
Component integration tests will be the default mode for `moduleForComponent` in the near future, however currently you will be required to activate them by passing `integration: true`. | ||
Component integration tests are the default mode for `moduleForComponent`. You can still explicitly activate them by passing `integration: true`. | ||
@@ -94,2 +58,38 @@ Integration tests have the advantage of testing your component as Ember would actually use them. It's helpful to think of this mode as simply testing the inputs and outputs of the component. These tests allow you interact with both the bound values that are passed into the component as well as its resulting actions. | ||
### Component Unit Tests | ||
[Ember Guide](http://guides.emberjs.com/v1.13.0/testing/testing-components/) | ||
```js | ||
import { test, moduleForComponent } from 'ember-qunit'; | ||
moduleForComponent('x-foo', { | ||
unit: true, | ||
needs: ['helper:pluralize-string'] | ||
}); | ||
// run a test | ||
test('it renders', function(assert) { | ||
assert.expect(1); | ||
// creates the component instance | ||
var subject = this.subject(); | ||
// render the component on the page | ||
this.render(); | ||
assert.equal(this.$('.foo').text(), 'bar'); | ||
}); | ||
``` | ||
Unit tests used to be the default mode for component tests. To flag a test as a unit test, either specify `unit: true` or include `needs: []` in the callbacks object. | ||
Unit tests have the advantage of giving you direct access to the component instance so you can test its internals. Unit tests have the following features: | ||
- You have access to the component instance through `this.subject()`. | ||
- If you want to render the componenet's template, call either `this.render()` or `this.$()`. | ||
- Testing the component's template is through `this.$()`. | ||
- You are required to specify any dependencies other than the component's template in the `needs: []` option. This includes helpers, services, partials, and any other components (with their templates) that are referenced. | ||
- Unit tests do not call most of the Ember lifecycle hooks. `didInsertElement` and `willDestroyElement` will be called, but the remaining hooks introduced in Ember 1.13.x will not be. | ||
- There is no outer context for the component so testing things such as actions will require directly stubbing the actions on the component. | ||
### Other Tests | ||
@@ -206,2 +206,3 @@ | ||
- QUnit callbacks (`beforeEach` and `afterEach`) | ||
- ember-test-helpers callback (`subject`) | ||
- `integration: true` or `unit: true` (default: `integration: true`) | ||
@@ -219,4 +220,5 @@ - `needs` specify any dependencies the tested module will require. | ||
- QUnit callbacks (`beforeEach` and `afterEach`) | ||
- ember-test-helpers callback (`subject`) | ||
- `integration: true` or `unit: true` (default: `integration: true`) | ||
- `needs` specify any dependencies the tested module will require. (Includig this will force your test into unit mode). | ||
- `needs` specify any dependencies the tested module will require. (Including this will force your test into unit mode). | ||
@@ -233,2 +235,3 @@ | ||
- QUnit callbacks (`beforeEach` and `afterEach`) | ||
- ember-test-helpers callback (`subject`) | ||
- `integration: true` or `unit: true` (default: `integration: true`) | ||
@@ -235,0 +238,0 @@ - `needs` specify any dependencies the tested module will require. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16801
17
144
264
Updatedember-test-helpers@^0.5.32