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.
Files changed (78) hide show
  1. package/dist/cli/index.js +2 -6
  2. package/dist/cli/init.js +19 -14
  3. package/dist/cli/lib/addBasePath.js +0 -1
  4. package/dist/cli/lib/addBasePath.unitTest.js +3 -1
  5. package/dist/cli/lib/addExports.unitTest.js +4 -1
  6. package/dist/cli/lib/applyConfigDefaults.js +12 -7
  7. package/dist/cli/lib/applyConfigDefaults.unitTest.js +9 -3
  8. package/dist/cli/lib/buildDependencyTree.js +10 -5
  9. package/dist/cli/lib/buildDependencyTree.unitTest.js +3 -1
  10. package/dist/cli/lib/buildDependencyTrees.js +6 -4
  11. package/dist/cli/lib/buildDependencyTrees.unitTest.js +3 -1
  12. package/dist/cli/lib/defaultConfig.test.js +3 -1
  13. package/dist/cli/lib/doUserSetup.js +0 -3
  14. package/dist/cli/lib/doUserSetup.unitTest.js +3 -1
  15. package/dist/cli/lib/doUserTeardown.js +0 -3
  16. package/dist/cli/lib/doUserTeardown.unitTest.js +3 -1
  17. package/dist/cli/lib/findTestFiles.unitTest.js +3 -1
  18. package/dist/cli/lib/getAllowedFlags.js +0 -2
  19. package/dist/cli/lib/getAllowedFlags.unitTest.js +3 -1
  20. package/dist/cli/lib/injectProperties.js +2 -2
  21. package/dist/cli/lib/injectProperties.unitTest.js +9 -2
  22. package/dist/cli/lib/loadConfig.js +2 -2
  23. package/dist/cli/lib/loadConfig.unitTest.js +3 -2
  24. package/dist/cli/lib/loadTestFile.js +17 -15
  25. package/dist/cli/lib/loadTestFile.unitTest.js +8 -3
  26. package/dist/cli/lib/loadTestFileStatic.js +1 -0
  27. package/dist/cli/lib/loadTestFileStatic.unitTest.js +1 -0
  28. package/dist/cli/lib/parseCommandLineArguments.js +1 -9
  29. package/dist/cli/lib/parseCommandLineArguments.unitTest.js +6 -2
  30. package/dist/cli/lib/parseDescribe.js +12 -18
  31. package/dist/cli/lib/parseDescribe.unitTest.js +6 -2
  32. package/dist/cli/lib/processWatchEvent.unitTest.js +9 -1
  33. package/dist/cli/lib/reservedExportKeys.unitTest.js +3 -1
  34. package/dist/cli/lib/runDescribe.js +4 -7
  35. package/dist/cli/lib/runDescribe.old.js +19 -25
  36. package/dist/cli/lib/runDescribe.unitTest.js +120 -2
  37. package/dist/cli/lib/runDescribeRun.js +3 -7
  38. package/dist/cli/lib/runDescribeRun.unitTest.js +125 -4
  39. package/dist/cli/lib/runIt.js +16 -18
  40. package/dist/cli/lib/runIt.unitTest.js +124 -4
  41. package/dist/cli/lib/runTasks.js +2 -7
  42. package/dist/cli/lib/runTasks.unitTest.js +3 -1
  43. package/dist/cli/lib/runTest-old.js +1 -0
  44. package/dist/cli/lib/runTest-old.unitTest.js +1 -0
  45. package/dist/cli/lib/runTest.js +15 -12
  46. package/dist/cli/lib/runTest.unitTest.js +38 -11
  47. package/dist/cli/lib/runTests.js +36 -35
  48. package/dist/cli/lib/runTests.unitTest.js +15 -8
  49. package/dist/cli/lib/showTestLoadingError.js +6 -6
  50. package/dist/cli/lib/showTestLoadingError.unitTest.js +5 -3
  51. package/dist/cli/lib/showTestResult.js +10 -16
  52. package/dist/cli/lib/showTestResult.unitTest.js +26 -17
  53. package/dist/cli/lib/validateConfig.js +0 -5
  54. package/dist/cli/lib/validateConfig.unitTest.js +2 -3
  55. package/dist/cli/lib/watchFiles.unitTest.js +5 -3
  56. package/dist/cli/lib/watchFilesAndRunTests.js +3 -1
  57. package/dist/cli/lib/watchFilesAndRunTests.unitTest.js +18 -15
  58. package/dist/cli/lib/watchFilesAndRunTestsChokidar.js +22 -29
  59. package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js +19 -17
  60. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js +28 -31
  61. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js +21 -16
  62. package/dist/cli/lib/watchFilesChokidar.js +15 -11
  63. package/dist/cli/lib/watchFilesChokidar.unitTest.js +11 -8
  64. package/dist/cli/lib/watchFilesNodeWatch.js +9 -6
  65. package/dist/cli/lib/watchFilesNodeWatch.unitTest.js +6 -3
  66. package/dist/cli/once.js +0 -6
  67. package/dist/cli/watch.js +18 -14
  68. package/dist/cli/watch.unitTest.js +16 -16
  69. package/dist/describe-old.js +35 -20
  70. package/dist/describe-old.unitTest.js +10 -1
  71. package/dist/describe.js +8 -3
  72. package/dist/describe.unitTest.js +5 -2
  73. package/dist/indexNumberToLetters.js +1 -3
  74. package/dist/output.js +7 -0
  75. package/dist/testsState.js +2 -1
  76. package/package.json +14 -7
  77. package/readme.md +1 -1
  78. package/sxy-loader.config.js +10 -10
@@ -1,7 +1,9 @@
1
1
  import { applyConfigDefaults } from './applyConfigDefaults.js';
2
2
  import { loadTestFile } from './loadTestFile.js';
3
3
  import { runDescribe } from './runDescribe.js';
4
- const defaultConfig = await applyConfigDefaults({}); // const beforeAfterTestFile = 'unitTesting/runTest/beforeAfter.test.js'
4
+ const defaultConfig = await applyConfigDefaults({});
5
+
6
+ // const beforeAfterTestFile = 'unitTesting/runTest/beforeAfter.test.js'
5
7
  // const beforeAfterTest = loadTestFile(defaultConfig, beforeAfterTestFile)
6
8
 
7
9
  await mochaDescribe('runDescribe() function', async function () {
@@ -14,50 +16,72 @@ await mochaDescribe('runDescribe() function', async function () {
14
16
  await describeResult.success.should.equal(true);
15
17
  await describeResult.itResultsSummary.total.should.equal(1);
16
18
  await describeResult.itResultsSummary.passes.should.equal(1);
17
- }); // mochaIt('should return sensible results from a test file without any describes', function() {
19
+ });
20
+
21
+ // mochaIt('should return sensible results from a test file without any describes', function() {
22
+
18
23
  // //const config = applyConfigDefaults({})
24
+
19
25
  // const sampleTestFile = 'unitTesting/sampletests/blank.test.js'
20
26
  // const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
27
+
21
28
  // const testResult = runTest(defaultConfig, sampleTest)
29
+
22
30
  // //console.log(testResult)
23
31
  // //console.log(testResult.describeResults[0].itResults)
24
32
  // //console.log(testResult.describeResults[0].itResultsSummary)
33
+
25
34
  // testResult.should.include.keys([
26
35
  // 'file',
27
36
  // 'success',
28
37
  // 'describeResults',
29
38
  // 'describeResultsSummary'
30
39
  // ])
40
+
31
41
  // chaiExpect(testResult.success).to.be.null
42
+
32
43
  // //testResult.describeResultsSummary.total.should.equal(1)
33
44
  // //testResult.describeResultsSummary.passes.should.equal(1)
34
45
  // //testResult.describeResultsSummary.itsTotal.should.equal(1)
35
46
  // //testResult.describeResultsSummary.itsPasses.should.equal(1)
47
+
36
48
  // })
49
+
37
50
  // mochaIt('should return sensible results from a test file with describes without any its/tests', function() {
51
+
38
52
  // //const config = applyConfigDefaults({})
53
+
39
54
  // const sampleTestFile = 'unitTesting/sampletests/describesWithoutTests.test.js'
40
55
  // const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
56
+
41
57
  // const testResult = runTest(defaultConfig, sampleTest)
58
+
42
59
  // //console.log(testResult)
43
60
  // //console.log(testResult.describeResults[0].itResults)
44
61
  // //console.log(testResult.describeResults[0].itResultsSummary)
62
+
45
63
  // testResult.should.include.keys([
46
64
  // 'file',
47
65
  // 'success',
48
66
  // 'describeResults',
49
67
  // 'describeResultsSummary'
50
68
  // ])
69
+
51
70
  // chaiExpect(testResult.success).to.be.null
71
+
52
72
  // testResult.describeResultsSummary.total.should.equal(0)
53
73
  // testResult.describeResultsSummary.passes.should.equal(0)
54
74
  // testResult.describeResultsSummary.invalid.should.equal(2)
55
75
  // testResult.describeResultsSummary.itsTotal.should.equal(0)
56
76
  // testResult.describeResultsSummary.itsPasses.should.equal(0)
77
+
57
78
  // })
79
+
58
80
  // mochaIt("should run beforeEachFile tasks (before - can't test)", function() {
81
+
59
82
  // let functionHasRun = false
60
83
  // global.beforeEachFileFileHasRun = false
84
+
61
85
  // const ourConfig = {
62
86
  // beforeEachFile: [
63
87
  // function() {
@@ -66,14 +90,21 @@ await mochaDescribe('runDescribe() function', async function () {
66
90
  // 'unitTesting/runTest/beforeEachFile.js'
67
91
  // ]
68
92
  // }
93
+
69
94
  // const config = applyConfigDefaults(ourConfig)
95
+
70
96
  // runTest(config, beforeAfterTest)
97
+
71
98
  // functionHasRun.should.equal(true)
72
99
  // global.beforeEachFileFileHasRun.should.equal(true)
100
+
73
101
  // })
102
+
74
103
  // mochaIt("should run afterEachFile tasks (after - can't test)", function() {
104
+
75
105
  // let functionHasRun = false
76
106
  // global.afterEachFileFileHasRun = false
107
+
77
108
  // const ourConfig = {
78
109
  // afterEachFile: [
79
110
  // function() {
@@ -82,14 +113,21 @@ await mochaDescribe('runDescribe() function', async function () {
82
113
  // 'unitTesting/runTest/afterEachFile.js'
83
114
  // ]
84
115
  // }
116
+
85
117
  // const config = applyConfigDefaults(ourConfig)
118
+
86
119
  // runTest(config, beforeAfterTest)
120
+
87
121
  // functionHasRun.should.equal(true)
88
122
  // global.afterEachFileFileHasRun.should.equal(true)
123
+
89
124
  // })
125
+
90
126
  // mochaIt("should run beforeEachDescribe tasks (before - can't test) each describe block", function() {
127
+
91
128
  // let functionHasRunTimes = 0
92
129
  // global.beforeEachDescribeFileHasRun = false
130
+
93
131
  // const ourConfig = {
94
132
  // beforeEachDescribe: [
95
133
  // function() {
@@ -98,14 +136,21 @@ await mochaDescribe('runDescribe() function', async function () {
98
136
  // 'unitTesting/runTest/beforeEachDescribe.js'
99
137
  // ]
100
138
  // }
139
+
101
140
  // const config = applyConfigDefaults(ourConfig)
141
+
102
142
  // runTest(config, beforeAfterTest)
143
+
103
144
  // functionHasRunTimes.should.equal(2)
104
145
  // global.beforeEachDescribeFileHasRun.should.equal(true)
146
+
105
147
  // })
148
+
106
149
  // mochaIt("should run afterEachDescribe tasks (after - can't test) each describe block", function() {
150
+
107
151
  // let functionHasRunTimes = 0
108
152
  // global.afterEachDescribeFileHasRun = false
153
+
109
154
  // const ourConfig = {
110
155
  // afterEachDescribe: [
111
156
  // function() {
@@ -114,14 +159,21 @@ await mochaDescribe('runDescribe() function', async function () {
114
159
  // 'unitTesting/runTest/afterEachDescribe.js'
115
160
  // ]
116
161
  // }
162
+
117
163
  // const config = applyConfigDefaults(ourConfig)
164
+
118
165
  // runTest(config, beforeAfterTest)
166
+
119
167
  // functionHasRunTimes.should.equal(2)
120
168
  // global.afterEachDescribeFileHasRun.should.equal(true)
169
+
121
170
  // })
171
+
122
172
  // mochaIt("should run beforeEachTest tasks (before - can't test) each test/it block", function() {
173
+
123
174
  // let functionHasRunTimes = 0
124
175
  // global.beforeEachTestbeforeEachFileFileHasRun = false
176
+
125
177
  // const ourConfig = {
126
178
  // beforeEachTest: [
127
179
  // function() {
@@ -130,14 +182,21 @@ await mochaDescribe('runDescribe() function', async function () {
130
182
  // 'unitTesting/runTest/beforeEachTest.js'
131
183
  // ]
132
184
  // }
185
+
133
186
  // const config = applyConfigDefaults(ourConfig)
187
+
134
188
  // runTest(config, beforeAfterTest)
189
+
135
190
  // functionHasRunTimes.should.equal(3)
136
191
  // global.beforeEachTestFileHasRun.should.equal(true)
192
+
137
193
  // })
194
+
138
195
  // mochaIt("should run afterEachTest tasks (after - can't test) each test/it block", function() {
196
+
139
197
  // let functionHasRunTimes = 0
140
198
  // global.afterEachTestFileFileHasRun = false
199
+
141
200
  // const ourConfig = {
142
201
  // afterEachTest: [
143
202
  // function() {
@@ -146,17 +205,26 @@ await mochaDescribe('runDescribe() function', async function () {
146
205
  // 'unitTesting/runTest/afterEachTest.js'
147
206
  // ]
148
207
  // }
208
+
149
209
  // const config = applyConfigDefaults(ourConfig)
210
+
150
211
  // runTest(config, beforeAfterTest)
212
+
151
213
  // functionHasRunTimes.should.equal(3)
152
214
  // global.afterEachTestFileHasRun.should.equal(true)
215
+
153
216
  // })
217
+
154
218
  // // exports provision to test file
219
+
155
220
  // // current beforeEachFile exports aren't provided
156
221
  // // perhaps extend sxy-loader to allow this
222
+
157
223
  // mochaIt("should pass exported/returned data from beforeEachDescribe tasks", function() {
224
+
158
225
  // const testFile = 'unitTesting/runTest/beforeEachDescribe.test.js'
159
226
  // const test = loadTestFile(defaultConfig, testFile)
227
+
160
228
  // const ourConfig = {
161
229
  // beforeEachDescribe: [
162
230
  // function() {
@@ -165,14 +233,21 @@ await mochaDescribe('runDescribe() function', async function () {
165
233
  // 'unitTesting/runTest/beforeEachDescribeExport.js'
166
234
  // ]
167
235
  // }
236
+
168
237
  // const config = applyConfigDefaults(ourConfig)
238
+
169
239
  // runTest(config, test)
240
+
170
241
  // global.functionThing.should.equal('foo')
171
242
  // global.fileThing.should.equal('bar')
243
+
172
244
  // })
245
+
173
246
  // mochaIt("should pass exported/returned data from beforeEachTest tasks", function() {
247
+
174
248
  // const testFile = 'unitTesting/runTest/beforeEachTest.test.js'
175
249
  // const test = loadTestFile(defaultConfig, testFile)
250
+
176
251
  // const ourConfig = {
177
252
  // beforeEachTest: [
178
253
  // function() {
@@ -181,17 +256,26 @@ await mochaDescribe('runDescribe() function', async function () {
181
256
  // 'unitTesting/runTest/beforeEachTestExport.js'
182
257
  // ]
183
258
  // }
259
+
184
260
  // const config = applyConfigDefaults(ourConfig)
261
+
185
262
  // runTest(config, test)
263
+
186
264
  // global.functionThing.should.equal('foo')
187
265
  // global.fileThing.should.equal('bar')
266
+
188
267
  // })
268
+
189
269
  // // exports pass through
270
+
190
271
  // mochaIt("beforeEachFile exports are passed through to afterEachFile", function() {
272
+
191
273
  // // don't try to reload test, fails due to module caching
192
274
  // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
193
275
  // //const test = loadTestFile(defaultConfig, testFile)
276
+
194
277
  // let exports
278
+
195
279
  // const ourConfig = {
196
280
  // beforeEachFile: [
197
281
  // function() {
@@ -206,16 +290,24 @@ await mochaDescribe('runDescribe() function', async function () {
206
290
  // },
207
291
  // ]
208
292
  // }
293
+
209
294
  // const config = applyConfigDefaults(ourConfig)
295
+
210
296
  // runTest(config, beforeAfterTest)
297
+
211
298
  // exports.functionThing.should.equal('foo')
212
299
  // exports.fileThing.should.equal('bar')
300
+
213
301
  // })
302
+
214
303
  // mochaIt("beforeEachDescribe exports are passed through to afterEachDescribe", function() {
304
+
215
305
  // // don't try to reload test, fails due to module caching
216
306
  // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
217
307
  // //const test = loadTestFile(defaultConfig, testFile)
308
+
218
309
  // let exports
310
+
219
311
  // const ourConfig = {
220
312
  // beforeEachDescribe: [
221
313
  // function() {
@@ -229,17 +321,26 @@ await mochaDescribe('runDescribe() function', async function () {
229
321
  // },
230
322
  // ]
231
323
  // }
324
+
232
325
  // const config = applyConfigDefaults(ourConfig)
326
+
233
327
  // runTest(config, beforeAfterTest)
328
+
234
329
  // //console.log('exports', exports)
330
+
235
331
  // exports.functionThing.should.equal('foo')
236
332
  // exports.fileThing.should.equal('bar')
333
+
237
334
  // })
335
+
238
336
  // mochaIt("beforeEachTest exports are passed through to afterEachTest", function() {
337
+
239
338
  // // don't try to reload test, fails due to module caching
240
339
  // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
241
340
  // //const test = loadTestFile(defaultConfig, testFile)
341
+
242
342
  // let exports
343
+
243
344
  // const ourConfig = {
244
345
  // beforeEachTest: [
245
346
  // function() {
@@ -253,35 +354,52 @@ await mochaDescribe('runDescribe() function', async function () {
253
354
  // },
254
355
  // ]
255
356
  // }
357
+
256
358
  // const config = applyConfigDefaults(ourConfig)
359
+
257
360
  // runTest(config, beforeAfterTest)
361
+
258
362
  // //console.log('exports', exports)
363
+
259
364
  // exports.functionThing.should.equal('foo')
260
365
  // exports.fileThing.should.equal('bar')
366
+
261
367
  // })
368
+
262
369
  // mochaIt("we can run code beforeEachTest and afterEachTest from within the test file", function() {
370
+
263
371
  // // don't try to reload test, fails due to module caching
264
372
  // const testFile = 'unitTesting/runTest/internalBeforeAfterEachTest.test.js'
265
373
  // const test = loadTestFile(defaultConfig, testFile)
374
+
266
375
  // const config = applyConfigDefaults({})
376
+
267
377
  // global.internalBeforeEachTestRanNTimes = 0
268
378
  // global.internalAfterEachTestRanNTimes = 0
269
379
  // runTest(config, test)
380
+
270
381
  // global.internalBeforeAfterEachTest_test1Valid.should.equal(true)
271
382
  // global.internalBeforeAfterEachTest_test2Valid.should.equal(true)
272
383
  // global.internalBeforeAfterEachTest_test3Valid.should.equal(true)
273
384
  // global.internalBeforeEachTestRanNTimes.should.equal(3)
274
385
  // global.internalAfterEachTestRanNTimes.should.equal(3)
386
+
275
387
  // })
388
+
276
389
  // mochaIt("we can run code afterDescribe from within descibe in the test file", function() {
390
+
277
391
  // // don't try to reload test, fails due to module caching
278
392
  // const testFile = 'unitTesting/runTest/internalAfterDescribeTest.test.js'
279
393
  // const test = loadTestFile(defaultConfig, testFile)
394
+
280
395
  // const config = applyConfigDefaults({})
396
+
281
397
  // global.internalAfterDescribeRanNTimes = 0
282
398
  // runTest(config, test)
399
+
283
400
  // //global.internalAfterDescribe_test1Valid.should.equal(true)
284
401
  // //global.internalAfterDescribe_test2Valid.should.equal(true)
285
402
  // global.internalAfterDescribeRanNTimes.should.equal(2)
403
+
286
404
  // })
287
405
  });
@@ -7,6 +7,7 @@ export async function runDescribeRun(config, describe, parsedIts) {
7
7
  return await timeProfileAsync(`run describe, run its ${describe.thing}`, async () => {
8
8
  // const beforeEachDescribeExports = {}
9
9
  // configBeforeEachDescribe(config, beforeEachDescribeExports)
10
+
10
11
  const {
11
12
  its,
12
13
  beforeDescribeExports,
@@ -15,21 +16,17 @@ export async function runDescribeRun(config, describe, parsedIts) {
15
16
  afterEachTestFunc
16
17
  } = parsedIts;
17
18
  const itResults = [];
18
-
19
19
  for (const it of its) {
20
20
  await itResults.push(await runIt(config, it, beforeEachTestFunc, afterEachTestFunc));
21
21
  }
22
-
23
22
  const itResultsSummary = {
24
23
  total: 0,
25
24
  passes: 0
26
25
  };
27
-
28
26
  for (const itResult of itResults) {
29
27
  itResultsSummary.total += +(itResult.success !== null);
30
28
  itResultsSummary.passes += +itResult.success;
31
29
  }
32
-
33
30
  await debug('itResultsSummary', itResultsSummary);
34
31
  const describeResult = {
35
32
  counter: describe.counter,
@@ -37,21 +34,20 @@ export async function runDescribeRun(config, describe, parsedIts) {
37
34
  success: itResultsSummary.total > 0 ? itResultsSummary.passes === itResultsSummary.total : null,
38
35
  itResults,
39
36
  itResultsSummary
40
- }; // run after
37
+ };
41
38
 
39
+ // run after
42
40
  if (typeof afterDescribeFunc === 'function') await afterDescribeFunc();
43
41
  await configAfterEachDescribe(config, beforeDescribeExports);
44
42
  return describeResult;
45
43
  });
46
44
  }
47
-
48
45
  async function configBeforeEachDescribe(config, exports) {
49
46
  if (config.beforeEachDescribe) {
50
47
  const theExports = await runTasks(config.beforeEachDescribe, undefined);
51
48
  await addExports(exports, theExports);
52
49
  }
53
50
  }
54
-
55
51
  async function configAfterEachDescribe(config, exports) {
56
52
  if (config.afterEachDescribe) {
57
53
  await runTasks(config.afterEachDescribe, exports);