-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjasmine.config.ts
65 lines (56 loc) · 1.48 KB
/
jasmine.config.ts
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
import Jasmine from "jasmine";
import JasmineConsoleReporter from "jasmine-console-reporter";
import path from "path";
import yargs from "yargs";
import { JSDOM } from "jsdom";
const args = yargs.options({
reporter: {type: "string"},
}).parse();
function reporter() {
if (args.reporter) {
const file = args.reporter;
const Reporter = require(file);
return new Reporter();
}
return new JasmineConsoleReporter({
colors: 2,
cleanStack: 1,
verbosity: 4,
listStyle: "indent",
activity: true,
emoji: false,
beep: false,
});
}
const jasmine = new Jasmine({});
jasmine.projectBaseDir = path.resolve(".");
jasmine.addReporter(reporter());
// INITIALIZE ENV
console.log("initializing environment...");
process.env.NODE_ENV = "test";
// INITIALIZE DOM
console.log("initializing DOM...");
const env = global as any;
const {window} = new JSDOM("<!doctype html><html><body></body></html>");
window.fetch = require("node-fetch");
require("raf/polyfill");
Object.defineProperties(env, {
...Object.getOwnPropertyDescriptors(window),
...Object.getOwnPropertyDescriptors(env),
});
Object.defineProperties(window, {
...Object.getOwnPropertyDescriptors(env),
...Object.getOwnPropertyDescriptors(window),
});
// FIND SPECS
console.log("resolving specs...");
jasmine.addSpecFiles([
"src/**/*.spec.ts?(x)",
]);
console.log(jasmine.specFiles);
// LOAD
console.log("loading specs...");
jasmine.loadSpecs();
// RUN
console.log("running tests...");
export = jasmine.execute();