sxy-test-runner 1.4.2 → 1.4.4

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