Skip to content

Commit

Permalink
Merge pull request #652 from thoov/embroider-test-setup
Browse files Browse the repository at this point in the history
Use @embroider/test-setup and get embroider passing
  • Loading branch information
rwjblue authored Feb 17, 2021
2 parents 005bba7 + 512ad87 commit 7d99254
Show file tree
Hide file tree
Showing 22 changed files with 2,160 additions and 1,599 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,18 @@ jobs:
- ember-default-with-jquery
- ember-default-with-mocha
- ember-classic
- embroider
- embroider-with-mocha
- embroider-safe
- embroider-safe-with-mocha
- embroider-optimized
- embroider-optimized-with-mocha
- ember-lts-3.24
- ember-lts-3.20
- ember-lts-3.16
- ember-lts-3.12
- ember-release
- ember-beta
- ember-canary
- ember-qunit-4

steps:
- uses: actions/checkout@v2
Expand Down
92 changes: 47 additions & 45 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
'use strict';

const getChannelURL = require('ember-source-channel-url');
const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');
const mergeWith = require('lodash.mergewith');

function mochaScenario(scenario = {}) {
return mergeWith({}, scenario, {
devDependencies: {
'chai-dom': '*',
'ember-cli-chai': '*',
'ember-mocha': '*',
'ember-qunit': null
}
});
}

const command = [
'ember',
Expand Down Expand Up @@ -34,6 +47,22 @@ module.exports = async function() {
}
}
},
{
name: 'ember-lts-3.20',
npm: {
devDependencies: {
'ember-source': '~3.20.0'
}
}
},
{
name: 'ember-lts-3.24',
npm: {
devDependencies: {
'ember-source': '~3.24.0'
}
}
},
{
name: 'ember-release',
npm: {
Expand Down Expand Up @@ -71,14 +100,9 @@ module.exports = async function() {
}
}
},
{
name: 'ember-default-with-mocha',
npm: {
devDependencies: {
'ember-mocha': '*'
}
}
},
mochaScenario({
name: 'ember-default-with-mocha'
}),
{
name: 'ember-classic',
env: {
Expand All @@ -94,48 +118,26 @@ module.exports = async function() {
}
}
},
embroiderSafe(),
embroiderSafe(
mochaScenario({
name: 'embroider-safe-with-mocha'
})
),
embroiderOptimized(),
embroiderOptimized(
mochaScenario({
name: 'embroider-optimized-with-mocha'
})
),
{
name: 'embroider',
name: 'ember-qunit-4',
npm: {
devDependencies: {
'@embroider/core': '*',
'@embroider/webpack': '*',
'@embroider/compat': '*',
},
},
},
{
name: 'embroider-with-mocha',
npm: {
devDependencies: {
'@embroider/core': '*',
'@embroider/webpack': '*',
'@embroider/compat': '*',
'ember-mocha': '*',
},
},
},
{
name: 'embroider-optimized',
npm: {
devDependencies: {
'@embroider/core': '*',
'@embroider/webpack': '*',
'@embroider/compat': '*',
},
'ember-qunit': '^4.6.0'
}
}
},
{
name: 'embroider-optimized-with-mocha',
npm: {
devDependencies: {
'@embroider/core': '*',
'@embroider/webpack': '*',
'@embroider/compat': '*',
'ember-mocha': '*',
},
}
}
]
};
};
36 changes: 11 additions & 25 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,20 @@
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function(defaults) {
const self = defaults.project.findAddonByName('ember-exam');
const autoImport = self.options.autoImport;
let app = new EmberAddon(defaults, {
// Add options here
autoImport
});

/*
This build file specifies the options for the dummy test app of this
addon, located in `/tests/dummy`
This build file does *not* influence how the addon or the app using it
behave. You most likely want to be modifying `./index.js` or app's build file
*/

// Use embroider if it's present (it can get added by ember-try)
if ('@embroider/core' in app.dependencies()) {
/* eslint-disable node/no-missing-require, node/no-extraneous-require */
const { Webpack } = require('@embroider/webpack');
const { compatBuild } = require('@embroider/compat');
/* eslint-enable node/no-missing-require, node/no-extraneous-require */
let config = {};
if (process.env.EMBER_TRY_SCENARIO === 'embroider-optimized') {
config = {
staticAddonTrees: true,
staticAddonTestSupportTrees: true,
staticHelpers: true,
staticComponents: true,
const { maybeEmbroider } = require('@embroider/test-setup');
return maybeEmbroider(app, {
packagerOptions: {
webpackConfig: {
externals: {
mocha: 'mocha'
}
}
}
return compatBuild(app, Webpack, config);
} else {
return app.toTree();
}
});
};
31 changes: 31 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,41 @@

'use strict';

const VersionChecker = require('ember-cli-version-checker');

module.exports = {
name: require('./package').name,

includedCommands() {
return require('./lib/commands');
},

init() {
this._super.init.apply(this, arguments);
let versionChecker = new VersionChecker(this.project);

const hasMagicallyProvidedQUnit = versionChecker
.for('ember-qunit')
.lt('5.0.0-beta.1');

let options = {
exclude: ['ember-mocha', 'mocha']
};

// Ember-qunit < 5 provides an AMD shim for qunit but newer versions now use
// ember-auto-import to include qunit. This means that qunit is no
// longer available for addons (if the parent app is using ember-qunit > 5) to
// directly import under embroider unless they are using ember-auto-import
// themselves. This condidionally falls back to not using ember-auto-import
// when the parent app is providing qunit because without this we would double
// include qunit resulting in a runtime error (qunit detects if it as
// already be added to the window object and errors if so).
if (hasMagicallyProvidedQUnit) {
this.options = this.options || {};
options.exclude.push('qunit');
this.options.autoImport = options;
} else {
this.options.autoImport = options;
}
}
};
18 changes: 14 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@
]
},
"dependencies": {
"@embroider/macros": "^0.29.0",
"@embroider/macros": "^0.36.0",
"chalk": "^4.1.0",
"cli-table3": "^0.6.0",
"debug": "^4.2.0",
"ember-auto-import": "^1.10.1",
"ember-cli-babel": "^7.21.0",
"ember-cli-version-checker": "^5.1.2",
"execa": "^4.0.3",
"fs-extra": "^9.0.1",
"js-yaml": "^3.14.0",
Expand All @@ -53,6 +55,8 @@
},
"devDependencies": {
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "^2.2.0",
"@embroider/test-setup": "^0.36.0",
"babel-eslint": "^10.1.0",
"codeclimate-test-reporter": "^0.5.0",
"ember-cli": "^3.21.2",
Expand All @@ -70,7 +74,7 @@
"ember-disable-prototype-extensions": "^1.1.2",
"ember-export-application-global": "^2.0.1",
"ember-load-initializers": "^2.1.1",
"ember-qunit": "^4.6.0",
"ember-qunit": "^5.1.2",
"ember-resolver": "^8.0.2",
"ember-source": "~3.21.3",
"ember-source-channel-url": "^1.1.0",
Expand All @@ -82,10 +86,12 @@
"fixturify": "^1.2.0",
"istanbul": "^0.4.3",
"loader.js": "^4.7.0",
"lodash.mergewith": "^4.6.2",
"mocha": "^8.1.0",
"mocha-eslint": "^6.0.0",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"qunit": "^2.14.0",
"release-it": "^14.0.2",
"release-it-lerna-changelog": "^2.4.0",
"rsvp": "^4.8.5",
Expand All @@ -94,14 +100,18 @@
},
"peerDependencies": {
"ember-mocha": "*",
"ember-qunit": "*"
"ember-qunit": "*",
"qunit": "*"
},
"peerDependenciesMeta": {
"ember-mocha": {
"optional": true
},
"ember-qunit": {
"optional": true
},
"qunit": {
"optional": true
}
},
"engines": {
Expand Down Expand Up @@ -132,4 +142,4 @@
"node": "10.23.0",
"yarn": "1.22.10"
}
}
}
7 changes: 0 additions & 7 deletions tests/dummy/config/targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ const browsers = [
'last 1 Safari versions'
];

const isCI = !!process.env.CI;
const isProduction = process.env.EMBER_ENV === 'production';

if (isCI || isProduction) {
browsers.push('ie 11');
}

module.exports = {
browsers
};
Loading

0 comments on commit 7d99254

Please sign in to comment.