-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
39 lines (31 loc) · 957 Bytes
/
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
/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */
// this is run via "npm test".
import Jasmine from 'jasmine';
import { argv } from 'yargs';
import jsdom from 'jsdom';
import app from 'app-module-path';
app.addPath(`${__dirname}/src/`);
const window = jsdom.jsdom('<html><head></head><body></body></html>').defaultView;
global.window = window;
global.document = window.document;
global.navigator = window.navigator;
const DEFAULT_FILES = [
'src/espina/server/**/*.test.js',
'src/espina/shared/**/*.test.js',
'src/espina/client/**/*.test.js',
];
function interpretFiles(ifiles) {
return ifiles.split(',').map((dir) => {
if (/\.test\.js$/.test(dir)) {
return dir;
}
return `${dir}/**/*.test.js`;
});
}
const jasmine = new Jasmine();
const files = argv.files ? interpretFiles(argv.files) : DEFAULT_FILES;
jasmine.loadConfig({
spec_dir: './',
spec_files: files,
});
jasmine.execute();