glimmerjs/glimmer.js

Overhaul Testing Infrastructure

pzuraq opened this issue · 4 comments

There are a few things about the testing infrastructure that need to be addressed moving forward:

  • Currently render() and settled() return a string containing the HTML output. This is a good way to get started with many types of tests, doesn't give us much flexibility. A better solution would be to incorporate QUnit.dom so that we can make assertions based on the output of a render, without having to worry about details like finding the QUnit render element.

  • render() should instead return the result of the call to renderComponent(). Currently, this is void, but we should add an API to control the rendered output with at least one method: destroy(). This would be useful for the embedding use cases, but also for simplifying tests, since it would allow us to manually destroy the component tree instead of using existing hacks like wrapping it in an {{#if}} and toggling the property.

  • We should add better DOM interaction functions. Ideally, we would genericize @ember/test-helpers and make it so they can work anywhere, then just use those.

  • We should rewrite the existing tests to use the new tracked() helper. Currently there are a number of tests that capture the instance of a component and try to manipulate it directly to ensure updates. This is a lot of boilerplate, and not really necessary in many cases.

Hey @pzuraq, I am new to Glimmer.js and would like to contribute to it. Can I pick this issue for my first contribution?

Yep, this would be great for a first issue 😄 I would recommend tackling each issue one at a time with separate PRs, so we can review them individually. Happy to help discuss the path for each change, in particular genericizing @ember/test-helpers might be a bit tricky.

Hey @pzuraq,

PR to refactor tests to use tracked utility. #283

Meeting notes on 4/23:

  • First item, we need a strategy here long term, but it's going to be tricky so we are going to wait for the time being.

  • Second item, we need to discuss this in the Glimmer.js team and make a decision about what we want to do here. Could just return the component instance.

  • Third item, we're going to move forward with breaking out ember-test-helpers into two packages, a normal node package that exports the test helpers as is, and a thin Ember addon wrapper.