-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.cjs
More file actions
90 lines (76 loc) · 2.6 KB
/
test.cjs
File metadata and controls
90 lines (76 loc) · 2.6 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
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
88
89
90
// Compile PsychoJS library, deploy test experiments, and run tests
// Modules
const child_process = require('child_process');
const CLIParser = require('./scripts/shared/CLIParser.cjs');
const TestCollector = require('./scripts/shared/TestCollector.cjs');
// Get psychoJSPath
const psychoJSPath = CLIParser.parseOption({env: 'PSYCHOJS_PATH'});
console.log('[test.cjs] psychoJSPath is ' + psychoJSPath);
// String of options passed to this script; we pass these on to child processes
let cliString = CLIParser.constructCLIString(2);
// See if actual testing is disabled
let skiptests = CLIParser.parseOption({cli: 'skiptests'}, false);
skiptests = skiptests !== undefined;
// execSync options
let execSyncOptions = {
stdio: ['inherit', 'inherit', 'inherit']
};
console.log('[test.cjs] Building library');
// Build library: CSS
if (CLIParser.parseOption({cli: 'nocss'}, false) === undefined) {
child_process.execSync(
'npm --prefix ' + psychoJSPath + ' run build:css',
execSyncOptions
);
}
// Build library: JS
if (CLIParser.parseOption({cli: 'nojs'}, false) === undefined) {
child_process.execSync(
'npm --prefix ' + psychoJSPath + ' run build:js',
execSyncOptions
);
}
// Collect tests
let tests = TestCollector.collectTests(CLIParser.parseOption({cli: 'label'}));
// Any karma tests? Run them
if (!skiptests && tests.karma.length > 0) {
console.log('[test.cjs] Starting karma tests');
child_process.execSync(
'node scripts/cli/runkarma.cjs ' + cliString,
execSyncOptions
);
}
// Any wdio tests? Deploy experiments and run them
if (tests.wdio.length > 0) {
console.log('[test.cjs] Starting wdio tests');
// Check if uploadExperiments is enabled when target == stager
if (parseOption({cli: 'url'}) == 'stager' && !CLIParser.parseOption({cli: 'uploadExperiments'})) {
throw new Error('[test.cjs] The url CLI option was "stager" but uploadExperiments was disabled. Please enable uploadExperiments')
}
// Compile experiments
if (CLIParser.parseOption({cli: 'compile'}, false) !== undefined) {
child_process.execSync(
'node scripts/cli/compileExperiments.cjs ' + cliString,
execSyncOptions
);
}
// Deploy experiments
child_process.execSync(
'node scripts/cli/deployExperiments.cjs ' + cliString,
execSyncOptions
);
// Run e2e tests
if (!skiptests) {
child_process.execSync(
'npx wdio scripts/shared/wdio.conf.cjs ' + cliString,
execSyncOptions
);
}
}
console.log('[test.cjs] Done!');
// Beep
const beep = CLIParser.parseOption({cli: 'beep'}, false) !== undefined;
if (beep) {
const beepbeep = require('beepbeep');
beepbeep(2);
}