-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathtests.js
49 lines (40 loc) · 1.77 KB
/
tests.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
/* eslint-env node */
"use strict";
var fluid = require("infusion");
var fs = require("graceful-fs");
var jqUnit = require("node-jqunit");
var gpii = fluid.registerNamespace("gpii");
/*
* Load all the code that is to be tested. Using relative path
* as this can either be the instrumented "app" or not.
*/
require("./src/main/app");
fluid.registerNamespace("gpii.tests.app");
// In case the "instrumented" source is loaded the `__coverage` variable will be present.
gpii.tests.app.isInstrumented = fluid.isValue(global.__coverage__);
// Code coverage harness, hooks into the jqUnit lifecycle and saves tests whenever the `onAllTestsDone` event is fired.
// Must be hooked in before requiring any actual tests.
jqUnit.onAllTestsDone.addListener(function () {
if (gpii.tests.app.isInstrumented) {
var filename = fluid.stringTemplate("coverage-tests-%timestamp.json", { timestamp: (new Date()).toISOString().replace(/:/g, "-") });
var coverageFilePath = fluid.module.resolvePath("%gpii-app/coverage/" + filename);
try {
var coverageData = JSON.stringify(global.__coverage__, null, 2);
fs.writeFileSync(coverageFilePath, coverageData);
fluid.log("Saved ", coverageData.length, " bytes of coverage data to '", coverageFilePath, "'.");
}
catch (error) {
fluid.log("Error saving coverage data:", error);
}
}
else {
fluid.log("No code coverage data to save.");
}
});
// Run the electron app tests with code coverage if possible.
require("./tests/AppTests.js");
require("./tests/MessageBundlesTests.js");
require("./tests/MessageBundlesCompilerTests.js");
require("./tests/PreferencesGroupingTests.js");
require("./tests/PreferencesParsingTests.js");
require("./tests/IntegrationTests.js");