Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Use ember-qunit as an NPM dependency.
Browse files Browse the repository at this point in the history
This removes ember-qunit as a bower dependency (in favor of using NPM
directly).

Currently, this adds ember-qunit, ember-test-helpers, and klassy
(required by ember-test-helpers) to `vendor.js`. That is slightly
unfortunate, as ideally these would be added to `test-support.js`
instead, however there is no mechanism other than `app.import` in
ember-cli today (1.13.x timeframe) to handle this.

IMO, we should add a `addon-test-support` tree, that appends to
`test-support.js` by default. This would allow addons to provide test
helpers much simpler than we can today.
  • Loading branch information
rwjblue committed Dec 12, 2015
1 parent 763661e commit ddc5db4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 28 deletions.
3 changes: 1 addition & 2 deletions blueprints/ember-cli-qunit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ module.exports = {
return this.addBowerPackagesToProject([
{ name: 'qunit', target: '~1.20.0' },
{ name: 'ember-cli-test-loader', target: '0.2.1' },
{ name: 'ember-qunit-notifications', target: '0.1.0' },
{ name: 'ember-qunit', target: '0.4.17' }
{ name: 'ember-qunit-notifications', target: '0.1.0' }
]);
}
};
51 changes: 26 additions & 25 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

var path = require('path');
var fs = require('fs');
var resolve = require('resolve');
var jshintTrees = require('broccoli-jshint');
var BabelTranspiler = require('broccoli-babel-transpiler');
var MergeTrees = require('broccoli-merge-trees');
var Funnel = require('broccoli-funnel');


module.exports = {
name: 'Ember CLI QUnit',
Expand Down Expand Up @@ -34,6 +39,27 @@ module.exports = {
return path.join(__dirname, 'blueprints');
},

treeForAddon: function() {
var emberQUnitPath = path.dirname(resolve.sync('ember-qunit'));
var emberTestHelpersPath = path.dirname(resolve.sync('ember-test-helpers', { basedir: emberQUnitPath }));
var klassyPath = path.dirname(resolve.sync('klassy', { basedir: emberTestHelpersPath }));

var tree = new MergeTrees([
this.treeGenerator(emberQUnitPath),
this.treeGenerator(emberTestHelpersPath),
this.treeGenerator(klassyPath)
]);

var transpiled = new BabelTranspiler(tree, {
loose: true,
blacklist: ['es6.modules']
});

return new Funnel(transpiled, {
destDir: 'modules'
});
},

included: function included(app, parentAddon) {
var target = (parentAddon || app);
this._super.included(target);
Expand Down Expand Up @@ -72,31 +98,6 @@ module.exports = {
fileAssets.push('vendor/ember-cli-qunit/test-container-styles.css');
}

var emberQunitPath = app.bowerDirectory + '/ember-qunit/ember-qunit.amd.js';
if (!fs.existsSync(emberQunitPath)) {
emberQunitPath = app.bowerDirectory + '/ember-qunit/named-amd/main.js';
}

app.import(emberQunitPath, {
type: 'test',
exports: {
'qunit': [
'default',
'module',
'test'
],

'ember-qunit': [
'globalize',
'moduleFor',
'moduleForComponent',
'moduleForModel',
'test',
'setResolver'
]
}
});

fileAssets.forEach(function(file){
app.import(file, {
type: 'test'
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
},
"homepage": "https://github.com/ember-cli/ember-cli-qunit",
"dependencies": {
"broccoli-jshint": "^1.0.0"
"broccoli-babel-transpiler": "^5.5.0",
"broccoli-funnel": "^1.0.1",
"broccoli-jshint": "^1.0.0",
"broccoli-merge-trees": "^1.1.0",
"ember-qunit": "^0.4.18",
"resolve": "^1.1.6"
},
"bundledDependencies": []
}

0 comments on commit ddc5db4

Please sign in to comment.