-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
Expose importable helper functions. #222
Conversation
What were the arguments leading to this decision? |
@Turbo87 roughly that the following "rightward" shift is something we can avoid: test('foo', function(assert) {
await this.visit('/some-path');
await this.click('.some-link');
await this.fillIn('.other-thing', 'derpy');
await this.click('.submit');
// assertions here
}); In the new system we are adding both Exposing the importable helpers (that simply defer to the import {
visit,
click,
fillIn
} from 'ember-qunit';
// ...snip...
test('foo', function(assert) {
await visit('/some-path');
await click('.some-link');
await fillIn('.other-thing', 'derpy');
await click('.submit');
// assertions here
}); |
I was a strong advocate for leaving the helper methods on the test context for discoverability, others were strongly opposed to the aesthetic of the rightward shift (as mentioned above). So I proposed this compromise (which satisfies both camps)... |
While |
Sounds good. I’ll remove element. |
We could also expose element as a function ( |
These functions can be used instead of repeating `this.` throughout the testing code. Example: ```js import { module, test } from 'qunit'; import { setupRenderingTest, render, element } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; module('x-foo', function(hooks) { setupRenderingTest(hooks); test('renders', async function(assert) { assert.expect(1); await render(hbs`{{pretty-color name="red"}}`); assert.equal(element.querySelector('.color-name').textContent, 'red'); }); }); ```
Might bring it back later in a different incarnation, but removing for now.
acdd479
to
2240194
Compare
These functions can be used instead of repeating
this.
throughout the testing code.Example:
This is essentially the compromise made with the rest of the core team while working on the the "Grand Unified Testing RFC". The helpers will continue to live on
this
(for easy discoverability), but are also importable (for cleaner looking tests). Using the nonthis.
form of helpers obviously means that we cannot run concurrent tests, but that is extremely unlikely to work anyways.