forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.js
87 lines (70 loc) · 3.49 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
'use strict';
var Command = require('../models/command');
var SilentError = require('silent-error');
var path = require('path');
var existsSync = require('exists-sync');
var defaultPort = 7357;
module.exports = Command.extend({
name: 'test',
description: 'Runs your app\'s test suite.',
aliases: ['t'],
availableOptions: [
{ name: 'environment', type: String, default: 'test', aliases: ['e'] },
{ name: 'config-file', type: String, aliases: ['c', 'cf']},
{ name: 'server', type: Boolean, default: false, aliases: ['s'] },
{ name: 'host', type: String, aliases: ['H'] },
{ name: 'test-port', type: Number, default: defaultPort, aliases: ['tp'], description: 'The test port to use when running with --server.' },
{ name: 'filter', type: String, aliases: ['f'], description: 'A string to filter tests to run' },
{ name: 'module', type: String, aliases: ['m'], description: 'The name of a test module to run' },
// { name: 'watcher', type: String, default: 'events', aliases: ['w'] },
{ name: 'launch', type: String, default: false, description: 'A comma separated list of browsers to launch for tests.' },
{ name: 'reporter', type: String, aliases: ['r'], description: 'Test reporter to use [tap|dot|xunit] (default: tap)' },
{ name: 'silent', type: Boolean, default: false, description: 'Suppress any output except for the test report' },
{ name: 'test-page', type: String, description: 'Test page to invoke' },
{ name: 'path', type: 'Path', description: 'Reuse an existing build at given path.' },
{ name: 'query', type: String, description: 'A query string to append to the test page URL.' }
],
init: function() {
this.assign = require('lodash/assign');
if (!this.testing) {
process.env.EMBER_CLI_TEST_COMMAND = true;
}
},
_generateCustomConfigs: function(options) {
var config = {};
if (!options.filter && !options.module && !options.launch && !options.query && !options['test-page']) { return config; }
var testPage = options['test-page'];
var queryString = this.buildTestPageQueryString(options);
if (testPage) {
var containsQueryString = testPage.indexOf('?') > -1;
var testPageJoinChar = containsQueryString ? '&' : '?';
config.testPage = testPage + testPageJoinChar + queryString;
}
if (queryString) {
config.queryString = queryString;
}
if (options.launch) {
config.launch = options.launch;
}
return config;
},
_generateTestPortNumber: function(options) {
if (options.port && options.testPort !== defaultPort || !isNaN(parseInt(options.testPort)) && !options.port) { return options.testPort; }
if (options.port) { return parseInt(options.port, 10) + 1; }
},
buildTestPageQueryString: function(options) {
var params = [];
if (options.module) {
params.push('module=' + options.module);
}
if (options.filter) {
params.push('filter=' + options.filter.toLowerCase());
}
if (options.query) {
params.push(options.query);
}
return params.join('&');
},
run: function(commandOptions) {
}
});