Having recently migrated Ember CLI from 2.15.0 to 3.7.0, the acceptance tests have regressed heavily. Having run the qunit codemod, the following issue seems to persist: UnrecognizedURLError: /tests
.
I have produced a minimum reproduction of the issue via the following acceptance test:
import { module, test } from 'qunit';
import { visit, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
module('Acceptance | poc', function(hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
test('visiting /poc', async function(assert) {
await visit('/');
assert.equal(currentURL(), '/');
});
});
This results on the three following issues:
Promise rejected before "visiting /poc": /tests?filter=poc
Source: UnrecognizedURLError: /tests?filter=poc
beforeEach failed on visiting /poc: You must call one of the ember-qunit setupTest(), setupRenderingTest() or setupApplicationTest() methods before calling setupMirage()
Source: Error: You must call one of the ember-qunit setupTest(), setupRenderingTest() or setupApplicationTest() methods before calling setupMirage()
Promise rejected after "visiting /poc": Cannot use 'in' operator to search for 'destroy' in undefined@ 80 ms
Source: TypeError: Cannot use 'in' operator to search for 'destroy' in undefined
Any advice would be greatly appreciated!
As @jelhan points to in the comment above, the issue here is missing test
environment settings within the environment.js
configuration.
To fix the UnrecognizedURLError
, adding ENV.locationType = 'none'
satisfies the requirements of testem.
I also replaced the other environment variables found in the linked block.
My test environment configuration now looks like this:
else if(environment === 'test') {
ENV.locationType = 'none';
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
ENV.APP.autoboot = false;
}