Skip to content

Commit

Permalink
Run scenarios with expected Ember CLI version (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
jelhan authored Oct 27, 2021
1 parent 73e5736 commit c521082
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ jobs:
matrix:
ember-cli: [
"~3.4.0",
"~3.8.0",
"~3.12.0",
"~3.16.0",
"~3.20.0",
Expand Down Expand Up @@ -176,9 +175,11 @@ jobs:
steps.cache-dependencies.outputs.cache-hit != 'true'
- name: Install Ember CLI
run: yarn global add ember-cli@${EMBER_CLI_VERSION}
run: |
yarn global add ember-cli@${EMBER_CLI_VERSION}
echo "$(yarn global bin)" >> $GITHUB_PATH
env:
EMBER_CLI_VERSION: ${{ matrix.ember-cli }}

- name: Test
run: yarn test:node
run: ./node_modules/.bin/mocha node-tests/**/*-test.js
13 changes: 10 additions & 3 deletions node-tests/e2e/test-support-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ async function adjustForCompatibility(testProject) {
// internally unless configured to not do so. This violates the default CSP and causes an
// `EvalError` to be thrown. This uncatched error will cause the tests to fail - regardless
// of our custom test support.
// To avoid this issue we uninstall Ember Auto Import for these tests. This can be removed
// as soon as Ember CLI Content Security Policy works out of the box with Ember Auto Import.
// We need to adjust Ember Auto Import's configuration prevent this. It can be removed as
// soon as Ember CLI Content Security Policy works out of the box with Ember Auto Import.
try {
await testProject.runCommand('yarn', 'remove', 'ember-auto-import');
const emberCliBuildJs = await testProject.readFile('ember-cli-build.js');
await testProject.writeFile(
'ember-cli-build.js',
emberCliBuildJs.replace(
'// Add options here',
'autoImport: { forbidEval: true }'
)
);
} catch (error) {
// Trying to remove ember-auto-import dependency may fail cause that dependency is not
// present for older Ember CLI versions.
Expand Down
16 changes: 16 additions & 0 deletions node-tests/e2e/test-support-warns-on-outdated-qunit-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const expect = require('chai').expect;
const TestProject = require('ember-addon-tests').default;
const path = require('path');
const { readPackageJson } = require('../utils');

describe('e2e: test support warns if dependencies are not supported', function () {
this.timeout(300000);
Expand All @@ -11,9 +12,24 @@ describe('e2e: test support warns if dependencies are not supported', function (
});

await testProject.createEmberApp();

// ember-qunit was upgraded to 5.x and qunit added as a direct dependency
// in Ember CLI 3.24.0. This test can not be performed for such new Ember
// CLI versions.
const packageJson = await readPackageJson(testProject);
const hasQunitAsDirectDependency = Object.keys(
packageJson.devDependencies
).includes('qunit');
if (hasQunitAsDirectDependency) {
return;
}

await testProject.addOwnPackageAsDevDependency(
'ember-cli-content-security-policy'
);

// Ensure that projects uses an old ember-qunit version, which depends on
// incompatible qunit version.
await testProject.addDevDependency('ember-qunit', '4.0.0');

try {
Expand Down

0 comments on commit c521082

Please sign in to comment.