Skip to content

Commit ab24902

Browse files
committed
feat(command): ng test command runs karma
Overrode the ember-cli test command to initialize the karma server Then start the karma server based upon the karma.conf.js config file closes #70
1 parent 87bfa14 commit ab24902

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

addon/ng2/commands/test.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
3+
var chalk = require('chalk');
4+
var Command = require('ember-cli/lib/models/command');
5+
var Promise = require('ember-cli/lib/ext/promise');
6+
var Project = require('ember-cli/lib/models/project');
7+
var SilentError = require('silent-error');
8+
var validProjectName = require('ember-cli/lib/utilities/valid-project-name');
9+
var normalizeBlueprint = require('ember-cli/lib/utilities/normalize-blueprint-option');
10+
11+
var TestCommand = require('ember-cli/lib/commands/test');
12+
var childProcess = require('child_process')
13+
14+
module.exports = TestCommand.extend({
15+
16+
init: function(){
17+
var cwd = process.cwd();
18+
this.karma = this.karma || require(cwd + '/node_modules/karma/lib/index');
19+
this.karmaConfig = this.karmaConfig || cwd + '/karma.conf';
20+
this.server = this.server || new this.karma.Server({configFile: this.karmaConfig});
21+
},
22+
23+
run: function(commandOptions, rawArgs) {
24+
var promise = new Promise(function(){});
25+
26+
this.server.start();
27+
28+
return promise;
29+
}
30+
});
31+
32+
module.exports.overrideCore = true;

addon/ng2/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ module.exports = {
66
includedCommands: function() {
77
return {
88
'new': require('./commands/new'),
9-
'init': require('./commands/init')
9+
'init': require('./commands/init'),
10+
'test': require('./commands/test')
1011
};
1112
}
1213
};

tests/acceptance/test.spec.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use strict';
2+
3+
var fs = require('fs-extra');
4+
var ng = require('../helpers/ng');
5+
var existsSync = require('exists-sync');
6+
var expect = require('chai').expect;
7+
var forEach = require('lodash/collection/forEach');
8+
var walkSync = require('walk-sync');
9+
var Blueprint = require('ember-cli/lib/models/blueprint');
10+
var path = require('path');
11+
var tmp = require('../helpers/tmp');
12+
var root = process.cwd();
13+
var util = require('util');
14+
var conf = require('ember-cli/tests/helpers/conf');
15+
var EOL = require('os').EOL;
16+
17+
describe('Acceptance: ng test', function () {
18+
before(conf.setup);
19+
20+
after(conf.restore);
21+
22+
beforeEach(function () {
23+
return tmp.setup('./tmp')
24+
.then(function () {
25+
process.chdir('./tmp');
26+
})
27+
.then(function () {
28+
return ng([
29+
'init',
30+
'--skip-npm',
31+
'--skip-bower'
32+
]);
33+
});
34+
});
35+
36+
afterEach(function () {
37+
this.timeout(10000);
38+
39+
return tmp.teardown('./tmp');
40+
});
41+
42+
it('ng test should excecute a test', function () {
43+
console.log('starting test');
44+
return ng([
45+
'test',
46+
'--skip-npm',
47+
'--skip-bower'
48+
])
49+
.then(function () {
50+
console.log('test completed');
51+
});
52+
});
53+
});

0 commit comments

Comments
 (0)