Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
- document npm command problems
- don't run npm command twice in same process for installing ember-disable-prototype-extensions
  • Loading branch information
hjdivad committed Jul 26, 2015
1 parent c2cf3a7 commit a1a5f6f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 14 deletions.
3 changes: 1 addition & 2 deletions lib/tasks/npm-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ module.exports = Task.extend({
// by default, do install peoples optional deps
'optional': 'optional' in options ? options.optional : true,
'save-dev': !!options['save-dev'],
'save-exact': !!options['save-exact'],
'optional': 'optional' in options ? options.optional : true
'save-exact': !!options['save-exact']
};

var packages = options.packages || [];
Expand Down
19 changes: 17 additions & 2 deletions lib/utilities/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@

var Promise = require('../ext/promise');

module.exports = function npm(command, packages, options/*, npm*/) {
//

/**
Runs the npm command `command` with the supplied args and load options.
Please note that the loaded module appears to retain some state, so do not
expect multiple invocations within the same process to work without quirks.
This problem is likely fixable.
@method npm
@param {String} command The npm command to run.
@param {Array} npmArgs The arguments passed to the npm command.
@param {Array} options The options passed when loading npm.
@param {Module} [npm] A reference to the npm module.
*/
module.exports = function npm(command, npmArgs, options/*, npm*/) {
var lib;
if (arguments.length === 4) {
lib = arguments[3];
Expand All @@ -18,6 +33,6 @@ module.exports = function npm(command, packages, options/*, npm*/) {
// it throws "Call npm.load(config, cb) before using this command."
var operation = Promise.denodeify(lib.commands[command]);

return operation(packages || []);
return operation(npmArgs || []);
});
};
1 change: 0 additions & 1 deletion tests/acceptance/install-test-slow.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ describe('Acceptance: ember install', function() {

it('installs addons via npm and runs generators', function() {
return installAddon(['ember-cli-fastclick', 'ember-cli-photoswipe']).then(function(result) {

assertFile('package.json', {
contains: [
/"ember-cli-fastclick": ".*"/,
Expand Down
4 changes: 1 addition & 3 deletions tests/helpers/acceptance.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var conf = require('./conf');
var existsSync = require('exists-sync');
var copy = Promise.denodeify(require('cpr'));
var root = process.cwd();
var npm = require('../../lib/utilities/npm');

var onOutput = {
onOutput: function() {
Expand Down Expand Up @@ -114,8 +113,7 @@ function createTestTargets(projectName, options) {
catch(handleResult).
then(function(value) {
if (noNodeModules) {
return npm('install', ['ember-disable-prototype-extensions'], { '--no-optional': true }).
then(function(){
return runCommand('npm', 'install', 'ember-disable-prototype-extensions').then(function () {
return value;
});
}
Expand Down
4 changes: 2 additions & 2 deletions tests/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ testFiles = jshint.concat(testFiles);
if (optionOrFile === 'all') {
addFiles(mocha, testFiles);
addFiles(mocha, '/**/*-slow.js');
} else if (optionOrFile) {
mocha.addFile(optionOrFile);
} else if (process.argv.length > 2) {
addFiles(mocha, process.argv.slice(2));
} else {
addFiles(mocha, testFiles);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/models/command-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ describe('models/command.js', function() {
analytics: analytics,
project: { isEmberCLIProject: function(){ return false; }},
settings: {}
}).validateAndRun([]).catch(function() {
expect(ui.output).to.match(/You have to be inside an ember-cli project/);
}).validateAndRun([]).catch(function(reason) {
expect(reason.message).to.match(/You have to be inside an ember-cli project/);
});
});

Expand All @@ -202,8 +202,8 @@ describe('models/command.js', function() {
analytics: analytics,
project: { isEmberCLIProject: function(){ return true; }},
settings: {}
}).validateAndRun([]).catch(function() {
expect(ui.output).to.match(/You cannot use.*inside an ember-cli project/);
}).validateAndRun([]).catch(function(reason) {
expect(reason.message).to.match(/You cannot use.*inside an ember-cli project/);
});
});

Expand Down

0 comments on commit a1a5f6f

Please sign in to comment.