forked from codeceptjs/CodeceptJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.js
More file actions
48 lines (41 loc) · 1.38 KB
/
run.js
File metadata and controls
48 lines (41 loc) · 1.38 KB
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
const getConfig = require('./utils').getConfig;
const getTestRoot = require('./utils').getTestRoot;
const fileExists = require('../utils').fileExists;
const path = require('path');
const mkdirp = require('mkdirp');
const Config = require('../config');
const Codecept = require('../codecept');
const output = require('../output');
module.exports = function (test, options) {
// registering options globally to use in config
process.profile = options.profile;
const configFile = options.config;
let codecept;
let outputDir;
const testRoot = getTestRoot(configFile);
let config = getConfig(configFile);
if (options.override) {
config = Config.append(JSON.parse(options.override));
}
if (path.isAbsolute(config.output)) outputDir = config.output;
else outputDir = path.join(testRoot, config.output);
if (!fileExists(outputDir)) {
output.print(`creating output directory: ${outputDir}`);
mkdirp.sync(outputDir);
}
try {
codecept = new Codecept(config, options);
codecept.init(testRoot);
codecept.runBootstrap((err) => {
if (err) throw new Error(`Error while running bootstrap file :${err}`);
codecept.loadTests();
codecept.run(test);
});
} catch (err) {
output.print('');
output.error(err.message);
output.print('');
output.print(output.colors.grey(err.stack.replace(err.message, '')));
process.exit(1);
}
};