I’m new to Ember and working through the Super Rentals tutorial. Loving it so far! I reached the first acceptance testing section and successfully created the super-rentals-test.js file. However, when I replace the code with the example in the tutorial, I get errors.
Line 3: Parsing error: identifier ‘visit’ has already been declared. (3:16) eslint Line 24: ‘}’ expected. ts(1005)
If I try to remove the duplicate ‘visit’ import, then currentURL shows the same error. If I remove the duplicate ‘currentURL’, then I get this error later in the code:
Line 10: Using QUnit.test inside of another QUnit.test is not allowed. eslint(quint/no-nested-tests)
…which wasn’t an issue until I removed the duplicate imports.
Adding }); at the end resolved the Line 24 error since the module wasn’t closed.
This is the provided code, copy and pasted:
import { module, test } from ‘qunit’; import { visit, currentURL } from ‘@ember/test-helpers’; import { click, visit, currentURL } from ‘@ember/test-helpers’; import { setupApplicationTest } from ‘super-rentals/tests/helpers’;
module(‘Acceptance | super rentals’, function (hooks) { setupApplicationTest(hooks);
test(‘visiting /super-rentals’, async function (assert) { await visit(‘/super-rentals’); test(‘visiting /’, async function (assert) { await visit(‘/’);
assert.strictEqual(currentURL(), '/super-rentals');
assert.strictEqual(currentURL(), '/');
assert.dom('h2').hasText('Welcome to Super Rentals!');
assert.dom('.jumbo a.button').hasText('About Us');
await click('.jumbo a.button');
assert.strictEqual(currentURL(), '/about');
}); });
Any help would be greatly appreciated. I tried searching for a similar topic but couldn’t find one (or didn’t know how to word the search well enough to find one.)