mercredi 31 juillet 2019

TypeError when using before all hook in ember mocha

I'm running into some issues with the before all hook in ember-mocha (version 0.14.0). Here's an example from the docs that's been slightly modified to include a beforeEach hook:

import { expect } from 'chai';
import { describe, it } from 'mocha';
import { setupApplicationTest } from 'ember-mocha';
import { visit, currentURL } from '@ember/test-helpers';

describe('basic acceptance test', function() {
  setupApplicationTest();

  beforeEach(async function() {
    await visit('index');
  });

  it('can visit /', async function() {
    await visit('/');
    expect(currentURL()).to.equal('/');
  });
});

The above test runs as expected with no issues. However, when I substitute before for beforeEach I encounter an error:

import { expect } from 'chai';
import { describe, it } from 'mocha';
import { setupApplicationTest } from 'ember-mocha';
import { visit, currentURL } from '@ember/test-helpers';

describe('basic acceptance test', function() {
  setupApplicationTest();

  before(async function() {
    await visit('index');
  });

  it('can visit /', async function() {
    await visit('/');
    expect(currentURL()).to.equal('/');
  });
});

TypeError: Cannot destructure property `owner` of 'undefined' or 'null'.
    at visit (assets/test-support.js:24931:9)
    at Context.<anonymous> (assets/tests.js:339:36)
    at invoke (assets/test-support.js:22801:21)
    at Context.asyncFn (assets/test-support.js:22786:11)
    at callFnAsync (assets/test-support.js:14070:8)
    at Hook.Runnable.run (assets/test-support.js:14022:7)
    at next (assets/test-support.js:14386:10)
    at assets/test-support.js:14408:5
    at timeslice (assets/test-support.js:9651:27)

Please let me know if any clarification is needed. Thanks in advance for your help!




Aucun commentaire:

Enregistrer un commentaire