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

Avoid await settled() in teardown when using async leak detection. #408

Merged
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
22 changes: 16 additions & 6 deletions addon-test-support/ember-qunit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export { module, test, skip, only, todo } from 'qunit';
export { loadTests } from './test-loader';

import { run } from '@ember/runloop';
import { assign } from '@ember/polyfills';
import { loadTests } from './test-loader';
import Ember from 'ember';
import QUnit from 'qunit';
Expand All @@ -21,7 +22,11 @@ import {
} from '@ember/test-helpers';
import { installTestNotIsolatedHook } from './test-isolation-validation';

export function setupTest(hooks, options) {
let waitForSettled = true;

export function setupTest(hooks, _options) {
let options = _options === undefined ? { waitForSettled } : assign({ waitForSettled }, _options);

hooks.beforeEach(function(assert) {
return setupContext(this, options).then(() => {
let originalPauseTest = this.pauseTest;
Expand All @@ -34,31 +39,35 @@ export function setupTest(hooks, options) {
});

hooks.afterEach(function() {
return teardownContext(this);
return teardownContext(this, options);
});
}

export function setupRenderingTest(hooks, options) {
export function setupRenderingTest(hooks, _options) {
let options = _options === undefined ? { waitForSettled } : assign({ waitForSettled }, _options);

setupTest(hooks, options);

hooks.beforeEach(function() {
return setupRenderingContext(this);
});

hooks.afterEach(function() {
return teardownRenderingContext(this);
return teardownRenderingContext(this, options);
});
}

export function setupApplicationTest(hooks, options) {
export function setupApplicationTest(hooks, _options) {
let options = _options === undefined ? { waitForSettled } : assign({ waitForSettled }, _options);

setupTest(hooks, options);

hooks.beforeEach(function() {
return setupApplicationContext(this);
});

hooks.afterEach(function() {
return teardownApplicationContext(this);
return teardownApplicationContext(this, options);
});
}

Expand Down Expand Up @@ -147,6 +156,7 @@ export function setupEmberOnerrorValidation() {
}

export function setupTestIsolationValidation() {
waitForSettled = false;
run.backburner.DEBUG = true;
QUnit.on('testStart', installTestNotIsolatedHook);
}
Expand Down