-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrollup-non-testem-tests.js
144 lines (135 loc) · 5.34 KB
/
rollup-non-testem-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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* eslint-env node */
"use strict";
var fluid = require("infusion");
var jqUnit = require("node-jqunit");
require("../../");
//require("../../src/js/coverageServer");
require("kettle");
require("fluid-webdriver");
fluid.webdriver.loadTestingSupport();
fluid.registerNamespace("fluid.tests.testem.rollup.webdriver");
// Simple function to retrieve data our "test result collector" set aside on the client side.
fluid.tests.testem.rollup.webdriver.retrieveTestResults = function () {
return window.__testDetails;
};
fluid.tests.testem.rollup.webdriver.checkTestResults = function (results) {
jqUnit.assertEquals("There should have been four tests run.", 4, results.total);
jqUnit.assertEquals("All tests should have passed.", 4, results.passed);
jqUnit.assertEquals("No tests should have failed.", 0, results.failed);
};
fluid.defaults("fluid.tests.testem.rollup.webdriver.caseHolder", {
gradeNames: ["fluid.test.webdriver.caseHolder"],
rawModules: [{
name: "Testing 'safe rollup' outside of Testem...",
tests: [
{
name: "Open and inspect a 'safe rollup'...",
type: "test",
sequence: [
{
func: "{testEnvironment}.webdriver.get",
args: ["{testEnvironment}.options.rollupUrl"]
},
// Give the tests half a second to run.
{
event: "{testEnvironment}.webdriver.events.onGetComplete",
listener: "{testEnvironment}.webdriver.sleep",
args: [1000]
},
{
event: "{testEnvironment}.webdriver.events.onSleepComplete",
listener: "{testEnvironment}.webdriver.executeScript",
args: [fluid.tests.testem.rollup.webdriver.retrieveTestResults]
},
{
event: "{testEnvironment}.webdriver.events.onExecuteScriptComplete",
listener: "fluid.tests.testem.rollup.webdriver.checkTestResults",
args: ["{arguments}.0"]
}
]
}
]
}]
});
fluid.tests.testem.rollup.webdriver.instrumentSource = function (that) {
fluid.testem.instrumenter.instrument("%fluid-testem/src", "%fluid-testem/instrumented").then(function () {
that.events.onSourceInstrumented.fire();
}, fluid.fail);
};
fluid.defaults("fluid.tests.testem.rollup.webdriver.environment", {
gradeNames: ["fluid.test.webdriver.testEnvironment.withExpress"],
rollupUrl: {
expander: {
funcName: "fluid.stringTemplate",
args: ["http://localhost:%port/tests/rollup-fixtures/rollup.html", { port: "{that}.options.port"}]
}
},
listeners: {
"onCreate.instrumentSource": {
funcName: "fluid.tests.testem.rollup.webdriver.instrumentSource",
args: ["{that}"]
}
},
events: {
onSourceInstrumented: null,
onFixturesConstructed: {
events: {
onDriverReady: "onDriverReady",
onExpressReady: "onExpressReady",
onSourceInstrumented: "onSourceInstrumented"
}
}
},
components: {
caseHolder: {
type: "fluid.tests.testem.rollup.webdriver.caseHolder"
},
express: {
options: {
components: {
coverage: {
type: "fluid.testem.coverage.router",
options: {
coveragePort: "{testEnvironment}.options.port",
components: {
client: {
options: {
hookTestem: false,
hookQUnit: true
}
},
coverageReceiver: {
options: {
coverageDir: "%fluid-testem/coverage"
}
}
}
}
},
nm: {
type: "fluid.express.router.static",
options: {
path: "/node_modules",
content: ["%fluid-testem/node_modules"]
}
},
tests: {
type: "fluid.express.router.static",
options: {
path: "/tests",
content: ["%fluid-testem/tests"]
}
},
src: {
type: "fluid.express.router.static",
options: {
path: "/src",
content: ["%fluid-testem/instrumented"]
}
}
}
}
}
}
});
fluid.test.webdriver.allBrowsers({ baseTestEnvironment: "fluid.tests.testem.rollup.webdriver.environment" });