ember-cli / ember-cli-qunit

QUnit testing package for ember-cli applications
MIT License
30 stars 55 forks source link

skipping first test in a module leaves module undefined during test hooks #179

Closed noslouch closed 7 years ago

noslouch commented 7 years ago

This seems like the same issue as emberjs/ember-qunit#269, but this is happening in a fresh ember-cli project, which does not explicitly install ember-qunit.

I noticed that ember-cli-qunit doesn't include the updated ember-qunit/qunit versions. This issue is partly a reminder to update ember-cli-qunit with the version of ember-qunit that includes the upstream fix in qunit, but also include a reduced case for this particular issue.

I can't quite get ember-twiddle to load up the proper version of things, but I can provide a reduced test case in this issue with samples of relevant code.

I ran the following generator commands and made a small series of edits to the boilerplate test file included here:

$ ember -v
ember-cli: 2.12.1
node: 6.9.2
os: darwin x64

$ ember new skip-test && cd skip-test
...
$ ember g component x-foo
// skip-test/tests/integration/components/skip-test-test.js
import { moduleForComponent, test, skip } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('skip-test', 'Integration | Component | skip test', {
  integration: true
});

skip('it renders', function(assert) {

  // Set any properties with this.set('myProperty', 'value');
  // Handle any actions with this.on('myAction', function(val) { ... });

  this.render(hbs`{{skip-test}}`);

  assert.equal(this.$().text().trim(), '');

  // Template block usage:
  this.render(hbs`
    {{#skip-test}}
      template block text
    {{/skip-test}}
  `);

  assert.equal(this.$().text().trim(), 'template block text');
});

test('test runs', function(assert) {
  assert.ok(true);
});
$ ember t
cleaning up...
Built project successfully. Stored in "/private/tmp/skip-test/tmp/class-tests_dist-zk8FKYth.tmp".
ok 1 PhantomJS 2.1 - ESLint - app.js: should pass ESLint
ok 2 PhantomJS 2.1 - ESLint - components/skip-test.js: should pass ESLint
ok 3 PhantomJS 2.1 - ESLint - helpers/destroy-app.js: should pass ESLint
ok 4 PhantomJS 2.1 - ESLint - helpers/module-for-acceptance.js: should pass ESLint
ok 5 PhantomJS 2.1 - ESLint - helpers/resolver.js: should pass ESLint
ok 6 PhantomJS 2.1 - ESLint - helpers/start-app.js: should pass ESLint
skip 7 PhantomJS 2.1 - Integration | Component | skip test: it renders
not ok 8 PhantomJS 2.1 - Integration | Component | skip test: test runs
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            beforeEach@http://localhost:7357/assets/test-support.js:5396:15
            callHook@http://localhost:7357/assets/test-support.js:1479:26
            runHook@http://localhost:7357/assets/test-support.js:1473:15
            advance@http://localhost:7357/assets/test-support.js:1106:26
            begin@http://localhost:7357/assets/test-support.js:2779:27
            http://localhost:7357/assets/test-support.js:2739:11
        message: >
            beforeEach failed on test runs: undefined is not an object (evaluating 'module.setContext')
        Log: |
    ...
ok 9 PhantomJS 2.1 - ESLint - integration/components/skip-test-test.js: should pass ESLint
ok 10 PhantomJS 2.1 - ESLint - resolver.js: should pass ESLint
ok 11 PhantomJS 2.1 - ESLint - router.js: should pass ESLint
ok 12 PhantomJS 2.1 - ESLint - test-helper.js: should pass ESLint

1..12
# tests 12
# pass  10
# skip  1
# fail  1
Testem finished with non-zero exit code. Tests failed.
rwjblue commented 7 years ago

It is the same issue as linked in the intro. ember-qunit is a dependency of ember-cli-qunit, and this bug was fixed upstream in QUnit.

@trentmwillis - Do you think a release of QUnit will be out in a few days, or should we revert the changes in ember-qunit (instead of using before we would just always create the module in beforeEach) and revert the revert after QUnit release?

trentmwillis commented 7 years ago

I'm planning on trying to do a release today. Was waiting for a couple PRs to land.

rwjblue commented 7 years ago

👍 - Awesome, thank you @trentmwillis!

trentmwillis commented 7 years ago

A fresh npm install should resolve this as qunitjs@2.3.2 is now released. Please reopen if it persists.

BryanCrotaz commented 6 years ago

I'm seeing this with ember-cli-qunit@4.1.1

rwjblue commented 6 years ago

Please open a new issue with a reproduction...