Skip to content
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

[BUGFIX lts] Cleans up the DebugRenderTree more thoroughly on errors #19199

Merged
merged 1 commit into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ export default class DebugRenderTree<Bucket extends object = object> {

// TODO: We could warn here? But this happens all the time in our tests?

// Clean up the root reference to prevent errors from happening if we
// attempt to capture the render tree (Ember Inspector may do this)
let root = expect(this.stack.toArray()[0], 'expected root state when resetting render tree');
let ref = this.refs.get(root);

if (ref !== undefined) {
this.roots.delete(ref);
}

while (!this.stack.isEmpty()) {
this.stack.pop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,28 @@ if (ENV._DEBUG_RENDER_TREE) {
this.assert.strictEqual(actual, expected, `Matching ${path}`);
}
}

async '@test cleans up correctly after errors'(assert: Assert) {
this.addTemplate(
'application',
strip`
<HelloWorld @name="first" />
`
);

this.addComponent('hello-world', {
ComponentClass: Component.extend({
init() {
throw new Error('oops!');
},
}),
template: 'Hello World',
});

await assert.rejectsAssertion(this.visit('/'), /oops!/);

assert.deepEqual(captureRenderTree(this.owner), [], 'there was no output');
}
}
);
}