ember.jsintegration-testingember-qunit

Error: 'ReferenceError: pauseTest is not defined' in integration tests with moduleForComponent syntax


The pauseTest() function from ember-qunit does not work as expected in Integration tests with the old syntax

import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('my-component, 'Integration | Component | MyComponent', {
  integration: true
});

test('it renders', function(assert) {
  return pauseTest();
  this.render(hbs`{{my-component}}/>`);
  ...
}

Failed:

Died on test #1     at Module.callback (http://localhost:4200/assets/tests.js:118959:24)
at Module.exports (http://localhost:4200/assets/vendor.js:111:32)
at requireModule (http://localhost:4200/assets/vendor.js:32:18)
at EmberExamQUnitTestLoader.<anonymous> (http://localhost:4200/assets/test-support.js:29031:11)
  at EmberExamQUnitTestLoader.require (http://localhost:4200/assets/test-support.js:29021:27)
at http://localhost:4200/assets/test-support.js:29545:90
  at Array.forEach (<anonymous>): pauseTest is not defined@ 698 ms
  Source:
  ReferenceError: pauseTest is not defined
  at Object.<anonymous> (http://localhost:4200/assets/tests.js:118960:5)
    at runTest (http://localhost:4200/assets/test-support.js:20889:30)
    at Test.run (http://localhost:4200/assets/test-support.js:20875:6)
    at http://localhost:4200/assets/test-support.js:21096:12
    at advanceTaskQueue (http://localhost:4200/assets/test-support.js:20488:6)
    at Object.advance (http://localhost:4200/assets/test-support.js:20469:4)
    at begin (http://localhost:4200/assets/test-support.js:22241:20)
    at http://localhost:4200/assets/test-support.js:21483:6

It's working fine in Acceptance tests, because of:

// ./tests/helpers/start-app.js
export default function startApp(attrs) {
  ...
    application.injectTestHelpers();
  ...
}

How to make it works in Integration tests?

Note: In modern syntax, it's working fine too:

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Component | MyComponent', function(hooks) {
  test('it renders', async function(assert) {
    return this.pauseTest();
    await render(hbs`{{my-component}}/>`);
  });
}

Solution

  • workaround:

    import { moduleForComponent, test } from 'ember-qunit';
    import hbs from 'htmlbars-inline-precompile';
    import Ember from 'ember';
    
    moduleForComponent('my-component, 'Integration | Component | MyComponent', {
      integration: true
    });
    
    test('it renders', function(assert) {
      return Ember.Test._helpers.pauseTest.method();
      this.render(hbs`{{my-component}}/>`);
      ...
    }
    
    

    source: https://github.com/emberjs/ember-mocha/issues/75#issuecomment-263142520