Comments (9)
@rwjblue provided a solution here https://youtu.be/PwQAj5UU9ng?t=1h25m30s.
Taking that info, I've made the following helper for my tests:
import { waitUntil } from 'ember-native-dom-helpers';
import Ember from 'ember';
export default function waitForError(opts) {
const orig = Ember.onerror;
let error = null;
Ember.onerror = (err) => {
error = err;
};
return waitUntil(() => error, opts).finally(() => {
Ember.onerror = orig;
});
}
I then replace
assert.expectAssertion(() => {
render(hbs`
{{button-hero
align='center'
icon='svg-add'
theme='secondary'
text='Create New Group'
}}
`);
}, 'Assertion Failed: An action is required');
with
const [ err ] = await Promise.all([
waitForError(),
render(hbs`
{{button-hero
align='center'
icon='svg-add'
theme='secondary'
text='Create New Group'
}}
`)
]);
assert.equal(err.message, 'Assertion Failed: An action is required', 'correct assertion');
maybe there's a way to wrap up that same logic into something that looks more like assert.expectAssertion
from ember-qunit-assert-helpers.
Would love to see support for this baked in. Anything we can do to get this over the finish line?
from ember-qunit-assert-helpers.
Updating issue description...
from ember-qunit-assert-helpers.
Was chatting with @workmanw in slack about this, and came up with master...async-wip as a possible solution for expectAssertion
.
from ember-qunit-assert-helpers.
I think next steps are to put some actual tests together and get the other assertion helper methods in line with that WIP (and fix my typos in the WIP).
Any takers?
from ember-qunit-assert-helpers.
I was taking a bit of a stab at it, issue I'm running into is that render now returns a promise which has it's body execute on the next iteration of the runloop. (https://github.com/emberjs/ember-test-helpers/blob/v0.7.0-beta.8/addon-test-support/setup-rendering-context.js#L98) So the expectAssertion
code will always return before the component's init()
hook has even fired.
I'll push up what I have even though it's not complete...#21
from ember-qunit-assert-helpers.
Our apps make fairly extensive use of assertions to document assumptions. I tried upgrading one of my apps to the new testing API while I was at EmberConf, and this broke around 100 of the tests. Do you have any idea how to get this working with the new API? Is there anything I could do to help?
from ember-qunit-assert-helpers.
EDIT: Note that my solution below didn't work anymore after updating to use @ember/test-helpers
.
For what it's worth, I ended up working around this in my projects by just wrapping the render call in a try
and asserting the content of the message in the catch
block:
test('it throws an exception if no range validation is present', async function(assert) {
try {
await render(hbs`{{clipped-numeric options=options}}`);
} catch (e) {
assert.equal(e.message, 'Assertion Failed: A single optional_in_range validation is required');
}
});
from ember-qunit-assert-helpers.
Any news about this issue?
from ember-qunit-assert-helpers.
Related Issues (8)
- expectAssertion string match HOT 3
- Incompatible with Ember 2.0 and below HOT 8
- Incompatible with Ember CLI 3.7.x HOT 5
- FEAT: expectNoDeprecation should filter out expected deprecations HOT 1
- Optionally suppress warnings and deprecations when expected. HOT 1
- Warnings and Deprecations that occur prior to test start result cause an exception HOT 1
- Detect production mode, and ensure expectAssertion/expectDeprecation works
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-qunit-assert-helpers.