ember-test-helpers: render does not reject when rendering fails

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.

test('render can throw', async function(assert) {
  try {
    await render(hbs`{{not-a-component x="y"}}`);
  } catch (err) {
    assert.ok(/not-a-component is not a helper/.test(err.message), "expected to see failure");
  }
  throw new Error("expected not to get here");
});

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 7
  • Comments: 15 (11 by maintainers)

Most upvoted comments

I’ve started a PR to finally fix this: #1194. I would appreciate your thoughts!

Any news about this? After more than 2 years?

This twiddle reproduces the issue.

TLDR

There is a component that will throw an error if two attrs arent passed in (x and y) and the component is clicked on.

There are three tests:

  1. Ensure no errors if both attrs passed in and component is clicked ✅
  2. Ensure an error is throw is only one attr is passed in and component is clicked (uses native JS and tests fails) ❌
  3. Ensure an error is throw is only one attr is passed in and component is clicked (uses jquery and test passes) ✅

Here is where things go wrong:

// Qunit throws
try {
   block.call(currentTest.testEnvironment);  <====== This call doesnt trigger an error when it uses native JS. But FUN FACT: if you highlight this line at a breakpoint, it will log an error (???)
} catch (e) {
   actual = e;
}
...
if (actual) {     <==== `actual` needs to be set otherwise it wont catch the error and the test will fail.

I still think this is a bug. render should throw.

This appears to be a bit stale, but I would love some workarounds as well.