workmanw / ember-qunit-assert-helpers Goto Github PK
View Code? Open in Web Editor NEWAn ember-addon that provides additional QUnit 2.0 assertions specific to Ember.js.
License: MIT License
An ember-addon that provides additional QUnit 2.0 assertions specific to Ember.js.
License: MIT License
Scenario: a test or module that wants to assert against any unexpected deprecations while still asserting specific deprecations are triggered.
ember-cli/ember-cli#8264 removed the private _requireBuildPackages()
method on the Addon
class that this project is calling. To fix it in a backward-compatible way we should probably check if the method exists before trying to call it.
The RFC essentially makes rendering async, which means that if you were doing:
assert.expectAssertion(() => {
this.render(hbs`stuff here`);
});
Then the codemod "helpfully" transforms that into:
assert.expectAssertion(async () => {
await render(hbs`stuff here`);
});
But this library always expects the callback to trigger assertions synchronously.
Further reading:
The registerDeprecationHandler()
method does not exist in Ember 2.0 and below. Since the deprecation tracking setup is using the method unconditionally it will break the test even if the expectDeprecation()
method is never used. This makes it impossible to use this addon in an ember-try
scenario that targets an older Ember version.
Any warnings or deprecations that occur before a test starts cause an exception :(.
An example of this would be using moduleForComponent
and not providing a value for the integration
option. PR forth coming.
// component.js
...
Ember.assert('{{#th-order-by}} must pass value argument: ["foo", "bar"]', myCheck);
...
// component-test.js
...
assert.expectAssertion(
() => {
this.render(hbs`{{th-order-by}}`);
},
"Assertion Failed: {{#th-order-by}} must pass value argument: [\"foo\", \"bar\"]"
);
});
...
Produces:
expected
and actual
are the same and yet the test itself fails.matcher
parameter is regular expression. So internally it will let the test assertion fail. Because I'm using characters that are special for regular expressions (hash, bracket, ...). But then when the strings are passed to testing environment, they really match and thus I'm getting the message that everything is ok.===
) when string is passed as matcher?I think we may need to optionally (possibly by default) suppress warnings and deprecations when they are expected. This means not invoking the next
callback in this addons registered handlers (e.g. asserts/deprecation.js#L14).
I had not done so originally because it felt wrong for this addon to swallow warnings and deprecations without knowing what else could be out there wanting to consume them. But practically speaking, not doing so creates a lot a noise in a test that passes. Example:
ok 166 PhantomJS 2.1 - model-fragments shim module: test the shim modules
---
Log: |
{ type: 'warn',
text: '\'DEPRECATION: Importing from the `model-fragments` module is deprecated. Instead import from `ember-data-model-fragments`. [deprecation id: model-fragments-module-import]\\n http://localhost:7357/assets/vendor.js:16197:15\\n raiseOnDeprecation@http://localhost:7357/assets/vendor.js:16116:17\\n http://localhost:7357/assets/vendor.js:16197:15\\n http://localhost:7357/assets/test-support.js:4793:11\\n http://localhost:7357/assets/vendor.js:16197:15\\n invoke@http://localhost:7357/assets/vendor.js:16213:21\\n deprecate@http://localhost:7357/assets/vendor.js:16181:37\\n deprecate@http://localhost:7357/assets/vendor.js:27940:42\\n http://localhost:7357/assets/vendor.js:71104:22\\n exports@http://localhost:7357/assets/vendor.js:140:37\\n requireModule@http://localhost:7357/assets/vendor.js:32:25\\n http://localhost:7357/assets/tests.js:3799:25\\n runTest@http://localhost:7357/assets/test-support.js:1060:34\\n run@http://localhost:7357/assets/test-support.js:1046:13\\n http://localhost:7357/assets/test-support.js:1220:15\\n process@http://localhost:7357/assets/test-support.js:2277:26\\n begin@http://localhost:7357/assets/test-support.js:2260:11\\n http://localhost:7357/assets/test-support.js:1634:11\'\n' }
{ type: 'warn',
text: '\'DEPRECATION: Importing from the `model-fragments` module is deprecated. Instead import from `ember-data-model-fragments`. [deprecation id: model-fragments-module-import]\\n http://localhost:7357/assets/vendor.js:16197:15\\n raiseOnDeprecation@http://localhost:7357/assets/vendor.js:16116:17\\n http://localhost:7357/assets/vendor.js:16197:15\\n http://localhost:7357/assets/test-support.js:4793:11\\n http://localhost:7357/assets/vendor.js:16197:15\\n invoke@http://localhost:7357/assets/vendor.js:16213:21\\n deprecate@http://localhost:7357/assets/vendor.js:16181:37\\n deprecate@http://localhost:7357/assets/vendor.js:27940:42\\n http://localhost:7357/assets/vendor.js:71104:22\\n exports@http://localhost:7357/assets/vendor.js:140:37\\n requireModule@http://localhost:7357/assets/vendor.js:32:25\\n http://localhost:7357/assets/tests.js:3800:25\\n runTest@http://localhost:7357/assets/test-support.js:1060:34\\n run@http://localhost:7357/assets/test-support.js:1046:13\\n http://localhost:7357/assets/test-support.js:1220:15\\n process@http://localhost:7357/assets/test-support.js:2277:26\\n begin@http://localhost:7357/assets/test-support.js:2260:11\\n http://localhost:7357/assets/test-support.js:1634:11\'\n' }
{ type: 'warn',
text: '\'DEPRECATION: Importing from the `model-fragments` module is deprecated. Instead import from `ember-data-model-fragments`. [deprecation id: model-fragments-module-import]\\n http://localhost:7357/assets/vendor.js:16197:15\\n raiseOnDeprecation@http://localhost:7357/assets/vendor.js:16116:17\\n http://localhost:7357/assets/vendor.js:16197:15\\n http://localhost:7357/assets/test-support.js:4793:11\\n http://localhost:7357/assets/vendor.js:16197:15\\n invoke@http://localhost:7357/assets/vendor.js:16213:21\\n deprecate@http://localhost:7357/assets/vendor.js:16181:37\\n deprecate@http://localhost:7357/assets/vendor.js:27940:42\\n http://localhost:7357/assets/vendor.js:71104:22\\n exports@http://localhost:7357/assets/vendor.js:140:37\\n requireModule@http://localhost:7357/assets/vendor.js:32:25\\n http://localhost:7357/assets/tests.js:3801:25\\n runTest@http://localhost:7357/assets/test-support.js:1060:34\\n run@http://localhost:7357/assets/test-support.js:1046:13\\n http://localhost:7357/assets/test-support.js:1220:15\\n process@http://localhost:7357/assets/test-support.js:2277:26\\n begin@http://localhost:7357/assets/test-support.js:2260:11\\n http://localhost:7357/assets/test-support.js:1634:11\'\n' }
{ type: 'warn',
text: '\'DEPRECATION: Importing from the `model-fragments` module is deprecated. Instead import from `ember-data-model-fragments`. [deprecation id: model-fragments-module-import]\\n http://localhost:7357/assets/vendor.js:16197:15\\n raiseOnDeprecation@http://localhost:7357/assets/vendor.js:16116:17\\n http://localhost:7357/assets/vendor.js:16197:15\\n http://localhost:7357/assets/test-support.js:4793:11\\n http://localhost:7357/assets/vendor.js:16197:15\\n invoke@http://localhost:7357/assets/vendor.js:16213:21\\n deprecate@http://localhost:7357/assets/vendor.js:16181:37\\n deprecate@http://localhost:7357/assets/vendor.js:27940:42\\n http://localhost:7357/assets/vendor.js:71104:22\\n exports@http://localhost:7357/assets/vendor.js:140:37\\n requireModule@http://localhost:7357/assets/vendor.js:32:25\\n http://localhost:7357/assets/tests.js:3802:25\\n runTest@http://localhost:7357/assets/test-support.js:1060:34\\n run@http://localhost:7357/assets/test-support.js:1046:13\\n http://localhost:7357/assets/test-support.js:1220:15\\n process@http://localhost:7357/assets/test-support.js:2277:26\\n begin@http://localhost:7357/assets/test-support.js:2260:11\\n http://localhost:7357/assets/test-support.js:1634:11\'\n' }
{ type: 'warn',
text: '\'DEPRECATION: Importing from the `model-fragments` module is deprecated. Instead import from `ember-data-model-fragments`. [deprecation id: model-fragments-module-import]\\n http://localhost:7357/assets/vendor.js:16197:15\\n raiseOnDeprecation@http://localhost:7357/assets/vendor.js:16116:17\\n http://localhost:7357/assets/vendor.js:16197:15\\n http://localhost:7357/assets/test-support.js:4793:11\\n http://localhost:7357/assets/vendor.js:16197:15\\n invoke@http://localhost:7357/assets/vendor.js:16213:21\\n deprecate@http://localhost:7357/assets/vendor.js:16181:37\\n deprecate@http://localhost:7357/assets/vendor.js:27940:42\\n http://localhost:7357/assets/vendor.js:71104:22\\n exports@http://localhost:7357/assets/vendor.js:140:37\\n requireModule@http://localhost:7357/assets/vendor.js:32:25\\n http://localhost:7357/assets/tests.js:3803:25\\n runTest@http://localhost:7357/assets/test-support.js:1060:34\\n run@http://localhost:7357/assets/test-support.js:1046:13\\n http://localhost:7357/assets/test-support.js:1220:15\\n process@http://localhost:7357/assets/test-support.js:2277:26\\n begin@http://localhost:7357/assets/test-support.js:2260:11\\n http://localhost:7357/assets/test-support.js:1634:11\'\n' }
{ type: 'warn',
text: '\'DEPRECATION: Importing from the `model-fragments` module is deprecated. Instead import from `ember-data-model-fragments`. [deprecation id: model-fragments-module-import]\\n http://localhost:7357/assets/vendor.js:16197:15\\n raiseOnDeprecation@http://localhost:7357/assets/vendor.js:16116:17\\n http://localhost:7357/assets/vendor.js:16197:15\\n http://localhost:7357/assets/test-support.js:4793:11\\n http://localhost:7357/assets/vendor.js:16197:15\\n invoke@http://localhost:7357/assets/vendor.js:16213:21\\n deprecate@http://localhost:7357/assets/vendor.js:16181:37\\n deprecate@http://localhost:7357/assets/vendor.js:27940:42\\n http://localhost:7357/assets/vendor.js:71104:22\\n exports@http://localhost:7357/assets/vendor.js:140:37\\n requireModule@http://localhost:7357/assets/vendor.js:32:25\\n http://localhost:7357/assets/tests.js:3804:25\\n runTest@http://localhost:7357/assets/test-support.js:1060:34\\n run@http://localhost:7357/assets/test-support.js:1046:13\\n http://localhost:7357/assets/test-support.js:1220:15\\n process@http://localhost:7357/assets/test-support.js:2277:26\\n begin@http://localhost:7357/assets/test-support.js:2260:11\\n http://localhost:7357/assets/test-support.js:1634:11\'\n' }
{ type: 'warn',
text: '\'DEPRECATION: Importing from the `model-fragments` module is deprecated. Instead import from `ember-data-model-fragments`. [deprecation id: model-fragments-module-import]\\n http://localhost:7357/assets/vendor.js:16197:15\\n raiseOnDeprecation@http://localhost:7357/assets/vendor.js:16116:17\\n http://localhost:7357/assets/vendor.js:16197:15\\n http://localhost:7357/assets/test-support.js:4793:11\\n http://localhost:7357/assets/vendor.js:16197:15\\n invoke@http://localhost:7357/assets/vendor.js:16213:21\\n deprecate@http://localhost:7357/assets/vendor.js:16181:37\\n deprecate@http://localhost:7357/assets/vendor.js:27940:42\\n http://localhost:7357/assets/vendor.js:71104:22\\n exports@http://localhost:7357/assets/vendor.js:140:37\\n requireModule@http://localhost:7357/assets/vendor.js:32:25\\n http://localhost:7357/assets/tests.js:3805:25\\n runTest@http://localhost:7357/assets/test-support.js:1060:34\\n run@http://localhost:7357/assets/test-support.js:1046:13\\n http://localhost:7357/assets/test-support.js:1220:15\\n process@http://localhost:7357/assets/test-support.js:2277:26\\n begin@http://localhost:7357/assets/test-support.js:2260:11\\n http://localhost:7357/assets/test-support.js:1634:11\'\n' }
{ type: 'warn',
text: '\'DEPRECATION: Importing from the `model-fragments` module is deprecated. Instead import from `ember-data-model-fragments`. [deprecation id: model-fragments-module-import]\\n http://localhost:7357/assets/vendor.js:16197:15\\n raiseOnDeprecation@http://localhost:7357/assets/vendor.js:16116:17\\n http://localhost:7357/assets/vendor.js:16197:15\\n http://localhost:7357/assets/test-support.js:4793:11\\n http://localhost:7357/assets/vendor.js:16197:15\\n invoke@http://localhost:7357/assets/vendor.js:16213:21\\n deprecate@http://localhost:7357/assets/vendor.js:16181:37\\n deprecate@http://localhost:7357/assets/vendor.js:27940:42\\n http://localhost:7357/assets/vendor.js:71104:22\\n exports@http://localhost:7357/assets/vendor.js:140:37\\n requireModule@http://localhost:7357/assets/vendor.js:32:25\\n http://localhost:7357/assets/tests.js:3809:25\\n runTest@http://localhost:7357/assets/test-support.js:1060:34\\n run@http://localhost:7357/assets/test-support.js:1046:13\\n http://localhost:7357/assets/test-support.js:1220:15\\n process@http://localhost:7357/assets/test-support.js:2277:26\\n begin@http://localhost:7357/assets/test-support.js:2260:11\\n http://localhost:7357/assets/test-support.js:1634:11\'\n' }
{ type: 'warn',
text: '\'DEPRECATION: Importing from the `model-fragments` module is deprecated. Instead import from `ember-data-model-fragments`. [deprecation id: model-fragments-module-import]\\n http://localhost:7357/assets/vendor.js:16197:15\\n raiseOnDeprecation@http://localhost:7357/assets/vendor.js:16116:17\\n http://localhost:7357/assets/vendor.js:16197:15\\n http://localhost:7357/assets/test-support.js:4793:11\\n http://localhost:7357/assets/vendor.js:16197:15\\n invoke@http://localhost:7357/assets/vendor.js:16213:21\\n deprecate@http://localhost:7357/assets/vendor.js:16181:37\\n deprecate@http://localhost:7357/assets/vendor.js:27940:42\\n http://localhost:7357/assets/vendor.js:71104:22\\n exports@http://localhost:7357/assets/vendor.js:140:37\\n requireModule@http://localhost:7357/assets/vendor.js:32:25\\n http://localhost:7357/assets/tests.js:3810:25\\n runTest@http://localhost:7357/assets/test-support.js:1060:34\\n run@http://localhost:7357/assets/test-support.js:1046:13\\n http://localhost:7357/assets/test-support.js:1220:15\\n process@http://localhost:7357/assets/test-support.js:2277:26\\n begin@http://localhost:7357/assets/test-support.js:2260:11\\n http://localhost:7357/assets/test-support.js:1634:11\'\n' }
...
The expectAssertion that exists in embers own test suite has some special behavior for when running in production mode. It adds an assert.ok(true, 'assertions stripped in prod mode')
so that when the test suite runs in prod the assert.expect
counts are not thrown off.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.