sxy-test-runner 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +2 -6
- package/dist/cli/init.js +19 -14
- package/dist/cli/lib/addBasePath.js +0 -1
- package/dist/cli/lib/addBasePath.unitTest.js +3 -1
- package/dist/cli/lib/addExports.unitTest.js +4 -1
- package/dist/cli/lib/applyConfigDefaults.js +12 -7
- package/dist/cli/lib/applyConfigDefaults.unitTest.js +9 -3
- package/dist/cli/lib/buildDependencyTree.js +10 -5
- package/dist/cli/lib/buildDependencyTree.unitTest.js +3 -1
- package/dist/cli/lib/buildDependencyTrees.js +6 -4
- package/dist/cli/lib/buildDependencyTrees.unitTest.js +3 -1
- package/dist/cli/lib/defaultConfig.test.js +3 -1
- package/dist/cli/lib/doUserSetup.js +0 -3
- package/dist/cli/lib/doUserSetup.unitTest.js +3 -1
- package/dist/cli/lib/doUserTeardown.js +0 -3
- package/dist/cli/lib/doUserTeardown.unitTest.js +3 -1
- package/dist/cli/lib/findTestFiles.unitTest.js +3 -1
- package/dist/cli/lib/getAllowedFlags.js +0 -2
- package/dist/cli/lib/getAllowedFlags.unitTest.js +3 -1
- package/dist/cli/lib/injectProperties.js +2 -2
- package/dist/cli/lib/injectProperties.unitTest.js +9 -2
- package/dist/cli/lib/loadConfig.js +2 -2
- package/dist/cli/lib/loadConfig.unitTest.js +3 -2
- package/dist/cli/lib/loadTestFile.js +17 -15
- package/dist/cli/lib/loadTestFile.unitTest.js +8 -3
- package/dist/cli/lib/loadTestFileStatic.js +1 -0
- package/dist/cli/lib/loadTestFileStatic.unitTest.js +1 -0
- package/dist/cli/lib/parseCommandLineArguments.js +1 -9
- package/dist/cli/lib/parseCommandLineArguments.unitTest.js +6 -2
- package/dist/cli/lib/parseDescribe.js +12 -18
- package/dist/cli/lib/parseDescribe.unitTest.js +6 -2
- package/dist/cli/lib/processWatchEvent.unitTest.js +9 -1
- package/dist/cli/lib/reservedExportKeys.unitTest.js +3 -1
- package/dist/cli/lib/runDescribe.js +4 -7
- package/dist/cli/lib/runDescribe.old.js +19 -25
- package/dist/cli/lib/runDescribe.unitTest.js +120 -2
- package/dist/cli/lib/runDescribeRun.js +3 -7
- package/dist/cli/lib/runDescribeRun.unitTest.js +125 -4
- package/dist/cli/lib/runIt.js +16 -18
- package/dist/cli/lib/runIt.unitTest.js +124 -4
- package/dist/cli/lib/runTasks.js +2 -7
- package/dist/cli/lib/runTasks.unitTest.js +3 -1
- package/dist/cli/lib/runTest-old.js +1 -0
- package/dist/cli/lib/runTest-old.unitTest.js +1 -0
- package/dist/cli/lib/runTest.js +15 -12
- package/dist/cli/lib/runTest.unitTest.js +38 -11
- package/dist/cli/lib/runTests.js +36 -35
- package/dist/cli/lib/runTests.unitTest.js +15 -8
- package/dist/cli/lib/showTestLoadingError.js +6 -6
- package/dist/cli/lib/showTestLoadingError.unitTest.js +5 -3
- package/dist/cli/lib/showTestResult.js +10 -16
- package/dist/cli/lib/showTestResult.unitTest.js +26 -17
- package/dist/cli/lib/validateConfig.js +0 -5
- package/dist/cli/lib/validateConfig.unitTest.js +2 -3
- package/dist/cli/lib/watchFiles.unitTest.js +5 -3
- package/dist/cli/lib/watchFilesAndRunTests.js +3 -1
- package/dist/cli/lib/watchFilesAndRunTests.unitTest.js +18 -15
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.js +22 -29
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js +19 -17
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js +28 -31
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js +21 -16
- package/dist/cli/lib/watchFilesChokidar.js +15 -11
- package/dist/cli/lib/watchFilesChokidar.unitTest.js +11 -8
- package/dist/cli/lib/watchFilesNodeWatch.js +9 -6
- package/dist/cli/lib/watchFilesNodeWatch.unitTest.js +6 -3
- package/dist/cli/once.js +0 -6
- package/dist/cli/watch.js +18 -14
- package/dist/cli/watch.unitTest.js +16 -16
- package/dist/describe-old.js +35 -20
- package/dist/describe-old.unitTest.js +10 -1
- package/dist/describe.js +8 -3
- package/dist/describe.unitTest.js +5 -2
- package/dist/indexNumberToLetters.js +1 -3
- package/dist/output.js +7 -0
- package/dist/testsState.js +2 -1
- package/package.json +14 -7
- package/readme.md +1 -1
- package/sxy-loader.config.js +10 -10
|
@@ -3,7 +3,9 @@ import { applyConfigDefaults } from './applyConfigDefaults.js';
|
|
|
3
3
|
import { loadTestFile } from './loadTestFile.js';
|
|
4
4
|
import { parseDescribe } from './parseDescribe.js';
|
|
5
5
|
import { runIt } from './runIt.js';
|
|
6
|
-
const defaultConfig = await applyConfigDefaults({});
|
|
6
|
+
const defaultConfig = await applyConfigDefaults({});
|
|
7
|
+
|
|
8
|
+
// const beforeAfterTestFile = 'unitTesting/runTest/beforeAfter.test.js'
|
|
7
9
|
// const beforeAfterTest = loadTestFile(defaultConfig, beforeAfterTestFile)
|
|
8
10
|
|
|
9
11
|
await mochaDescribe('runIt() function', async function () {
|
|
@@ -11,60 +13,84 @@ await mochaDescribe('runIt() function', async function () {
|
|
|
11
13
|
const sampleTestFile = 'unitTesting/runTest/1.test.js';
|
|
12
14
|
const sampleTest = await loadTestFile(defaultConfig, sampleTestFile);
|
|
13
15
|
const sampleDescribe = sampleTest.describes[0];
|
|
14
|
-
const parsedDescribe = await parseDescribe(defaultConfig, sampleDescribe);
|
|
16
|
+
const parsedDescribe = await parseDescribe(defaultConfig, sampleDescribe);
|
|
17
|
+
//console.log('sample describe', sampleDescribe)
|
|
15
18
|
|
|
16
19
|
await parsedDescribe.its.length.should.equal(1);
|
|
17
20
|
const sampleIt = parsedDescribe.its[0];
|
|
18
|
-
const itResult = await runIt(defaultConfig, sampleIt);
|
|
21
|
+
const itResult = await runIt(defaultConfig, sampleIt);
|
|
19
22
|
|
|
23
|
+
// should causes errors because our obj contains a field called 'should'
|
|
20
24
|
await (await chaiExpect(itResult)).to.include.keys(['counter', 'should', 'success', 'time', 'error']);
|
|
21
25
|
await itResult['should'].should.equal('1 should equal 1');
|
|
22
26
|
await itResult.success.should.equal(true);
|
|
23
27
|
await chaiShould.not.exist(itResult.error);
|
|
24
|
-
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// mochaIt('should return sensible results from a test file without any describes', function() {
|
|
31
|
+
|
|
25
32
|
// //const config = applyConfigDefaults({})
|
|
33
|
+
|
|
26
34
|
// const sampleTestFile = 'unitTesting/sampletests/blank.test.js'
|
|
27
35
|
// const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
|
|
36
|
+
|
|
28
37
|
// const testResult = runTest(defaultConfig, sampleTest)
|
|
38
|
+
|
|
29
39
|
// //console.log(testResult)
|
|
30
40
|
// //console.log(testResult.describeResults[0].itResults)
|
|
31
41
|
// //console.log(testResult.describeResults[0].itResultsSummary)
|
|
42
|
+
|
|
32
43
|
// testResult.should.include.keys([
|
|
33
44
|
// 'file',
|
|
34
45
|
// 'success',
|
|
35
46
|
// 'describeResults',
|
|
36
47
|
// 'describeResultsSummary'
|
|
37
48
|
// ])
|
|
49
|
+
|
|
38
50
|
// chaiExpect(testResult.success).to.be.null
|
|
51
|
+
|
|
39
52
|
// //testResult.describeResultsSummary.total.should.equal(1)
|
|
40
53
|
// //testResult.describeResultsSummary.passes.should.equal(1)
|
|
41
54
|
// //testResult.describeResultsSummary.itsTotal.should.equal(1)
|
|
42
55
|
// //testResult.describeResultsSummary.itsPasses.should.equal(1)
|
|
56
|
+
|
|
43
57
|
// })
|
|
58
|
+
|
|
44
59
|
// mochaIt('should return sensible results from a test file with describes without any its/tests', function() {
|
|
60
|
+
|
|
45
61
|
// //const config = applyConfigDefaults({})
|
|
62
|
+
|
|
46
63
|
// const sampleTestFile = 'unitTesting/sampletests/describesWithoutTests.test.js'
|
|
47
64
|
// const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
|
|
65
|
+
|
|
48
66
|
// const testResult = runTest(defaultConfig, sampleTest)
|
|
67
|
+
|
|
49
68
|
// //console.log(testResult)
|
|
50
69
|
// //console.log(testResult.describeResults[0].itResults)
|
|
51
70
|
// //console.log(testResult.describeResults[0].itResultsSummary)
|
|
71
|
+
|
|
52
72
|
// testResult.should.include.keys([
|
|
53
73
|
// 'file',
|
|
54
74
|
// 'success',
|
|
55
75
|
// 'describeResults',
|
|
56
76
|
// 'describeResultsSummary'
|
|
57
77
|
// ])
|
|
78
|
+
|
|
58
79
|
// chaiExpect(testResult.success).to.be.null
|
|
80
|
+
|
|
59
81
|
// testResult.describeResultsSummary.total.should.equal(0)
|
|
60
82
|
// testResult.describeResultsSummary.passes.should.equal(0)
|
|
61
83
|
// testResult.describeResultsSummary.invalid.should.equal(2)
|
|
62
84
|
// testResult.describeResultsSummary.itsTotal.should.equal(0)
|
|
63
85
|
// testResult.describeResultsSummary.itsPasses.should.equal(0)
|
|
86
|
+
|
|
64
87
|
// })
|
|
88
|
+
|
|
65
89
|
// mochaIt("should run beforeEachFile tasks (before - can't test)", function() {
|
|
90
|
+
|
|
66
91
|
// let functionHasRun = false
|
|
67
92
|
// global.beforeEachFileFileHasRun = false
|
|
93
|
+
|
|
68
94
|
// const ourConfig = {
|
|
69
95
|
// beforeEachFile: [
|
|
70
96
|
// function() {
|
|
@@ -73,14 +99,21 @@ await mochaDescribe('runIt() function', async function () {
|
|
|
73
99
|
// 'unitTesting/runTest/beforeEachFile.js'
|
|
74
100
|
// ]
|
|
75
101
|
// }
|
|
102
|
+
|
|
76
103
|
// const config = applyConfigDefaults(ourConfig)
|
|
104
|
+
|
|
77
105
|
// runTest(config, beforeAfterTest)
|
|
106
|
+
|
|
78
107
|
// functionHasRun.should.equal(true)
|
|
79
108
|
// global.beforeEachFileFileHasRun.should.equal(true)
|
|
109
|
+
|
|
80
110
|
// })
|
|
111
|
+
|
|
81
112
|
// mochaIt("should run afterEachFile tasks (after - can't test)", function() {
|
|
113
|
+
|
|
82
114
|
// let functionHasRun = false
|
|
83
115
|
// global.afterEachFileFileHasRun = false
|
|
116
|
+
|
|
84
117
|
// const ourConfig = {
|
|
85
118
|
// afterEachFile: [
|
|
86
119
|
// function() {
|
|
@@ -89,14 +122,21 @@ await mochaDescribe('runIt() function', async function () {
|
|
|
89
122
|
// 'unitTesting/runTest/afterEachFile.js'
|
|
90
123
|
// ]
|
|
91
124
|
// }
|
|
125
|
+
|
|
92
126
|
// const config = applyConfigDefaults(ourConfig)
|
|
127
|
+
|
|
93
128
|
// runTest(config, beforeAfterTest)
|
|
129
|
+
|
|
94
130
|
// functionHasRun.should.equal(true)
|
|
95
131
|
// global.afterEachFileFileHasRun.should.equal(true)
|
|
132
|
+
|
|
96
133
|
// })
|
|
134
|
+
|
|
97
135
|
// mochaIt("should run beforeEachDescribe tasks (before - can't test) each describe block", function() {
|
|
136
|
+
|
|
98
137
|
// let functionHasRunTimes = 0
|
|
99
138
|
// global.beforeEachDescribeFileHasRun = false
|
|
139
|
+
|
|
100
140
|
// const ourConfig = {
|
|
101
141
|
// beforeEachDescribe: [
|
|
102
142
|
// function() {
|
|
@@ -105,14 +145,21 @@ await mochaDescribe('runIt() function', async function () {
|
|
|
105
145
|
// 'unitTesting/runTest/beforeEachDescribe.js'
|
|
106
146
|
// ]
|
|
107
147
|
// }
|
|
148
|
+
|
|
108
149
|
// const config = applyConfigDefaults(ourConfig)
|
|
150
|
+
|
|
109
151
|
// runTest(config, beforeAfterTest)
|
|
152
|
+
|
|
110
153
|
// functionHasRunTimes.should.equal(2)
|
|
111
154
|
// global.beforeEachDescribeFileHasRun.should.equal(true)
|
|
155
|
+
|
|
112
156
|
// })
|
|
157
|
+
|
|
113
158
|
// mochaIt("should run afterEachDescribe tasks (after - can't test) each describe block", function() {
|
|
159
|
+
|
|
114
160
|
// let functionHasRunTimes = 0
|
|
115
161
|
// global.afterEachDescribeFileHasRun = false
|
|
162
|
+
|
|
116
163
|
// const ourConfig = {
|
|
117
164
|
// afterEachDescribe: [
|
|
118
165
|
// function() {
|
|
@@ -121,14 +168,21 @@ await mochaDescribe('runIt() function', async function () {
|
|
|
121
168
|
// 'unitTesting/runTest/afterEachDescribe.js'
|
|
122
169
|
// ]
|
|
123
170
|
// }
|
|
171
|
+
|
|
124
172
|
// const config = applyConfigDefaults(ourConfig)
|
|
173
|
+
|
|
125
174
|
// runTest(config, beforeAfterTest)
|
|
175
|
+
|
|
126
176
|
// functionHasRunTimes.should.equal(2)
|
|
127
177
|
// global.afterEachDescribeFileHasRun.should.equal(true)
|
|
178
|
+
|
|
128
179
|
// })
|
|
180
|
+
|
|
129
181
|
// mochaIt("should run beforeEachTest tasks (before - can't test) each test/it block", function() {
|
|
182
|
+
|
|
130
183
|
// let functionHasRunTimes = 0
|
|
131
184
|
// global.beforeEachTestbeforeEachFileFileHasRun = false
|
|
185
|
+
|
|
132
186
|
// const ourConfig = {
|
|
133
187
|
// beforeEachTest: [
|
|
134
188
|
// function() {
|
|
@@ -137,14 +191,21 @@ await mochaDescribe('runIt() function', async function () {
|
|
|
137
191
|
// 'unitTesting/runTest/beforeEachTest.js'
|
|
138
192
|
// ]
|
|
139
193
|
// }
|
|
194
|
+
|
|
140
195
|
// const config = applyConfigDefaults(ourConfig)
|
|
196
|
+
|
|
141
197
|
// runTest(config, beforeAfterTest)
|
|
198
|
+
|
|
142
199
|
// functionHasRunTimes.should.equal(3)
|
|
143
200
|
// global.beforeEachTestFileHasRun.should.equal(true)
|
|
201
|
+
|
|
144
202
|
// })
|
|
203
|
+
|
|
145
204
|
// mochaIt("should run afterEachTest tasks (after - can't test) each test/it block", function() {
|
|
205
|
+
|
|
146
206
|
// let functionHasRunTimes = 0
|
|
147
207
|
// global.afterEachTestFileFileHasRun = false
|
|
208
|
+
|
|
148
209
|
// const ourConfig = {
|
|
149
210
|
// afterEachTest: [
|
|
150
211
|
// function() {
|
|
@@ -153,17 +214,26 @@ await mochaDescribe('runIt() function', async function () {
|
|
|
153
214
|
// 'unitTesting/runTest/afterEachTest.js'
|
|
154
215
|
// ]
|
|
155
216
|
// }
|
|
217
|
+
|
|
156
218
|
// const config = applyConfigDefaults(ourConfig)
|
|
219
|
+
|
|
157
220
|
// runTest(config, beforeAfterTest)
|
|
221
|
+
|
|
158
222
|
// functionHasRunTimes.should.equal(3)
|
|
159
223
|
// global.afterEachTestFileHasRun.should.equal(true)
|
|
224
|
+
|
|
160
225
|
// })
|
|
226
|
+
|
|
161
227
|
// // exports provision to test file
|
|
228
|
+
|
|
162
229
|
// // current beforeEachFile exports aren't provided
|
|
163
230
|
// // perhaps extend sxy-loader to allow this
|
|
231
|
+
|
|
164
232
|
// mochaIt("should pass exported/returned data from beforeEachDescribe tasks", function() {
|
|
233
|
+
|
|
165
234
|
// const testFile = 'unitTesting/runTest/beforeEachDescribe.test.js'
|
|
166
235
|
// const test = loadTestFile(defaultConfig, testFile)
|
|
236
|
+
|
|
167
237
|
// const ourConfig = {
|
|
168
238
|
// beforeEachDescribe: [
|
|
169
239
|
// function() {
|
|
@@ -172,14 +242,21 @@ await mochaDescribe('runIt() function', async function () {
|
|
|
172
242
|
// 'unitTesting/runTest/beforeEachDescribeExport.js'
|
|
173
243
|
// ]
|
|
174
244
|
// }
|
|
245
|
+
|
|
175
246
|
// const config = applyConfigDefaults(ourConfig)
|
|
247
|
+
|
|
176
248
|
// runTest(config, test)
|
|
249
|
+
|
|
177
250
|
// global.functionThing.should.equal('foo')
|
|
178
251
|
// global.fileThing.should.equal('bar')
|
|
252
|
+
|
|
179
253
|
// })
|
|
254
|
+
|
|
180
255
|
// mochaIt("should pass exported/returned data from beforeEachTest tasks", function() {
|
|
256
|
+
|
|
181
257
|
// const testFile = 'unitTesting/runTest/beforeEachTest.test.js'
|
|
182
258
|
// const test = loadTestFile(defaultConfig, testFile)
|
|
259
|
+
|
|
183
260
|
// const ourConfig = {
|
|
184
261
|
// beforeEachTest: [
|
|
185
262
|
// function() {
|
|
@@ -188,17 +265,26 @@ await mochaDescribe('runIt() function', async function () {
|
|
|
188
265
|
// 'unitTesting/runTest/beforeEachTestExport.js'
|
|
189
266
|
// ]
|
|
190
267
|
// }
|
|
268
|
+
|
|
191
269
|
// const config = applyConfigDefaults(ourConfig)
|
|
270
|
+
|
|
192
271
|
// runTest(config, test)
|
|
272
|
+
|
|
193
273
|
// global.functionThing.should.equal('foo')
|
|
194
274
|
// global.fileThing.should.equal('bar')
|
|
275
|
+
|
|
195
276
|
// })
|
|
277
|
+
|
|
196
278
|
// // exports pass through
|
|
279
|
+
|
|
197
280
|
// mochaIt("beforeEachFile exports are passed through to afterEachFile", function() {
|
|
281
|
+
|
|
198
282
|
// // don't try to reload test, fails due to module caching
|
|
199
283
|
// //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
|
|
200
284
|
// //const test = loadTestFile(defaultConfig, testFile)
|
|
285
|
+
|
|
201
286
|
// let exports
|
|
287
|
+
|
|
202
288
|
// const ourConfig = {
|
|
203
289
|
// beforeEachFile: [
|
|
204
290
|
// function() {
|
|
@@ -213,16 +299,24 @@ await mochaDescribe('runIt() function', async function () {
|
|
|
213
299
|
// },
|
|
214
300
|
// ]
|
|
215
301
|
// }
|
|
302
|
+
|
|
216
303
|
// const config = applyConfigDefaults(ourConfig)
|
|
304
|
+
|
|
217
305
|
// runTest(config, beforeAfterTest)
|
|
306
|
+
|
|
218
307
|
// exports.functionThing.should.equal('foo')
|
|
219
308
|
// exports.fileThing.should.equal('bar')
|
|
309
|
+
|
|
220
310
|
// })
|
|
311
|
+
|
|
221
312
|
// mochaIt("beforeEachDescribe exports are passed through to afterEachDescribe", function() {
|
|
313
|
+
|
|
222
314
|
// // don't try to reload test, fails due to module caching
|
|
223
315
|
// //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
|
|
224
316
|
// //const test = loadTestFile(defaultConfig, testFile)
|
|
317
|
+
|
|
225
318
|
// let exports
|
|
319
|
+
|
|
226
320
|
// const ourConfig = {
|
|
227
321
|
// beforeEachDescribe: [
|
|
228
322
|
// function() {
|
|
@@ -236,17 +330,26 @@ await mochaDescribe('runIt() function', async function () {
|
|
|
236
330
|
// },
|
|
237
331
|
// ]
|
|
238
332
|
// }
|
|
333
|
+
|
|
239
334
|
// const config = applyConfigDefaults(ourConfig)
|
|
335
|
+
|
|
240
336
|
// runTest(config, beforeAfterTest)
|
|
337
|
+
|
|
241
338
|
// //console.log('exports', exports)
|
|
339
|
+
|
|
242
340
|
// exports.functionThing.should.equal('foo')
|
|
243
341
|
// exports.fileThing.should.equal('bar')
|
|
342
|
+
|
|
244
343
|
// })
|
|
344
|
+
|
|
245
345
|
// mochaIt("beforeEachTest exports are passed through to afterEachTest", function() {
|
|
346
|
+
|
|
246
347
|
// // don't try to reload test, fails due to module caching
|
|
247
348
|
// //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
|
|
248
349
|
// //const test = loadTestFile(defaultConfig, testFile)
|
|
350
|
+
|
|
249
351
|
// let exports
|
|
352
|
+
|
|
250
353
|
// const ourConfig = {
|
|
251
354
|
// beforeEachTest: [
|
|
252
355
|
// function() {
|
|
@@ -260,35 +363,52 @@ await mochaDescribe('runIt() function', async function () {
|
|
|
260
363
|
// },
|
|
261
364
|
// ]
|
|
262
365
|
// }
|
|
366
|
+
|
|
263
367
|
// const config = applyConfigDefaults(ourConfig)
|
|
368
|
+
|
|
264
369
|
// runTest(config, beforeAfterTest)
|
|
370
|
+
|
|
265
371
|
// //console.log('exports', exports)
|
|
372
|
+
|
|
266
373
|
// exports.functionThing.should.equal('foo')
|
|
267
374
|
// exports.fileThing.should.equal('bar')
|
|
375
|
+
|
|
268
376
|
// })
|
|
377
|
+
|
|
269
378
|
// mochaIt("we can run code beforeEachTest and afterEachTest from within the test file", function() {
|
|
379
|
+
|
|
270
380
|
// // don't try to reload test, fails due to module caching
|
|
271
381
|
// const testFile = 'unitTesting/runTest/internalBeforeAfterEachTest.test.js'
|
|
272
382
|
// const test = loadTestFile(defaultConfig, testFile)
|
|
383
|
+
|
|
273
384
|
// const config = applyConfigDefaults({})
|
|
385
|
+
|
|
274
386
|
// global.internalBeforeEachTestRanNTimes = 0
|
|
275
387
|
// global.internalAfterEachTestRanNTimes = 0
|
|
276
388
|
// runTest(config, test)
|
|
389
|
+
|
|
277
390
|
// global.internalBeforeAfterEachTest_test1Valid.should.equal(true)
|
|
278
391
|
// global.internalBeforeAfterEachTest_test2Valid.should.equal(true)
|
|
279
392
|
// global.internalBeforeAfterEachTest_test3Valid.should.equal(true)
|
|
280
393
|
// global.internalBeforeEachTestRanNTimes.should.equal(3)
|
|
281
394
|
// global.internalAfterEachTestRanNTimes.should.equal(3)
|
|
395
|
+
|
|
282
396
|
// })
|
|
397
|
+
|
|
283
398
|
// mochaIt("we can run code afterDescribe from within descibe in the test file", function() {
|
|
399
|
+
|
|
284
400
|
// // don't try to reload test, fails due to module caching
|
|
285
401
|
// const testFile = 'unitTesting/runTest/internalAfterDescribeTest.test.js'
|
|
286
402
|
// const test = loadTestFile(defaultConfig, testFile)
|
|
403
|
+
|
|
287
404
|
// const config = applyConfigDefaults({})
|
|
405
|
+
|
|
288
406
|
// global.internalAfterDescribeRanNTimes = 0
|
|
289
407
|
// runTest(config, test)
|
|
408
|
+
|
|
290
409
|
// //global.internalAfterDescribe_test1Valid.should.equal(true)
|
|
291
410
|
// //global.internalAfterDescribe_test2Valid.should.equal(true)
|
|
292
411
|
// global.internalAfterDescribeRanNTimes.should.equal(2)
|
|
412
|
+
|
|
293
413
|
// })
|
|
294
414
|
});
|
package/dist/cli/lib/runTasks.js
CHANGED
|
@@ -5,10 +5,8 @@ export async function runTasks(tasks, parcel = undefined) {
|
|
|
5
5
|
if (tasks) {
|
|
6
6
|
if (!(await Array.isArray(tasks))) tasks = [tasks];
|
|
7
7
|
const exports = {};
|
|
8
|
-
|
|
9
8
|
for (const task of tasks) {
|
|
10
9
|
await debug('task', typeof task, task);
|
|
11
|
-
|
|
12
10
|
switch (typeof task) {
|
|
13
11
|
case 'function':
|
|
14
12
|
{
|
|
@@ -17,15 +15,13 @@ export async function runTasks(tasks, parcel = undefined) {
|
|
|
17
15
|
await addExports(exports, result);
|
|
18
16
|
break;
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
case 'string':
|
|
22
19
|
{
|
|
23
|
-
const result = await import(`file://${await join(await process.cwd(), task)}`);
|
|
24
|
-
|
|
20
|
+
const result = await import(`file://${await join(await process.cwd(), task)}`);
|
|
21
|
+
//console.log
|
|
25
22
|
await addExports(exports, result);
|
|
26
23
|
break;
|
|
27
24
|
}
|
|
28
|
-
|
|
29
25
|
default:
|
|
30
26
|
{
|
|
31
27
|
await out(`Error: task entry has an invalid type, expected 'function' or 'string' of an file to import.`);
|
|
@@ -33,7 +29,6 @@ export async function runTasks(tasks, parcel = undefined) {
|
|
|
33
29
|
}
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
|
-
|
|
37
32
|
return exports;
|
|
38
33
|
} else {
|
|
39
34
|
await debug('no tasks');
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { runTasks } from './runTasks.js';
|
|
2
|
-
import { defaultConfig } from './defaultConfig.js';
|
|
2
|
+
import { defaultConfig } from './defaultConfig.js';
|
|
3
|
+
|
|
4
|
+
// runTasks(config, tasks)
|
|
3
5
|
// config:
|
|
4
6
|
// tasks: function, file location, or array of those
|
|
5
7
|
|
package/dist/cli/lib/runTest.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createTimeProfiler } from 'sxy-dev-tools';
|
|
2
|
-
|
|
1
|
+
import { createTimeProfiler } from 'sxy-dev-tools';
|
|
2
|
+
//import chalk from 'chalk-extensions'
|
|
3
3
|
import { out, log, debug } from '../../output.js';
|
|
4
4
|
import { showTimeProfiling } from '../../config.js';
|
|
5
5
|
import { runTasks } from './runTasks.js';
|
|
@@ -10,23 +10,29 @@ const {
|
|
|
10
10
|
} = await createTimeProfiler(showTimeProfiling);
|
|
11
11
|
export async function runTest(config, test) {
|
|
12
12
|
return await timeProfileAsync(`run test ${test.file}`, async () => {
|
|
13
|
-
await debug('test', test);
|
|
13
|
+
await debug('test', test);
|
|
14
14
|
|
|
15
|
+
// run before test file
|
|
15
16
|
const fileExports = {};
|
|
16
|
-
await configBeforeEachFile(config, fileExports);
|
|
17
|
+
await configBeforeEachFile(config, fileExports);
|
|
18
|
+
|
|
19
|
+
// const beforeEachFileExports = (config.beforeEachFile)
|
|
17
20
|
// ? runTasks(config, config.beforeEachFile)
|
|
18
21
|
// : {}
|
|
22
|
+
|
|
19
23
|
//const describeCounter = 1
|
|
20
24
|
|
|
21
25
|
const runDescribePromises = [];
|
|
22
|
-
|
|
23
26
|
for (const describe of test.describes) {
|
|
24
27
|
await runDescribePromises.push(runDescribe(config, describe));
|
|
25
28
|
if (config.execution.describes === 'sequential') await runDescribePromises.at(-1);
|
|
26
|
-
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//console.log('runDescribePromises', runDescribePromises)
|
|
27
32
|
|
|
33
|
+
const describeResults = await Promise.all(runDescribePromises);
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
//console.log('describeResults', describeResults)
|
|
30
36
|
|
|
31
37
|
const describeResultsSummary = {
|
|
32
38
|
total: 0,
|
|
@@ -35,7 +41,6 @@ export async function runTest(config, test) {
|
|
|
35
41
|
itsTotal: 0,
|
|
36
42
|
itsPasses: 0
|
|
37
43
|
};
|
|
38
|
-
|
|
39
44
|
for (const describeResult of describeResults) {
|
|
40
45
|
describeResultsSummary.total += +(describeResult.success !== null);
|
|
41
46
|
describeResultsSummary.passes += +describeResult.success;
|
|
@@ -43,27 +48,25 @@ export async function runTest(config, test) {
|
|
|
43
48
|
describeResultsSummary.itsTotal += describeResult.itResultsSummary.total;
|
|
44
49
|
describeResultsSummary.itsPasses += describeResult.itResultsSummary.passes;
|
|
45
50
|
}
|
|
46
|
-
|
|
47
51
|
const testResults = {
|
|
48
52
|
file: test.file,
|
|
49
53
|
success: describeResultsSummary.total > 0 ? describeResultsSummary.total === describeResultsSummary.passes : null,
|
|
50
54
|
describeResults,
|
|
51
55
|
describeResultsSummary,
|
|
52
56
|
logs: test.logs
|
|
53
|
-
};
|
|
57
|
+
};
|
|
54
58
|
|
|
59
|
+
// run after test
|
|
55
60
|
await configAfterEachFile(config, fileExports);
|
|
56
61
|
return testResults;
|
|
57
62
|
});
|
|
58
63
|
}
|
|
59
|
-
|
|
60
64
|
async function configBeforeEachFile(config, exports) {
|
|
61
65
|
if (config.beforeEachFile) {
|
|
62
66
|
const theExports = await runTasks(config.beforeEachFile, undefined);
|
|
63
67
|
await addExports(exports, theExports);
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
|
-
|
|
67
70
|
async function configAfterEachFile(config, exports) {
|
|
68
71
|
if (config.afterEachFile) {
|
|
69
72
|
await runTasks(config.afterEachFile, exports);
|
|
@@ -7,9 +7,12 @@ const beforeAfterTest = await loadTestFile(defaultConfig, beforeAfterTestFile);
|
|
|
7
7
|
await mochaDescribe('runTest() function', async function () {
|
|
8
8
|
await mochaIt('should run a test that was previously loaded from a test file', async function () {
|
|
9
9
|
//const config = applyConfigDefaults({})
|
|
10
|
+
|
|
10
11
|
const sampleTestFile = 'unitTesting/runTest/1.test.js';
|
|
11
12
|
const sampleTest = await loadTestFile(defaultConfig, sampleTestFile);
|
|
12
|
-
const testResult = await runTest(defaultConfig, sampleTest);
|
|
13
|
+
const testResult = await runTest(defaultConfig, sampleTest);
|
|
14
|
+
|
|
15
|
+
//console.log(testResult)
|
|
13
16
|
//console.log(testResult.describeResults[0].itResults)
|
|
14
17
|
//console.log(testResult.describeResults[0].itResultsSummary)
|
|
15
18
|
|
|
@@ -22,23 +25,32 @@ await mochaDescribe('runTest() function', async function () {
|
|
|
22
25
|
});
|
|
23
26
|
await mochaIt('should return sensible results from a test file without any describes', async function () {
|
|
24
27
|
//const config = applyConfigDefaults({})
|
|
28
|
+
|
|
25
29
|
const sampleTestFile = 'unitTesting/sampletests/blank.test.js';
|
|
26
30
|
const sampleTest = await loadTestFile(defaultConfig, sampleTestFile);
|
|
27
|
-
const testResult = await runTest(defaultConfig, sampleTest);
|
|
31
|
+
const testResult = await runTest(defaultConfig, sampleTest);
|
|
32
|
+
|
|
33
|
+
//console.log(testResult)
|
|
28
34
|
//console.log(testResult.describeResults[0].itResults)
|
|
29
35
|
//console.log(testResult.describeResults[0].itResultsSummary)
|
|
30
36
|
|
|
31
37
|
await testResult.should.include.keys(['file', 'success', 'describeResults', 'describeResultsSummary']);
|
|
32
|
-
(await chaiExpect(testResult.success)).to.be.null;
|
|
38
|
+
(await chaiExpect(testResult.success)).to.be.null;
|
|
39
|
+
|
|
40
|
+
//testResult.describeResultsSummary.total.should.equal(1)
|
|
33
41
|
//testResult.describeResultsSummary.passes.should.equal(1)
|
|
34
42
|
//testResult.describeResultsSummary.itsTotal.should.equal(1)
|
|
35
43
|
//testResult.describeResultsSummary.itsPasses.should.equal(1)
|
|
36
44
|
});
|
|
45
|
+
|
|
37
46
|
await mochaIt('should return sensible results from a test file with describes without any its/tests', async function () {
|
|
38
47
|
//const config = applyConfigDefaults({})
|
|
48
|
+
|
|
39
49
|
const sampleTestFile = 'unitTesting/sampletests/describesWithoutTests.test.js';
|
|
40
50
|
const sampleTest = await loadTestFile(defaultConfig, sampleTestFile);
|
|
41
|
-
const testResult = await runTest(defaultConfig, sampleTest);
|
|
51
|
+
const testResult = await runTest(defaultConfig, sampleTest);
|
|
52
|
+
|
|
53
|
+
//console.log(testResult)
|
|
42
54
|
//console.log(testResult.describeResults[0].itResults)
|
|
43
55
|
//console.log(testResult.describeResults[0].itResultsSummary)
|
|
44
56
|
|
|
@@ -127,7 +139,10 @@ await mochaDescribe('runTest() function', async function () {
|
|
|
127
139
|
await runTest(config, beforeAfterTest);
|
|
128
140
|
await functionHasRunTimes.should.equal(3);
|
|
129
141
|
await global.afterEachTestFileHasRun.should.equal(true);
|
|
130
|
-
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// exports provision to test file
|
|
145
|
+
|
|
131
146
|
// current beforeEachFile exports aren't provided
|
|
132
147
|
// perhaps extend sxy-loader to allow this
|
|
133
148
|
|
|
@@ -160,12 +175,15 @@ await mochaDescribe('runTest() function', async function () {
|
|
|
160
175
|
await runTest(config, test);
|
|
161
176
|
await global.functionThing.should.equal('foo');
|
|
162
177
|
await global.fileThing.should.equal('bar');
|
|
163
|
-
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// exports pass through
|
|
164
181
|
|
|
165
182
|
await mochaIt("beforeEachFile exports are passed through to afterEachFile", async function () {
|
|
166
183
|
// don't try to reload test, fails due to module caching
|
|
167
184
|
//const testFile = 'unitTesting/runTest/beforeAfter.test.js'
|
|
168
185
|
//const test = loadTestFile(defaultConfig, testFile)
|
|
186
|
+
|
|
169
187
|
let exports;
|
|
170
188
|
const ourConfig = {
|
|
171
189
|
beforeEachFile: [async function () {
|
|
@@ -187,6 +205,7 @@ await mochaDescribe('runTest() function', async function () {
|
|
|
187
205
|
// don't try to reload test, fails due to module caching
|
|
188
206
|
//const testFile = 'unitTesting/runTest/beforeAfter.test.js'
|
|
189
207
|
//const test = loadTestFile(defaultConfig, testFile)
|
|
208
|
+
|
|
190
209
|
let exports;
|
|
191
210
|
const ourConfig = {
|
|
192
211
|
beforeEachDescribe: [async function () {
|
|
@@ -199,7 +218,9 @@ await mochaDescribe('runTest() function', async function () {
|
|
|
199
218
|
}]
|
|
200
219
|
};
|
|
201
220
|
const config = await applyConfigDefaults(ourConfig);
|
|
202
|
-
await runTest(config, beforeAfterTest);
|
|
221
|
+
await runTest(config, beforeAfterTest);
|
|
222
|
+
|
|
223
|
+
//console.log('exports', exports)
|
|
203
224
|
|
|
204
225
|
await exports.functionThing.should.equal('foo');
|
|
205
226
|
await exports.fileThing.should.equal('bar');
|
|
@@ -208,6 +229,7 @@ await mochaDescribe('runTest() function', async function () {
|
|
|
208
229
|
// don't try to reload test, fails due to module caching
|
|
209
230
|
//const testFile = 'unitTesting/runTest/beforeAfter.test.js'
|
|
210
231
|
//const test = loadTestFile(defaultConfig, testFile)
|
|
232
|
+
|
|
211
233
|
let exports;
|
|
212
234
|
const ourConfig = {
|
|
213
235
|
beforeEachTest: [async function () {
|
|
@@ -220,7 +242,9 @@ await mochaDescribe('runTest() function', async function () {
|
|
|
220
242
|
}]
|
|
221
243
|
};
|
|
222
244
|
const config = await applyConfigDefaults(ourConfig);
|
|
223
|
-
await runTest(config, beforeAfterTest);
|
|
245
|
+
await runTest(config, beforeAfterTest);
|
|
246
|
+
|
|
247
|
+
//console.log('exports', exports)
|
|
224
248
|
|
|
225
249
|
await exports.functionThing.should.equal('foo');
|
|
226
250
|
await exports.fileThing.should.equal('bar');
|
|
@@ -245,9 +269,10 @@ await mochaDescribe('runTest() function', async function () {
|
|
|
245
269
|
const test = await loadTestFile(defaultConfig, testFile);
|
|
246
270
|
const config = await applyConfigDefaults({});
|
|
247
271
|
global.internalAfterDescribeRanNTimes = 0;
|
|
248
|
-
await runTest(config, test);
|
|
249
|
-
//global.internalAfterDescribe_test2Valid.should.equal(true)
|
|
272
|
+
await runTest(config, test);
|
|
250
273
|
|
|
274
|
+
//global.internalAfterDescribe_test1Valid.should.equal(true)
|
|
275
|
+
//global.internalAfterDescribe_test2Valid.should.equal(true)
|
|
251
276
|
await global.internalAfterDescribeRanNTimes.should.equal(2);
|
|
252
277
|
});
|
|
253
278
|
await mochaIt('should capture and returns logs from the test when using sequential execution', async function () {
|
|
@@ -263,7 +288,9 @@ await mochaDescribe('runTest() function', async function () {
|
|
|
263
288
|
const testResult = await runTest(config, sampleTest);
|
|
264
289
|
await testResult.describeResults[0].logs.length.should.equal(1);
|
|
265
290
|
await testResult.describeResults[0].itResults[0].logs.length.should.equal(1);
|
|
266
|
-
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// mochaIt('should not capture logs when not running in sequential mode', function() {
|
|
267
294
|
// throw new Error('to do')
|
|
268
295
|
// })
|
|
269
296
|
});
|