Skip to content

Commit 0ba0745

Browse files
author
Robert Jackson
authored
Merge pull request #204 from bmish/bmishkin/before-each-async
fix: handle async lifecycle hooks like beforeEach
2 parents 5a51fc3 + 8e6e8fb commit 0ba0745

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { moduleForComponent, test } from 'ember-qunit';
2+
import wait from 'ember-test-helpers/wait';
3+
import hbs from 'htmlbars-inline-precompile';
4+
5+
moduleForComponent('foo-bar', 'Integration | Component | FooBar', {
6+
integration: true,
7+
async beforeEach() {
8+
await doStuff();
9+
},
10+
});
11+
12+
test('it happens', function() {
13+
this.render(hbs`derp`);
14+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
3+
import { render, settled } from '@ember/test-helpers';
4+
import hbs from 'htmlbars-inline-precompile';
5+
6+
module('Integration | Component | FooBar', function(hooks) {
7+
setupRenderingTest(hooks);
8+
9+
hooks.beforeEach(async function() {
10+
await doStuff();
11+
});
12+
13+
test('it happens', async function() {
14+
await render(hbs`derp`);
15+
});
16+
});

transforms/convert-module-for-to-setup-test/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ module.exports = function(file, api) {
394394
? j.functionExpression(null, property.params, property.body)
395395
: property.value;
396396

397+
if (property.async) {
398+
value.async = true;
399+
}
400+
397401
if (moduleInfo.setupType) {
398402
let expressionCollection = j(value);
399403

0 commit comments

Comments
 (0)