testing ember's glimmer components

2021-03-24

 | 

~1 min read

 | 

127 words

We recently began updating some of our classic components to Glimmer and writing new components as Glimmer components. It was not initially obvious how to write unit tests for these new components however.

It turns out to be an easy fix!

Ember testing is mostly done with qunit, however, Glimmer tests will not render correctly (and consequently tests will fail) if you use the qunit’s render method. The solution is to replace qunit’s render method with the render method from the @ember/test-helpers package.

-  import { render } from 'ember-qunit';
+  import { render } from '@ember/test-helpers';

@ember/test-helpers is already the package that’s used for things like find, click, etc. so it is likely already available.

For more on testing components, see the Ember docs.



Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!