Skip to content

Commit

Permalink
Enable embroider-safe ember-try scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Aug 17, 2021
1 parent c1d458e commit e82f784
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 35 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
- ember-canary
- ember-classic
- ember-default-with-jquery
- embroider-safe

steps:
- uses: actions/checkout@v2
Expand Down
53 changes: 53 additions & 0 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,45 @@

const getChannelURL = require('ember-source-channel-url');

const EMBROIDER_VERSION = '^0.43.4';
const embroider = {
safe: {
name: 'embroider-safe',
npm: {
devDependencies: {
'@embroider/core': EMBROIDER_VERSION,
'@embroider/webpack': EMBROIDER_VERSION,
'@embroider/compat': EMBROIDER_VERSION,
'@embroider/test-setup': EMBROIDER_VERSION,

// Webpack is a peer dependency of `@embroider/webpack`
webpack: '^5.0.0',
},
},
env: {
EMBROIDER_TEST_SETUP_OPTIONS: 'safe',
},
},

optimized: {
name: 'embroider-optimized',
npm: {
devDependencies: {
'@embroider/core': EMBROIDER_VERSION,
'@embroider/webpack': EMBROIDER_VERSION,
'@embroider/compat': EMBROIDER_VERSION,
'@embroider/test-setup': EMBROIDER_VERSION,

// Webpack is a peer dependency of `@embroider/webpack`
webpack: '^5.0.0',
},
},
env: {
EMBROIDER_TEST_SETUP_OPTIONS: 'optimized',
},
},
};

module.exports = async function () {
return {
useYarn: true,
Expand Down Expand Up @@ -103,6 +142,20 @@ module.exports = async function () {
devDependencies: {},
},
},
embroider.safe,
// disable embroider optimized test scenarios, as the dynamism these
// tests use is not compatible with embroider we are still exploring
// appropriate paths forward.
//
// Steps to re-enable:
//
// 1. have a strategy to make this work
// 2. uncomment the next line
// embroider.optimized,
//
// 3. add "embroider-optimized" to .github/workflows/ci-build.yml's
// ember-try-scenario list.
//
],
};
};
25 changes: 13 additions & 12 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function (defaults) {
let app = new EmberAddon(defaults, {
autoImport: {
exclude: ['qunit'],
},
});

app.import('node_modules/qunit/qunit/qunit.js', {
type: 'test',
});
let app = new EmberAddon(defaults);

app.import('node_modules/qunit/qunit/qunit.css', {
type: 'test',
});

app.import('vendor/shims/qunit.js', { type: 'test' });

return app.toTree();
try {
const { maybeEmbroider } = require('@embroider/test-setup'); // eslint-disable-line node/no-missing-require
return maybeEmbroider(app);
} catch (e) {
// This exists, so that we can continue to support node 10 for some of our
// test scenarios. Specifically those not scenario testing embroider. As
// @embroider/test-setup and @embroider in no longer supports node 10
if (e !== null && typeof e === 'object' && e.code === 'MODULE_NOT_FOUND') {
return app.toTree();
}
throw e;
}
};
17 changes: 17 additions & 0 deletions tests/dummy/vendor/ember-cli/test-support-suffix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line no-unused-vars
/* global runningTests: true */

/*
used to determine if the application should be booted immediately when `app-name.js` is evaluated
when `runningTests` the `app-name.js` file will **not** import the applications `app/app.js` and
call `Application.create(...)` on it. Additionally, applications can opt-out of this behavior by
setting `autoRun` to `false` in their `ember-cli-build.js`
*/
runningTests = true;

/*
This file overrides a file built into ember-cli's build pipeline and prevents
this built-in `Testem.hookIntoTestFramework` invocation:
https://github.com/ember-cli/ember-cli/blob/v3.20.0/lib/broccoli/test-support-suffix.js#L3-L5
*/
10 changes: 5 additions & 5 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
{{content-for "test-body"}}

<div id="qunit"></div>
<div id="qunit-fixture"></div>

<div id="ember-testing-container">
<div id="ember-testing"></div>
<div id="qunit-fixture">
<div id="ember-testing-container">
<div id="ember-testing"></div>
</div>
</div>

<script src="/testem.js" integrity=""></script>
<script src="/testem.js" integrity="" data-embroider-ignore></script>
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/test-support.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
Expand Down
7 changes: 7 additions & 0 deletions tests/test-helper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* globals Testem */

import QUnit from 'qunit';
import AbstractTestLoader from 'ember-cli-test-loader/test-support/index';
import { polyfill } from 'es6-promise';
Expand Down Expand Up @@ -34,3 +36,8 @@ QUnit.testDone(function () {
let testElementReset = testElementContainer.outerHTML;
testElementContainer.innerHTML = testElementReset;
});

QUnit.start();
if (typeof Testem !== 'undefined') {
Testem.hookIntoTestFramework();
}
Empty file removed vendor/.gitkeep
Empty file.
18 changes: 0 additions & 18 deletions vendor/shims/qunit.js

This file was deleted.

0 comments on commit e82f784

Please sign in to comment.