diff --git a/blueprints/app/files/tests/helpers/.gitkeep b/blueprints/app/files/tests/helpers/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/blueprints/app/files/tests/helpers/destroy-app.js b/blueprints/app/files/tests/helpers/destroy-app.js deleted file mode 100644 index e7f983bd14..0000000000 --- a/blueprints/app/files/tests/helpers/destroy-app.js +++ /dev/null @@ -1,5 +0,0 @@ -import { run } from '@ember/runloop'; - -export default function destroyApp(application) { - run(application, 'destroy'); -} diff --git a/blueprints/app/files/tests/helpers/module-for-acceptance.js b/blueprints/app/files/tests/helpers/module-for-acceptance.js deleted file mode 100644 index 90a93bac2b..0000000000 --- a/blueprints/app/files/tests/helpers/module-for-acceptance.js +++ /dev/null @@ -1,21 +0,0 @@ -import { module } from 'qunit'; -import { resolve } from 'rsvp'; -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; - -export default function(name, options = {}) { - module(name, { - beforeEach() { - this.application = startApp(); - - if (options.beforeEach) { - return options.beforeEach.apply(this, arguments); - } - }, - - afterEach() { - let afterEach = options.afterEach && options.afterEach.apply(this, arguments); - return resolve(afterEach).then(() => destroyApp(this.application)); - } - }); -} diff --git a/blueprints/app/files/tests/helpers/start-app.js b/blueprints/app/files/tests/helpers/start-app.js deleted file mode 100644 index 99d35dcf4e..0000000000 --- a/blueprints/app/files/tests/helpers/start-app.js +++ /dev/null @@ -1,17 +0,0 @@ -import Application from '../../app'; -import config from '../../config/environment'; -import { merge } from '@ember/polyfills'; -import { run } from '@ember/runloop'; - -export default function startApp(attrs) { - let attributes = merge({}, config.APP); - attributes.autoboot = true; - attributes = merge(attributes, attrs); // use defaults, but you can override; - - return run(() => { - let application = Application.create(attributes); - application.setupForTesting(); - application.injectTestHelpers(); - return application; - }); -} diff --git a/blueprints/module-unification-app/files/tests/helpers/.gitkeep b/blueprints/module-unification-app/files/tests/helpers/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/blueprints/module-unification-app/files/tests/helpers/destroy-app.js b/blueprints/module-unification-app/files/tests/helpers/destroy-app.js deleted file mode 100644 index e7f983bd14..0000000000 --- a/blueprints/module-unification-app/files/tests/helpers/destroy-app.js +++ /dev/null @@ -1,5 +0,0 @@ -import { run } from '@ember/runloop'; - -export default function destroyApp(application) { - run(application, 'destroy'); -} diff --git a/blueprints/module-unification-app/files/tests/helpers/module-for-acceptance.js b/blueprints/module-unification-app/files/tests/helpers/module-for-acceptance.js deleted file mode 100644 index 90a93bac2b..0000000000 --- a/blueprints/module-unification-app/files/tests/helpers/module-for-acceptance.js +++ /dev/null @@ -1,21 +0,0 @@ -import { module } from 'qunit'; -import { resolve } from 'rsvp'; -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; - -export default function(name, options = {}) { - module(name, { - beforeEach() { - this.application = startApp(); - - if (options.beforeEach) { - return options.beforeEach.apply(this, arguments); - } - }, - - afterEach() { - let afterEach = options.afterEach && options.afterEach.apply(this, arguments); - return resolve(afterEach).then(() => destroyApp(this.application)); - } - }); -} diff --git a/blueprints/module-unification-app/files/tests/helpers/start-app.js b/blueprints/module-unification-app/files/tests/helpers/start-app.js deleted file mode 100644 index 00f3e4f53e..0000000000 --- a/blueprints/module-unification-app/files/tests/helpers/start-app.js +++ /dev/null @@ -1,16 +0,0 @@ -import Application from '../../src/main'; -import config from '../../config/environment'; -import { run } from '@ember/runloop'; -import { merge } from '@ember/polyfills'; - -export default function startApp(attrs) { - let attributes = merge({}, config.APP); - attributes = merge(attributes, attrs); // use defaults, but you can override; - - return run(() => { - let application = Application.create(attributes); - application.setupForTesting(); - application.injectTestHelpers(); - return application; - }); -} diff --git a/tests/acceptance/smoke-test-slow.js b/tests/acceptance/smoke-test-slow.js index 9051dfa282..505dda2b47 100644 --- a/tests/acceptance/smoke-test-slow.js +++ b/tests/acceptance/smoke-test-slow.js @@ -152,7 +152,7 @@ describe('Acceptance: smoke-test', function() { output = output.join(EOL); expect(output).to.match(/fail\s+0/, 'no failures'); - expect(output).to.match(/pass\s+11/, '11 passing'); + expect(output).to.match(/pass\s+8/, '8 passing'); })); it('ember new foo, build development, and verify generated files', co.wrap(function *() { diff --git a/tests/fixtures/addon/component-with-template/tests/acceptance/main-test.js b/tests/fixtures/addon/component-with-template/tests/acceptance/main-test.js index 86b31bd6b7..88f6347bbe 100644 --- a/tests/fixtures/addon/component-with-template/tests/acceptance/main-test.js +++ b/tests/fixtures/addon/component-with-template/tests/acceptance/main-test.js @@ -1,30 +1,22 @@ -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; +import Ember from 'ember'; +import { setupApplicationTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; import { module, test } from 'qunit'; -module('Acceptance', { - beforeEach() { - this.application = startApp(); - }, - afterEach() { - destroyApp(this.application); - } -}); +module('Acceptance', function(hooks) { + setupApplicationTest(hooks); -test('renders properly', function(assert) { - visit('/'); + test('renders properly', async function(assert) { + await visit('/'); - andThen(function() { - var element = find('.basic-thing'); - assert.equal(element.first().text().trim(), 'WOOT!!'); + var element = this.element.querySelector('.basic-thing'); + assert.equal(element.textContent.trim(), 'WOOT!!'); }); -}); -test('renders imported component', function(assert) { - visit('/'); + test('renders imported component', async function(assert) { + await visit('/'); - andThen(function() { - var element = find('.second-thing'); - assert.equal(element.first().text().trim(), 'SECOND!!'); + var element = this.element.querySelector('.second-thing'); + assert.equal(element.textContent.trim(), 'SECOND!!'); }); }); diff --git a/tests/fixtures/addon/kitchen-sink/tests/acceptance/main-test.js b/tests/fixtures/addon/kitchen-sink/tests/acceptance/main-test.js index e38fea59aa..19175b8f25 100644 --- a/tests/fixtures/addon/kitchen-sink/tests/acceptance/main-test.js +++ b/tests/fixtures/addon/kitchen-sink/tests/acceptance/main-test.js @@ -1,32 +1,23 @@ -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; +import { setupApplicationTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; import truthyHelper from 'kitchen-sink/test-support/helper'; import { module, test } from 'qunit'; -module('Acceptance', { - beforeEach() { - this.application = startApp(); - }, - afterEach() { - destroyApp(this.application); - } -}); +module('Acceptance', function(hooks) { + setupApplicationTest(hooks); -test('renders properly', function(assert) { - visit('/'); + test('renders properly', async function(assert) { + await visit('/'); - andThen(function() { - var element = find('.basic-thing'); - assert.equal(element.first().text().trim(), 'WOOT!!'); + var element = this.element.querySelector('.basic-thing'); + assert.equal(element.textContent.trim(), 'WOOT!!'); assert.ok(truthyHelper(), 'addon-test-support helper'); }); -}); -test('renders imported component', function(assert) { - visit('/'); + test('renders imported component', async function(assert) { + await visit('/'); - andThen(function() { - var element = find('.second-thing'); - assert.equal(element.first().text().trim(), 'SECOND!!'); + var element = this.element.querySelector('.second-thing'); + assert.equal(element.textContent.trim(), 'SECOND!!'); }); }); diff --git a/tests/fixtures/brocfile-tests/default-development/tests/integration/app-boots-test.js b/tests/fixtures/brocfile-tests/default-development/tests/integration/app-boots-test.js index 463e4f49f1..4de7473168 100644 --- a/tests/fixtures/brocfile-tests/default-development/tests/integration/app-boots-test.js +++ b/tests/fixtures/brocfile-tests/default-development/tests/integration/app-boots-test.js @@ -1,23 +1,15 @@ import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; +import { setupApplicationTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; import { module, test } from 'qunit'; -module('default-development - Integration', { - beforeEach() { - this.application = startApp(); - }, - afterEach() { - destroyApp(this.application); - } -}); - -test('the application boots properly', function(assert) { - assert.expect(1); +module('default-development - Integration', function(hook) { + setupApplicationTest(hooks); - visit('/'); + test('renders properly', async function(assert) { + await visit('/'); - andThen(function() { - assert.ok(Ember.$('.ember-view').length > 0); + var elements = this.element.querySelectorAll('.ember-view'); + assert.ok(elements.length > 0); }); }); diff --git a/tests/fixtures/brocfile-tests/pods-templates/tests/integration/pods-template-test.js b/tests/fixtures/brocfile-tests/pods-templates/tests/integration/pods-template-test.js index c3f935290f..d2e335881c 100644 --- a/tests/fixtures/brocfile-tests/pods-templates/tests/integration/pods-template-test.js +++ b/tests/fixtures/brocfile-tests/pods-templates/tests/integration/pods-template-test.js @@ -1,23 +1,17 @@ import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; +import { setupApplicationTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; import { module, test } from 'qunit'; -module('pods based templates', { - beforeEach() { - this.application = startApp(); - }, - afterEach() { - destroyApp(this.application); - } -}); +module('pods based templates', function(hooks) { + setupApplicationTest(hooks); -test('the application boots properly with pods based templates', function(assert) { - assert.expect(1); + test('the application boots properly with pods based templates', async function(assert) { + assert.expect(1); - visit('/'); + await visit('/'); - andThen(function() { - assert.equal(Ember.$('#title').text(), 'ZOMG, PODS WORKS!!'); + let actual = this.element.querySelector('#title').textContent + assert.equal(actual, 'ZOMG, PODS WORKS!!'); }); }); diff --git a/tests/fixtures/brocfile-tests/pods-with-prefix-templates/tests/integration/pods-template-test.js b/tests/fixtures/brocfile-tests/pods-with-prefix-templates/tests/integration/pods-template-test.js index 9c8795dd76..0d6c81e254 100644 --- a/tests/fixtures/brocfile-tests/pods-with-prefix-templates/tests/integration/pods-template-test.js +++ b/tests/fixtures/brocfile-tests/pods-with-prefix-templates/tests/integration/pods-template-test.js @@ -1,24 +1,17 @@ import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; +import { setupApplicationTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; import { module, test } from 'qunit'; -module('pods based templates', { - beforeEach() { - this.application = startApp(); - }, - afterEach() { - destroyApp(this.application); - } -}); - +module('pods based templates', function(hooks) { + setupApplicationTest(hooks); -test('the application boots properly with pods based templates with a podModulePrefix set', function(assert) { - assert.expect(1); + test('the application boots properly with pods based templates with a podModulePrefix set', async function(assert) { + assert.expect(1); - visit('/'); + await visit('/'); - andThen(function() { - assert.equal(Ember.$('#title').text(), 'ZOMG, PODS WORKS!!'); + let actual = this.element.querySelector('#title').textContent + assert.equal(actual, 'ZOMG, PODS WORKS!!'); }); }); diff --git a/tests/fixtures/smoke-tests/passing-test/tests/acceptance/acceptance-test.js b/tests/fixtures/smoke-tests/passing-test/tests/acceptance/acceptance-test.js index 995c694893..a6da5ad481 100644 --- a/tests/fixtures/smoke-tests/passing-test/tests/acceptance/acceptance-test.js +++ b/tests/fixtures/smoke-tests/passing-test/tests/acceptance/acceptance-test.js @@ -1,23 +1,20 @@ -import moduleForAcceptance from '../helpers/module-for-acceptance'; -import QUnit from 'qunit'; +import { setupApplicationTest } from 'ember-qunit'; +import QUnit, { module, test } from 'qunit'; -let application, firstArgument; +let firstArgument; -moduleForAcceptance('Module', { - beforeEach(assert) { - application = this.application; - firstArgument = assert; - }, +module('Module', function(hooks) { + setupApplicationTest(hooks); - afterEach() { - console.log('afterEach called'); - } -}); + hooks.beforeEach(function(assert) { + firstArgument = assert; + }); -QUnit.test('it works', function(assert) { - assert.ok(application, 'beforeEach binds to the setup context'); - assert.ok( - Object.getPrototypeOf(firstArgument) === QUnit.assert, - 'first argument is QUnit assert' - ); + test('it works', function(assert) { + assert.ok(this.owner, 'setupApplicationTest binds to the context'); + assert.ok( + Object.getPrototypeOf(firstArgument) === QUnit.assert, + 'first argument is QUnit assert' + ); + }); });