-
-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
render does not reject when rendering fails #310
Comments
This is ultimately due to how rendering is deferred in the render queue. There are work arounds / solutions, I’ll try to list them so we can discuss the best path forward. |
Yeah, I know the scheduling isn't synchronous, I was just a little surprised because we're already waiting here for everything to finish, so most of the plumbing for getting the state threaded back to us must already be present. |
I'm also trying to find a reliable way of testing errors/assertions during the render. What are the possible workarounds for this? (Or reliable fix for that matter) |
This appears to be a bit stale, but I would love some workarounds as well. |
With the help of @rwjblue's talk https://www.youtube.com/watch?v=PwQAj5UU9ng, I came up with a decent workaround. let onerror;
hooks.beforeEach(function() {
// `sinon.stub(Ember, 'onerror')` won't work because onerror
// has a setter, it's not the real reference called
onerror = Ember.onerror;
});
hooks.afterEach(function() {
Ember.onerror = onerror;
});
test('it fails when passed a number', async function(assert) {
let stub = sinon.stub();
Ember.onerror = stub;
await render(hbs`{{zip-filter 98101}}`);
assert.ok(stub.withArgs(sinon.match({
message: 'Assertion Failed: zip-filter helper expected a string. Got a number instead.'
})).calledOnce);
}); I guess this can be closed now? |
I still think this is a bug. |
But thanks for sharing the workaround! |
Agreed. Though the actual details of how to implement this properly are non-trivial. I will try to gather better info and report here... |
👍 Chiming in as someone who is being affected by this Ember 3.3 Noting neither this workaround or the one @kellyselden mentioned above worked for me. Noting I'm coming to this not when rendering fails, but when a click throws an error, but assuming its the same issue with the render queue Test test('Handles not having action passed in', async function(assert) {
await render(hbs`{{async-button}}`);
assert.throws(
async () => {
await click(find('.async-button'));
},
'Throws exception when action not passed in'
);
}); Relevant piece of component (within click handler) else {
throw new Error('missing passed in action to async-button');
} |
@Frozenfire92 out of curiosity, what happens if you do this instead: assert.throws(
() => this.$('.async-button').click(),
'Throws exception when action not passed in'
); I'm running into the same issue as you and only using jQuery works; neither |
This twiddle reproduces the issue. TLDRThere is a component that will throw an error if two attrs arent passed in ( There are three tests:
Here is where things go wrong:
|
@nlfurniss switching to jquery worked for me, not ideal but a temp fix until this issue is resolved, thanks! |
Are there any updates to this? I was going through a bunch of my tests where they referenced checking up on this issue. Just wanted to make sure there are still no other options than what's mentioned here. |
Any news about this? After more than 2 years? |
I've started a PR to finally fix this: #1194. I would appreciate your thoughts! |
I would have expected this test to pass, but it fails with "expected not to get here" in addition to an out-of-band qunit failure for the actual
Compiler Error: not-a-component is not a helper
.The text was updated successfully, but these errors were encountered: