sxy-test-runner 1.0.4 → 1.0.7

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 (108) hide show
  1. package/dist/cli/init.js +170 -0
  2. package/dist/cli/init.unitTest.js +0 -0
  3. package/dist/cli/lib/addBasePath.js +15 -0
  4. package/dist/cli/lib/addBasePath.unitTest.js +31 -0
  5. package/dist/cli/lib/addExports.js +12 -0
  6. package/dist/cli/lib/addExports.unitTest.js +29 -0
  7. package/dist/cli/lib/applyConfigDefaults.js +41 -0
  8. package/dist/cli/lib/applyConfigDefaults.unitTest.js +25 -0
  9. package/dist/cli/lib/buildDependencyTree.js +32 -0
  10. package/dist/cli/lib/buildDependencyTree.unitTest.js +15 -0
  11. package/dist/cli/lib/buildDependencyTrees.js +34 -0
  12. package/dist/cli/lib/buildDependencyTrees.unitTest.js +17 -0
  13. package/dist/cli/lib/configBeforeAfterFuncs.js +35 -0
  14. package/dist/cli/lib/configBeforeAfterFuncs.unitTest.js +0 -0
  15. package/dist/cli/lib/defaultConfig.js +22 -0
  16. package/dist/cli/lib/defaultConfig.test.js +7 -0
  17. package/dist/cli/lib/doUserSetup.js +30 -0
  18. package/dist/cli/lib/doUserSetup.unitTest.js +39 -0
  19. package/dist/cli/lib/doUserTeardown.js +30 -0
  20. package/dist/cli/lib/doUserTeardown.unitTest.js +39 -0
  21. package/dist/cli/lib/findTestFiles.js +24 -0
  22. package/dist/cli/lib/findTestFiles.unitTest.js +22 -0
  23. package/dist/cli/lib/getAllowedFlags.js +11 -0
  24. package/dist/cli/lib/getAllowedFlags.unitTest.js +20 -0
  25. package/dist/cli/lib/globArgCombine.js +1 -0
  26. package/dist/cli/lib/globArgCombine.unitTest.js +18 -0
  27. package/dist/cli/lib/injectProperties.js +11 -0
  28. package/dist/cli/lib/injectProperties.unitTest.js +75 -0
  29. package/dist/cli/lib/load.js +3 -0
  30. package/dist/cli/lib/load.unitTest.js +7 -0
  31. package/dist/cli/lib/loadConfig.js +21 -0
  32. package/dist/cli/lib/loadConfig.unitTest.js +15 -0
  33. package/dist/cli/lib/loadTestFile.js +75 -0
  34. package/dist/cli/lib/loadTestFile.unitTest.js +45 -0
  35. package/dist/cli/lib/loadTestFileStatic.js +40 -0
  36. package/dist/cli/lib/loadTestFileStatic.unitTest.js +29 -0
  37. package/dist/cli/lib/overrideConsoleLog.js +20 -0
  38. package/dist/cli/lib/overrideConsoleLog.unitTest.js +0 -0
  39. package/dist/cli/lib/parseCommandLineArguments.js +57 -0
  40. package/dist/cli/lib/parseCommandLineArguments.unitTest.js +21 -0
  41. package/dist/cli/lib/parseDescribe.js +88 -0
  42. package/dist/cli/lib/parseDescribe.unitTest.js +17 -0
  43. package/dist/cli/lib/processWatchEvent.js +0 -0
  44. package/dist/cli/lib/processWatchEvent.unitTest.js +7 -0
  45. package/dist/cli/lib/reservedExportKeys.js +1 -0
  46. package/dist/cli/lib/reservedExportKeys.unitTest.js +7 -0
  47. package/dist/cli/lib/runDescribe.js +29 -0
  48. package/dist/cli/lib/runDescribe.old.js +115 -0
  49. package/dist/cli/lib/runDescribe.old.unitTest.js +440 -0
  50. package/dist/cli/lib/runDescribe.unitTest.js +287 -0
  51. package/dist/cli/lib/runDescribeRun.js +59 -0
  52. package/dist/cli/lib/runDescribeRun.unitTest.js +293 -0
  53. package/dist/cli/lib/runIt.js +79 -0
  54. package/dist/cli/lib/runIt.unitTest.js +294 -0
  55. package/dist/cli/lib/runTasks.js +42 -0
  56. package/dist/cli/lib/runTasks.unitTest.js +30 -0
  57. package/dist/cli/lib/runTest-old.js +159 -0
  58. package/dist/cli/lib/runTest-old.unitTest.js +183 -0
  59. package/dist/cli/lib/runTest.js +71 -0
  60. package/dist/cli/lib/runTest.unitTest.js +269 -0
  61. package/dist/cli/lib/runTestFile copy.js +292 -0
  62. package/dist/cli/lib/runTestFile-old.js +348 -0
  63. package/dist/cli/lib/runTestFile.js +105 -0
  64. package/dist/cli/lib/runTestFile.unitTest.js +264 -0
  65. package/dist/cli/lib/runTestFiles.js +141 -0
  66. package/dist/cli/lib/runTestFiles.unitTest.js +147 -0
  67. package/dist/cli/lib/runTests.js +137 -0
  68. package/dist/cli/lib/runTests.unitTest.js +59 -0
  69. package/dist/cli/lib/shouldCaptureConsoleLog.js +24 -0
  70. package/dist/cli/lib/shouldCaptureConsoleLog.unitTest.js +31 -0
  71. package/dist/cli/lib/showTestLoadingError.js +22 -0
  72. package/dist/cli/lib/showTestLoadingError.unitTest.js +25 -0
  73. package/dist/cli/lib/showTestResult.js +87 -0
  74. package/dist/cli/lib/showTestResult.unitTest.js +180 -0
  75. package/dist/cli/lib/timeProfier.js +7 -0
  76. package/dist/cli/lib/validateConfig.js +29 -0
  77. package/dist/cli/lib/validateConfig.unitTest.js +22 -0
  78. package/dist/cli/lib/watchFiles.js +1 -0
  79. package/dist/cli/lib/watchFiles.unitTest.js +48 -0
  80. package/dist/cli/lib/watchFilesAndRunTests.js +2 -0
  81. package/dist/cli/lib/watchFilesAndRunTests.unitTest.js +129 -0
  82. package/dist/cli/lib/watchFilesAndRunTestsChokidar.js +142 -0
  83. package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js +133 -0
  84. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js +162 -0
  85. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js +131 -0
  86. package/dist/cli/lib/watchFilesChokidar.js +56 -0
  87. package/dist/cli/lib/watchFilesChokidar.unitTest.js +85 -0
  88. package/dist/cli/lib/watchFilesNodeWatch.js +42 -0
  89. package/dist/cli/lib/watchFilesNodeWatch.unitTest.js +48 -0
  90. package/dist/cli/once.js +47 -0
  91. package/dist/cli/once.unitTest.js +39 -0
  92. package/dist/cli/watch.js +100 -0
  93. package/dist/cli/watch.unitTest.js +117 -0
  94. package/dist/config.js +7 -0
  95. package/dist/describe-old.js +257 -0
  96. package/dist/describe-old.unitTest.js +21 -0
  97. package/dist/describe.js +24 -0
  98. package/dist/describe.unitTest.js +27 -0
  99. package/dist/exported.eslintrc.cjs +7 -0
  100. package/dist/exported.eslintrc.js +7 -0
  101. package/dist/index.js +1 -0
  102. package/dist/indexNumberToLetters.js +13 -0
  103. package/dist/load.js +3 -0
  104. package/dist/output.js +17 -0
  105. package/dist/testsState.js +4 -0
  106. package/dist/timeProfiling.js +9 -0
  107. package/package.json +3 -2
  108. package/sxy-loader.config.js +10 -0
@@ -0,0 +1,287 @@
1
+ import { applyConfigDefaults } from './applyConfigDefaults.js';
2
+ import { loadTestFile } from './loadTestFile.js';
3
+ import { runDescribe } from './runDescribe.js';
4
+ const defaultConfig = await applyConfigDefaults({}); // const beforeAfterTestFile = 'unitTesting/runTest/beforeAfter.test.js'
5
+ // const beforeAfterTest = loadTestFile(defaultConfig, beforeAfterTestFile)
6
+
7
+ await mochaDescribe('runDescribe() function', async function () {
8
+ await mochaIt('should run an it block that was loaded from a test file', async function () {
9
+ const sampleTestFile = 'unitTesting/runTest/1.test.js';
10
+ const sampleTest = await loadTestFile(defaultConfig, sampleTestFile);
11
+ const sampleDescribe = sampleTest.describes[0];
12
+ const describeResult = await runDescribe(defaultConfig, sampleDescribe);
13
+ await describeResult.should.include.keys(['counter', 'thing', 'success', 'itResults', 'itResultsSummary']);
14
+ await describeResult.success.should.equal(true);
15
+ await describeResult.itResultsSummary.total.should.equal(1);
16
+ await describeResult.itResultsSummary.passes.should.equal(1);
17
+ }); // mochaIt('should return sensible results from a test file without any describes', function() {
18
+ // //const config = applyConfigDefaults({})
19
+ // const sampleTestFile = 'unitTesting/sampletests/blank.test.js'
20
+ // const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
21
+ // const testResult = runTest(defaultConfig, sampleTest)
22
+ // //console.log(testResult)
23
+ // //console.log(testResult.describeResults[0].itResults)
24
+ // //console.log(testResult.describeResults[0].itResultsSummary)
25
+ // testResult.should.include.keys([
26
+ // 'file',
27
+ // 'success',
28
+ // 'describeResults',
29
+ // 'describeResultsSummary'
30
+ // ])
31
+ // chaiExpect(testResult.success).to.be.null
32
+ // //testResult.describeResultsSummary.total.should.equal(1)
33
+ // //testResult.describeResultsSummary.passes.should.equal(1)
34
+ // //testResult.describeResultsSummary.itsTotal.should.equal(1)
35
+ // //testResult.describeResultsSummary.itsPasses.should.equal(1)
36
+ // })
37
+ // mochaIt('should return sensible results from a test file with describes without any its/tests', function() {
38
+ // //const config = applyConfigDefaults({})
39
+ // const sampleTestFile = 'unitTesting/sampletests/describesWithoutTests.test.js'
40
+ // const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
41
+ // const testResult = runTest(defaultConfig, sampleTest)
42
+ // //console.log(testResult)
43
+ // //console.log(testResult.describeResults[0].itResults)
44
+ // //console.log(testResult.describeResults[0].itResultsSummary)
45
+ // testResult.should.include.keys([
46
+ // 'file',
47
+ // 'success',
48
+ // 'describeResults',
49
+ // 'describeResultsSummary'
50
+ // ])
51
+ // chaiExpect(testResult.success).to.be.null
52
+ // testResult.describeResultsSummary.total.should.equal(0)
53
+ // testResult.describeResultsSummary.passes.should.equal(0)
54
+ // testResult.describeResultsSummary.invalid.should.equal(2)
55
+ // testResult.describeResultsSummary.itsTotal.should.equal(0)
56
+ // testResult.describeResultsSummary.itsPasses.should.equal(0)
57
+ // })
58
+ // mochaIt("should run beforeEachFile tasks (before - can't test)", function() {
59
+ // let functionHasRun = false
60
+ // global.beforeEachFileFileHasRun = false
61
+ // const ourConfig = {
62
+ // beforeEachFile: [
63
+ // function() {
64
+ // functionHasRun = true
65
+ // },
66
+ // 'unitTesting/runTest/beforeEachFile.js'
67
+ // ]
68
+ // }
69
+ // const config = applyConfigDefaults(ourConfig)
70
+ // runTest(config, beforeAfterTest)
71
+ // functionHasRun.should.equal(true)
72
+ // global.beforeEachFileFileHasRun.should.equal(true)
73
+ // })
74
+ // mochaIt("should run afterEachFile tasks (after - can't test)", function() {
75
+ // let functionHasRun = false
76
+ // global.afterEachFileFileHasRun = false
77
+ // const ourConfig = {
78
+ // afterEachFile: [
79
+ // function() {
80
+ // functionHasRun = true
81
+ // },
82
+ // 'unitTesting/runTest/afterEachFile.js'
83
+ // ]
84
+ // }
85
+ // const config = applyConfigDefaults(ourConfig)
86
+ // runTest(config, beforeAfterTest)
87
+ // functionHasRun.should.equal(true)
88
+ // global.afterEachFileFileHasRun.should.equal(true)
89
+ // })
90
+ // mochaIt("should run beforeEachDescribe tasks (before - can't test) each describe block", function() {
91
+ // let functionHasRunTimes = 0
92
+ // global.beforeEachDescribeFileHasRun = false
93
+ // const ourConfig = {
94
+ // beforeEachDescribe: [
95
+ // function() {
96
+ // functionHasRunTimes++
97
+ // },
98
+ // 'unitTesting/runTest/beforeEachDescribe.js'
99
+ // ]
100
+ // }
101
+ // const config = applyConfigDefaults(ourConfig)
102
+ // runTest(config, beforeAfterTest)
103
+ // functionHasRunTimes.should.equal(2)
104
+ // global.beforeEachDescribeFileHasRun.should.equal(true)
105
+ // })
106
+ // mochaIt("should run afterEachDescribe tasks (after - can't test) each describe block", function() {
107
+ // let functionHasRunTimes = 0
108
+ // global.afterEachDescribeFileHasRun = false
109
+ // const ourConfig = {
110
+ // afterEachDescribe: [
111
+ // function() {
112
+ // functionHasRunTimes++
113
+ // },
114
+ // 'unitTesting/runTest/afterEachDescribe.js'
115
+ // ]
116
+ // }
117
+ // const config = applyConfigDefaults(ourConfig)
118
+ // runTest(config, beforeAfterTest)
119
+ // functionHasRunTimes.should.equal(2)
120
+ // global.afterEachDescribeFileHasRun.should.equal(true)
121
+ // })
122
+ // mochaIt("should run beforeEachTest tasks (before - can't test) each test/it block", function() {
123
+ // let functionHasRunTimes = 0
124
+ // global.beforeEachTestbeforeEachFileFileHasRun = false
125
+ // const ourConfig = {
126
+ // beforeEachTest: [
127
+ // function() {
128
+ // functionHasRunTimes++
129
+ // },
130
+ // 'unitTesting/runTest/beforeEachTest.js'
131
+ // ]
132
+ // }
133
+ // const config = applyConfigDefaults(ourConfig)
134
+ // runTest(config, beforeAfterTest)
135
+ // functionHasRunTimes.should.equal(3)
136
+ // global.beforeEachTestFileHasRun.should.equal(true)
137
+ // })
138
+ // mochaIt("should run afterEachTest tasks (after - can't test) each test/it block", function() {
139
+ // let functionHasRunTimes = 0
140
+ // global.afterEachTestFileFileHasRun = false
141
+ // const ourConfig = {
142
+ // afterEachTest: [
143
+ // function() {
144
+ // functionHasRunTimes++
145
+ // },
146
+ // 'unitTesting/runTest/afterEachTest.js'
147
+ // ]
148
+ // }
149
+ // const config = applyConfigDefaults(ourConfig)
150
+ // runTest(config, beforeAfterTest)
151
+ // functionHasRunTimes.should.equal(3)
152
+ // global.afterEachTestFileHasRun.should.equal(true)
153
+ // })
154
+ // // exports provision to test file
155
+ // // current beforeEachFile exports aren't provided
156
+ // // perhaps extend sxy-loader to allow this
157
+ // mochaIt("should pass exported/returned data from beforeEachDescribe tasks", function() {
158
+ // const testFile = 'unitTesting/runTest/beforeEachDescribe.test.js'
159
+ // const test = loadTestFile(defaultConfig, testFile)
160
+ // const ourConfig = {
161
+ // beforeEachDescribe: [
162
+ // function() {
163
+ // return { functionThing : 'foo' }
164
+ // },
165
+ // 'unitTesting/runTest/beforeEachDescribeExport.js'
166
+ // ]
167
+ // }
168
+ // const config = applyConfigDefaults(ourConfig)
169
+ // runTest(config, test)
170
+ // global.functionThing.should.equal('foo')
171
+ // global.fileThing.should.equal('bar')
172
+ // })
173
+ // mochaIt("should pass exported/returned data from beforeEachTest tasks", function() {
174
+ // const testFile = 'unitTesting/runTest/beforeEachTest.test.js'
175
+ // const test = loadTestFile(defaultConfig, testFile)
176
+ // const ourConfig = {
177
+ // beforeEachTest: [
178
+ // function() {
179
+ // return { functionThing : 'foo' }
180
+ // },
181
+ // 'unitTesting/runTest/beforeEachTestExport.js'
182
+ // ]
183
+ // }
184
+ // const config = applyConfigDefaults(ourConfig)
185
+ // runTest(config, test)
186
+ // global.functionThing.should.equal('foo')
187
+ // global.fileThing.should.equal('bar')
188
+ // })
189
+ // // exports pass through
190
+ // mochaIt("beforeEachFile exports are passed through to afterEachFile", function() {
191
+ // // don't try to reload test, fails due to module caching
192
+ // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
193
+ // //const test = loadTestFile(defaultConfig, testFile)
194
+ // let exports
195
+ // const ourConfig = {
196
+ // beforeEachFile: [
197
+ // function() {
198
+ // return { functionThing : 'foo' }
199
+ // },
200
+ // 'unitTesting/runTest/beforeEachExport.js'
201
+ // ],
202
+ // afterEachFile: [
203
+ // function(theExports) {
204
+ // theExports.should.have.keys(['functionThing', 'fileThing'])
205
+ // exports = theExports
206
+ // },
207
+ // ]
208
+ // }
209
+ // const config = applyConfigDefaults(ourConfig)
210
+ // runTest(config, beforeAfterTest)
211
+ // exports.functionThing.should.equal('foo')
212
+ // exports.fileThing.should.equal('bar')
213
+ // })
214
+ // mochaIt("beforeEachDescribe exports are passed through to afterEachDescribe", function() {
215
+ // // don't try to reload test, fails due to module caching
216
+ // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
217
+ // //const test = loadTestFile(defaultConfig, testFile)
218
+ // let exports
219
+ // const ourConfig = {
220
+ // beforeEachDescribe: [
221
+ // function() {
222
+ // return { functionThing : 'foo' }
223
+ // },
224
+ // 'unitTesting/runTest/beforeEachExport.js'
225
+ // ],
226
+ // afterEachDescribe: [
227
+ // function(theExports) {
228
+ // exports = theExports
229
+ // },
230
+ // ]
231
+ // }
232
+ // const config = applyConfigDefaults(ourConfig)
233
+ // runTest(config, beforeAfterTest)
234
+ // //console.log('exports', exports)
235
+ // exports.functionThing.should.equal('foo')
236
+ // exports.fileThing.should.equal('bar')
237
+ // })
238
+ // mochaIt("beforeEachTest exports are passed through to afterEachTest", function() {
239
+ // // don't try to reload test, fails due to module caching
240
+ // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
241
+ // //const test = loadTestFile(defaultConfig, testFile)
242
+ // let exports
243
+ // const ourConfig = {
244
+ // beforeEachTest: [
245
+ // function() {
246
+ // return { functionThing : 'foo' }
247
+ // },
248
+ // 'unitTesting/runTest/beforeEachExport.js'
249
+ // ],
250
+ // afterEachTest: [
251
+ // function(theExports) {
252
+ // exports = theExports
253
+ // },
254
+ // ]
255
+ // }
256
+ // const config = applyConfigDefaults(ourConfig)
257
+ // runTest(config, beforeAfterTest)
258
+ // //console.log('exports', exports)
259
+ // exports.functionThing.should.equal('foo')
260
+ // exports.fileThing.should.equal('bar')
261
+ // })
262
+ // mochaIt("we can run code beforeEachTest and afterEachTest from within the test file", function() {
263
+ // // don't try to reload test, fails due to module caching
264
+ // const testFile = 'unitTesting/runTest/internalBeforeAfterEachTest.test.js'
265
+ // const test = loadTestFile(defaultConfig, testFile)
266
+ // const config = applyConfigDefaults({})
267
+ // global.internalBeforeEachTestRanNTimes = 0
268
+ // global.internalAfterEachTestRanNTimes = 0
269
+ // runTest(config, test)
270
+ // global.internalBeforeAfterEachTest_test1Valid.should.equal(true)
271
+ // global.internalBeforeAfterEachTest_test2Valid.should.equal(true)
272
+ // global.internalBeforeAfterEachTest_test3Valid.should.equal(true)
273
+ // global.internalBeforeEachTestRanNTimes.should.equal(3)
274
+ // global.internalAfterEachTestRanNTimes.should.equal(3)
275
+ // })
276
+ // mochaIt("we can run code afterDescribe from within descibe in the test file", function() {
277
+ // // don't try to reload test, fails due to module caching
278
+ // const testFile = 'unitTesting/runTest/internalAfterDescribeTest.test.js'
279
+ // const test = loadTestFile(defaultConfig, testFile)
280
+ // const config = applyConfigDefaults({})
281
+ // global.internalAfterDescribeRanNTimes = 0
282
+ // runTest(config, test)
283
+ // //global.internalAfterDescribe_test1Valid.should.equal(true)
284
+ // //global.internalAfterDescribe_test2Valid.should.equal(true)
285
+ // global.internalAfterDescribeRanNTimes.should.equal(2)
286
+ // })
287
+ });
@@ -0,0 +1,59 @@
1
+ import { timeProfileAsync } from './timeProfier.js';
2
+ import { runTasks } from './runTasks.js';
3
+ import { addExports } from './addExports.js';
4
+ import { debug } from '../../output.js';
5
+ import { runIt } from './runIt.js';
6
+ export async function runDescribeRun(config, describe, parsedIts) {
7
+ return await timeProfileAsync(`run describe, run its ${describe.thing}`, async () => {
8
+ // const beforeEachDescribeExports = {}
9
+ // configBeforeEachDescribe(config, beforeEachDescribeExports)
10
+ const {
11
+ its,
12
+ beforeDescribeExports,
13
+ afterDescribeFunc,
14
+ beforeEachTestFunc,
15
+ afterEachTestFunc
16
+ } = parsedIts;
17
+ const itResults = [];
18
+
19
+ for (const it of its) {
20
+ await itResults.push(await runIt(config, it, beforeEachTestFunc, afterEachTestFunc));
21
+ }
22
+
23
+ const itResultsSummary = {
24
+ total: 0,
25
+ passes: 0
26
+ };
27
+
28
+ for (const itResult of itResults) {
29
+ itResultsSummary.total += +(itResult.success !== null);
30
+ itResultsSummary.passes += +itResult.success;
31
+ }
32
+
33
+ await debug('itResultsSummary', itResultsSummary);
34
+ const describeResult = {
35
+ counter: describe.counter,
36
+ thing: describe.thing,
37
+ success: itResultsSummary.total > 0 ? itResultsSummary.passes === itResultsSummary.total : null,
38
+ itResults,
39
+ itResultsSummary
40
+ }; // run after
41
+
42
+ if (typeof afterDescribeFunc === 'function') await afterDescribeFunc();
43
+ await configAfterEachDescribe(config, beforeDescribeExports);
44
+ return describeResult;
45
+ });
46
+ }
47
+
48
+ async function configBeforeEachDescribe(config, exports) {
49
+ if (config.beforeEachDescribe) {
50
+ const theExports = await runTasks(config.beforeEachDescribe, undefined);
51
+ await addExports(exports, theExports);
52
+ }
53
+ }
54
+
55
+ async function configAfterEachDescribe(config, exports) {
56
+ if (config.afterEachDescribe) {
57
+ await runTasks(config.afterEachDescribe, exports);
58
+ }
59
+ }
@@ -0,0 +1,293 @@
1
+ import { applyConfigDefaults } from './applyConfigDefaults.js';
2
+ import { loadTestFile } from './loadTestFile.js';
3
+ import { runDescribeRun } from './runDescribeRun.js';
4
+ import { parseDescribe } from './parseDescribe.js';
5
+ const defaultConfig = await applyConfigDefaults({}); // const beforeAfterTestFile = 'unitTesting/runTest/beforeAfter.test.js'
6
+ // const beforeAfterTest = loadTestFile(defaultConfig, beforeAfterTestFile)
7
+
8
+ await mochaDescribe('runDescribe() function', async function () {
9
+ await mochaIt('should run an it block that was loaded from a test file', async function () {
10
+ const sampleTestFile = 'unitTesting/runTest/1.test.js';
11
+ const sampleTest = await loadTestFile(defaultConfig, sampleTestFile);
12
+ const sampleDescribe = sampleTest.describes[0];
13
+ const parsedDescribe = await parseDescribe(defaultConfig, sampleDescribe); //console.log('sample describe', sampleDescribe)
14
+
15
+ const describeResult = await runDescribeRun(defaultConfig, sampleDescribe, parsedDescribe); //console.log('describe result', describeResult)
16
+ //console.log(testResult.describeResults[0].itResults)
17
+ //console.log(testResult.describeResults[0].itResultsSummary)
18
+
19
+ await describeResult.should.include.keys(['counter', 'thing', 'success', 'itResults', 'itResultsSummary']);
20
+ await describeResult.success.should.equal(true);
21
+ await describeResult.itResultsSummary.total.should.equal(1);
22
+ await describeResult.itResultsSummary.passes.should.equal(1);
23
+ }); // mochaIt('should return sensible results from a test file without any describes', function() {
24
+ // //const config = applyConfigDefaults({})
25
+ // const sampleTestFile = 'unitTesting/sampletests/blank.test.js'
26
+ // const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
27
+ // const testResult = runTest(defaultConfig, sampleTest)
28
+ // //console.log(testResult)
29
+ // //console.log(testResult.describeResults[0].itResults)
30
+ // //console.log(testResult.describeResults[0].itResultsSummary)
31
+ // testResult.should.include.keys([
32
+ // 'file',
33
+ // 'success',
34
+ // 'describeResults',
35
+ // 'describeResultsSummary'
36
+ // ])
37
+ // chaiExpect(testResult.success).to.be.null
38
+ // //testResult.describeResultsSummary.total.should.equal(1)
39
+ // //testResult.describeResultsSummary.passes.should.equal(1)
40
+ // //testResult.describeResultsSummary.itsTotal.should.equal(1)
41
+ // //testResult.describeResultsSummary.itsPasses.should.equal(1)
42
+ // })
43
+ // mochaIt('should return sensible results from a test file with describes without any its/tests', function() {
44
+ // //const config = applyConfigDefaults({})
45
+ // const sampleTestFile = 'unitTesting/sampletests/describesWithoutTests.test.js'
46
+ // const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
47
+ // const testResult = runTest(defaultConfig, sampleTest)
48
+ // //console.log(testResult)
49
+ // //console.log(testResult.describeResults[0].itResults)
50
+ // //console.log(testResult.describeResults[0].itResultsSummary)
51
+ // testResult.should.include.keys([
52
+ // 'file',
53
+ // 'success',
54
+ // 'describeResults',
55
+ // 'describeResultsSummary'
56
+ // ])
57
+ // chaiExpect(testResult.success).to.be.null
58
+ // testResult.describeResultsSummary.total.should.equal(0)
59
+ // testResult.describeResultsSummary.passes.should.equal(0)
60
+ // testResult.describeResultsSummary.invalid.should.equal(2)
61
+ // testResult.describeResultsSummary.itsTotal.should.equal(0)
62
+ // testResult.describeResultsSummary.itsPasses.should.equal(0)
63
+ // })
64
+ // mochaIt("should run beforeEachFile tasks (before - can't test)", function() {
65
+ // let functionHasRun = false
66
+ // global.beforeEachFileFileHasRun = false
67
+ // const ourConfig = {
68
+ // beforeEachFile: [
69
+ // function() {
70
+ // functionHasRun = true
71
+ // },
72
+ // 'unitTesting/runTest/beforeEachFile.js'
73
+ // ]
74
+ // }
75
+ // const config = applyConfigDefaults(ourConfig)
76
+ // runTest(config, beforeAfterTest)
77
+ // functionHasRun.should.equal(true)
78
+ // global.beforeEachFileFileHasRun.should.equal(true)
79
+ // })
80
+ // mochaIt("should run afterEachFile tasks (after - can't test)", function() {
81
+ // let functionHasRun = false
82
+ // global.afterEachFileFileHasRun = false
83
+ // const ourConfig = {
84
+ // afterEachFile: [
85
+ // function() {
86
+ // functionHasRun = true
87
+ // },
88
+ // 'unitTesting/runTest/afterEachFile.js'
89
+ // ]
90
+ // }
91
+ // const config = applyConfigDefaults(ourConfig)
92
+ // runTest(config, beforeAfterTest)
93
+ // functionHasRun.should.equal(true)
94
+ // global.afterEachFileFileHasRun.should.equal(true)
95
+ // })
96
+ // mochaIt("should run beforeEachDescribe tasks (before - can't test) each describe block", function() {
97
+ // let functionHasRunTimes = 0
98
+ // global.beforeEachDescribeFileHasRun = false
99
+ // const ourConfig = {
100
+ // beforeEachDescribe: [
101
+ // function() {
102
+ // functionHasRunTimes++
103
+ // },
104
+ // 'unitTesting/runTest/beforeEachDescribe.js'
105
+ // ]
106
+ // }
107
+ // const config = applyConfigDefaults(ourConfig)
108
+ // runTest(config, beforeAfterTest)
109
+ // functionHasRunTimes.should.equal(2)
110
+ // global.beforeEachDescribeFileHasRun.should.equal(true)
111
+ // })
112
+ // mochaIt("should run afterEachDescribe tasks (after - can't test) each describe block", function() {
113
+ // let functionHasRunTimes = 0
114
+ // global.afterEachDescribeFileHasRun = false
115
+ // const ourConfig = {
116
+ // afterEachDescribe: [
117
+ // function() {
118
+ // functionHasRunTimes++
119
+ // },
120
+ // 'unitTesting/runTest/afterEachDescribe.js'
121
+ // ]
122
+ // }
123
+ // const config = applyConfigDefaults(ourConfig)
124
+ // runTest(config, beforeAfterTest)
125
+ // functionHasRunTimes.should.equal(2)
126
+ // global.afterEachDescribeFileHasRun.should.equal(true)
127
+ // })
128
+ // mochaIt("should run beforeEachTest tasks (before - can't test) each test/it block", function() {
129
+ // let functionHasRunTimes = 0
130
+ // global.beforeEachTestbeforeEachFileFileHasRun = false
131
+ // const ourConfig = {
132
+ // beforeEachTest: [
133
+ // function() {
134
+ // functionHasRunTimes++
135
+ // },
136
+ // 'unitTesting/runTest/beforeEachTest.js'
137
+ // ]
138
+ // }
139
+ // const config = applyConfigDefaults(ourConfig)
140
+ // runTest(config, beforeAfterTest)
141
+ // functionHasRunTimes.should.equal(3)
142
+ // global.beforeEachTestFileHasRun.should.equal(true)
143
+ // })
144
+ // mochaIt("should run afterEachTest tasks (after - can't test) each test/it block", function() {
145
+ // let functionHasRunTimes = 0
146
+ // global.afterEachTestFileFileHasRun = false
147
+ // const ourConfig = {
148
+ // afterEachTest: [
149
+ // function() {
150
+ // functionHasRunTimes++
151
+ // },
152
+ // 'unitTesting/runTest/afterEachTest.js'
153
+ // ]
154
+ // }
155
+ // const config = applyConfigDefaults(ourConfig)
156
+ // runTest(config, beforeAfterTest)
157
+ // functionHasRunTimes.should.equal(3)
158
+ // global.afterEachTestFileHasRun.should.equal(true)
159
+ // })
160
+ // // exports provision to test file
161
+ // // current beforeEachFile exports aren't provided
162
+ // // perhaps extend sxy-loader to allow this
163
+ // mochaIt("should pass exported/returned data from beforeEachDescribe tasks", function() {
164
+ // const testFile = 'unitTesting/runTest/beforeEachDescribe.test.js'
165
+ // const test = loadTestFile(defaultConfig, testFile)
166
+ // const ourConfig = {
167
+ // beforeEachDescribe: [
168
+ // function() {
169
+ // return { functionThing : 'foo' }
170
+ // },
171
+ // 'unitTesting/runTest/beforeEachDescribeExport.js'
172
+ // ]
173
+ // }
174
+ // const config = applyConfigDefaults(ourConfig)
175
+ // runTest(config, test)
176
+ // global.functionThing.should.equal('foo')
177
+ // global.fileThing.should.equal('bar')
178
+ // })
179
+ // mochaIt("should pass exported/returned data from beforeEachTest tasks", function() {
180
+ // const testFile = 'unitTesting/runTest/beforeEachTest.test.js'
181
+ // const test = loadTestFile(defaultConfig, testFile)
182
+ // const ourConfig = {
183
+ // beforeEachTest: [
184
+ // function() {
185
+ // return { functionThing : 'foo' }
186
+ // },
187
+ // 'unitTesting/runTest/beforeEachTestExport.js'
188
+ // ]
189
+ // }
190
+ // const config = applyConfigDefaults(ourConfig)
191
+ // runTest(config, test)
192
+ // global.functionThing.should.equal('foo')
193
+ // global.fileThing.should.equal('bar')
194
+ // })
195
+ // // exports pass through
196
+ // mochaIt("beforeEachFile exports are passed through to afterEachFile", function() {
197
+ // // don't try to reload test, fails due to module caching
198
+ // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
199
+ // //const test = loadTestFile(defaultConfig, testFile)
200
+ // let exports
201
+ // const ourConfig = {
202
+ // beforeEachFile: [
203
+ // function() {
204
+ // return { functionThing : 'foo' }
205
+ // },
206
+ // 'unitTesting/runTest/beforeEachExport.js'
207
+ // ],
208
+ // afterEachFile: [
209
+ // function(theExports) {
210
+ // theExports.should.have.keys(['functionThing', 'fileThing'])
211
+ // exports = theExports
212
+ // },
213
+ // ]
214
+ // }
215
+ // const config = applyConfigDefaults(ourConfig)
216
+ // runTest(config, beforeAfterTest)
217
+ // exports.functionThing.should.equal('foo')
218
+ // exports.fileThing.should.equal('bar')
219
+ // })
220
+ // mochaIt("beforeEachDescribe exports are passed through to afterEachDescribe", function() {
221
+ // // don't try to reload test, fails due to module caching
222
+ // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
223
+ // //const test = loadTestFile(defaultConfig, testFile)
224
+ // let exports
225
+ // const ourConfig = {
226
+ // beforeEachDescribe: [
227
+ // function() {
228
+ // return { functionThing : 'foo' }
229
+ // },
230
+ // 'unitTesting/runTest/beforeEachExport.js'
231
+ // ],
232
+ // afterEachDescribe: [
233
+ // function(theExports) {
234
+ // exports = theExports
235
+ // },
236
+ // ]
237
+ // }
238
+ // const config = applyConfigDefaults(ourConfig)
239
+ // runTest(config, beforeAfterTest)
240
+ // //console.log('exports', exports)
241
+ // exports.functionThing.should.equal('foo')
242
+ // exports.fileThing.should.equal('bar')
243
+ // })
244
+ // mochaIt("beforeEachTest exports are passed through to afterEachTest", function() {
245
+ // // don't try to reload test, fails due to module caching
246
+ // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
247
+ // //const test = loadTestFile(defaultConfig, testFile)
248
+ // let exports
249
+ // const ourConfig = {
250
+ // beforeEachTest: [
251
+ // function() {
252
+ // return { functionThing : 'foo' }
253
+ // },
254
+ // 'unitTesting/runTest/beforeEachExport.js'
255
+ // ],
256
+ // afterEachTest: [
257
+ // function(theExports) {
258
+ // exports = theExports
259
+ // },
260
+ // ]
261
+ // }
262
+ // const config = applyConfigDefaults(ourConfig)
263
+ // runTest(config, beforeAfterTest)
264
+ // //console.log('exports', exports)
265
+ // exports.functionThing.should.equal('foo')
266
+ // exports.fileThing.should.equal('bar')
267
+ // })
268
+ // mochaIt("we can run code beforeEachTest and afterEachTest from within the test file", function() {
269
+ // // don't try to reload test, fails due to module caching
270
+ // const testFile = 'unitTesting/runTest/internalBeforeAfterEachTest.test.js'
271
+ // const test = loadTestFile(defaultConfig, testFile)
272
+ // const config = applyConfigDefaults({})
273
+ // global.internalBeforeEachTestRanNTimes = 0
274
+ // global.internalAfterEachTestRanNTimes = 0
275
+ // runTest(config, test)
276
+ // global.internalBeforeAfterEachTest_test1Valid.should.equal(true)
277
+ // global.internalBeforeAfterEachTest_test2Valid.should.equal(true)
278
+ // global.internalBeforeAfterEachTest_test3Valid.should.equal(true)
279
+ // global.internalBeforeEachTestRanNTimes.should.equal(3)
280
+ // global.internalAfterEachTestRanNTimes.should.equal(3)
281
+ // })
282
+ // mochaIt("we can run code afterDescribe from within descibe in the test file", function() {
283
+ // // don't try to reload test, fails due to module caching
284
+ // const testFile = 'unitTesting/runTest/internalAfterDescribeTest.test.js'
285
+ // const test = loadTestFile(defaultConfig, testFile)
286
+ // const config = applyConfigDefaults({})
287
+ // global.internalAfterDescribeRanNTimes = 0
288
+ // runTest(config, test)
289
+ // //global.internalAfterDescribe_test1Valid.should.equal(true)
290
+ // //global.internalAfterDescribe_test2Valid.should.equal(true)
291
+ // global.internalAfterDescribeRanNTimes.should.equal(2)
292
+ // })
293
+ });