sxy-test-runner 1.4.4 → 2.0.0

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 (287) hide show
  1. package/dist/cli/index.js +24 -22
  2. package/dist/cli/init.js +41 -91
  3. package/dist/cli/init.js.map +1 -1
  4. package/dist/cli/lib/addBasePath.d.ts.map +1 -1
  5. package/dist/cli/lib/addBasePath.js +12 -14
  6. package/dist/cli/lib/addBasePath.js.map +1 -1
  7. package/dist/cli/lib/addBasePath.unitTest.d.ts +2 -0
  8. package/dist/cli/lib/addBasePath.unitTest.d.ts.map +1 -0
  9. package/dist/cli/lib/addBasePath.unitTest.js +51 -29
  10. package/dist/cli/lib/addBasePath.unitTest.js.map +1 -0
  11. package/dist/cli/lib/addExports.js +13 -11
  12. package/dist/cli/lib/addExports.unitTest.d.ts +2 -0
  13. package/dist/cli/lib/addExports.unitTest.d.ts.map +1 -0
  14. package/dist/cli/lib/addExports.unitTest.js +15 -30
  15. package/dist/cli/lib/addExports.unitTest.js.map +1 -0
  16. package/dist/cli/lib/applyConfigDefaults.js +6 -42
  17. package/dist/cli/lib/applyConfigDefaults.js.map +1 -1
  18. package/dist/cli/lib/applyConfigDefaults.unitTest.d.ts +2 -0
  19. package/dist/cli/lib/applyConfigDefaults.unitTest.d.ts.map +1 -0
  20. package/dist/cli/lib/applyConfigDefaults.unitTest.js +19 -27
  21. package/dist/cli/lib/applyConfigDefaults.unitTest.js.map +1 -0
  22. package/dist/cli/lib/buildDependencyTree.js +23 -34
  23. package/dist/cli/lib/buildDependencyTree.js.map +1 -1
  24. package/dist/cli/lib/buildDependencyTree.unitTest.d.ts +2 -0
  25. package/dist/cli/lib/buildDependencyTree.unitTest.d.ts.map +1 -0
  26. package/dist/cli/lib/buildDependencyTree.unitTest.js +13 -11
  27. package/dist/cli/lib/buildDependencyTree.unitTest.js.map +1 -0
  28. package/dist/cli/lib/buildDependencyTrees.js +15 -34
  29. package/dist/cli/lib/buildDependencyTrees.js.map +1 -1
  30. package/dist/cli/lib/buildDependencyTrees.unitTest.d.ts +2 -0
  31. package/dist/cli/lib/buildDependencyTrees.unitTest.d.ts.map +1 -0
  32. package/dist/cli/lib/buildDependencyTrees.unitTest.js +18 -14
  33. package/dist/cli/lib/buildDependencyTrees.unitTest.js.map +1 -0
  34. package/dist/cli/lib/defaultConfig.js +23 -21
  35. package/dist/cli/lib/defaultConfig.unitTest.d.ts +2 -0
  36. package/dist/cli/lib/defaultConfig.unitTest.d.ts.map +1 -0
  37. package/dist/cli/lib/defaultConfig.unitTest.js +7 -0
  38. package/dist/cli/lib/defaultConfig.unitTest.js.map +1 -0
  39. package/dist/cli/lib/doUserSetup.d.ts +1 -1
  40. package/dist/cli/lib/doUserSetup.d.ts.map +1 -1
  41. package/dist/cli/lib/doUserSetup.js +20 -23
  42. package/dist/cli/lib/doUserSetup.js.map +1 -1
  43. package/dist/cli/lib/doUserSetup.unitTest.d.ts +7 -0
  44. package/dist/cli/lib/doUserSetup.unitTest.d.ts.map +1 -0
  45. package/dist/cli/lib/doUserSetup.unitTest.js +41 -36
  46. package/dist/cli/lib/doUserSetup.unitTest.js.map +1 -0
  47. package/dist/cli/lib/doUserTeardown.d.ts +1 -1
  48. package/dist/cli/lib/doUserTeardown.d.ts.map +1 -1
  49. package/dist/cli/lib/doUserTeardown.js +21 -23
  50. package/dist/cli/lib/doUserTeardown.js.map +1 -1
  51. package/dist/cli/lib/doUserTeardown.unitTest.d.ts +7 -0
  52. package/dist/cli/lib/doUserTeardown.unitTest.d.ts.map +1 -0
  53. package/dist/cli/lib/doUserTeardown.unitTest.js +41 -36
  54. package/dist/cli/lib/doUserTeardown.unitTest.js.map +1 -0
  55. package/dist/cli/lib/findTestFiles.d.ts.map +1 -1
  56. package/dist/cli/lib/findTestFiles.js +16 -24
  57. package/dist/cli/lib/findTestFiles.js.map +1 -1
  58. package/dist/cli/lib/findTestFiles.unitTest.d.ts +2 -0
  59. package/dist/cli/lib/findTestFiles.unitTest.d.ts.map +1 -0
  60. package/dist/cli/lib/findTestFiles.unitTest.js +19 -19
  61. package/dist/cli/lib/findTestFiles.unitTest.js.map +1 -0
  62. package/dist/cli/lib/getAllowedFlags.js +10 -8
  63. package/dist/cli/lib/getAllowedFlags.unitTest.d.ts +2 -0
  64. package/dist/cli/lib/getAllowedFlags.unitTest.d.ts.map +1 -0
  65. package/dist/cli/lib/getAllowedFlags.unitTest.js +22 -21
  66. package/dist/cli/lib/getAllowedFlags.unitTest.js.map +1 -0
  67. package/dist/cli/lib/globArgCombine.js +8 -1
  68. package/dist/cli/lib/globArgCombine.unitTest.d.ts +2 -0
  69. package/dist/cli/lib/globArgCombine.unitTest.d.ts.map +1 -0
  70. package/dist/cli/lib/globArgCombine.unitTest.js +19 -18
  71. package/dist/cli/lib/globArgCombine.unitTest.js.map +1 -0
  72. package/dist/cli/lib/injectProperties.d.ts.map +1 -1
  73. package/dist/cli/lib/injectProperties.js +10 -10
  74. package/dist/cli/lib/injectProperties.js.map +1 -1
  75. package/dist/cli/lib/injectProperties.unitTest.d.ts +2 -0
  76. package/dist/cli/lib/injectProperties.unitTest.d.ts.map +1 -0
  77. package/dist/cli/lib/injectProperties.unitTest.js +19 -81
  78. package/dist/cli/lib/injectProperties.unitTest.js.map +1 -0
  79. package/dist/cli/lib/loadConfig.js +14 -18
  80. package/dist/cli/lib/loadConfig.js.map +1 -1
  81. package/dist/cli/lib/loadConfig.unitTest.d.ts +2 -0
  82. package/dist/cli/lib/loadConfig.unitTest.d.ts.map +1 -0
  83. package/dist/cli/lib/loadConfig.unitTest.js +15 -15
  84. package/dist/cli/lib/loadConfig.unitTest.js.map +1 -0
  85. package/dist/cli/lib/loadTestFile.js +48 -78
  86. package/dist/cli/lib/loadTestFile.js.map +1 -1
  87. package/dist/cli/lib/loadTestFile.unitTest.d.ts +2 -0
  88. package/dist/cli/lib/loadTestFile.unitTest.d.ts.map +1 -0
  89. package/dist/cli/lib/loadTestFile.unitTest.js +12 -49
  90. package/dist/cli/lib/loadTestFile.unitTest.js.map +1 -0
  91. package/dist/cli/lib/parseCommandLineArguments.js +48 -42
  92. package/dist/cli/lib/parseCommandLineArguments.unitTest.d.ts +2 -0
  93. package/dist/cli/lib/parseCommandLineArguments.unitTest.d.ts.map +1 -0
  94. package/dist/cli/lib/parseCommandLineArguments.unitTest.js +22 -24
  95. package/dist/cli/lib/parseCommandLineArguments.unitTest.js.map +1 -0
  96. package/dist/cli/lib/parseDescribe.d.ts.map +1 -1
  97. package/dist/cli/lib/parseDescribe.js +67 -81
  98. package/dist/cli/lib/parseDescribe.js.map +1 -1
  99. package/dist/cli/lib/parseDescribe.unitTest.d.ts +2 -0
  100. package/dist/cli/lib/parseDescribe.unitTest.d.ts.map +1 -0
  101. package/dist/cli/lib/parseDescribe.unitTest.js +20 -18
  102. package/dist/cli/lib/parseDescribe.unitTest.js.map +1 -0
  103. package/dist/cli/lib/reservedExportKeys.d.ts +2 -0
  104. package/dist/cli/lib/reservedExportKeys.d.ts.map +1 -0
  105. package/dist/cli/lib/reservedExportKeys.js +12 -1
  106. package/dist/cli/lib/reservedExportKeys.js.map +1 -0
  107. package/dist/cli/lib/reservedExportKeys.unitTest.d.ts +2 -0
  108. package/dist/cli/lib/reservedExportKeys.unitTest.d.ts.map +1 -0
  109. package/dist/cli/lib/reservedExportKeys.unitTest.js +6 -8
  110. package/dist/cli/lib/reservedExportKeys.unitTest.js.map +1 -0
  111. package/dist/cli/lib/runDescribe.d.ts.map +1 -1
  112. package/dist/cli/lib/runDescribe.js +39 -39
  113. package/dist/cli/lib/runDescribe.js.map +1 -1
  114. package/dist/cli/lib/runDescribe.unitTest.d.ts +2 -0
  115. package/dist/cli/lib/runDescribe.unitTest.d.ts.map +1 -0
  116. package/dist/cli/lib/runDescribe.unitTest.js +22 -402
  117. package/dist/cli/lib/runDescribe.unitTest.js.map +1 -0
  118. package/dist/cli/lib/runDescribeRun.js +34 -49
  119. package/dist/cli/lib/runDescribeRun.js.map +1 -1
  120. package/dist/cli/lib/runDescribeRun.unitTest.d.ts +2 -0
  121. package/dist/cli/lib/runDescribeRun.unitTest.d.ts.map +1 -0
  122. package/dist/cli/lib/runDescribeRun.unitTest.js +44 -410
  123. package/dist/cli/lib/runDescribeRun.unitTest.js.map +1 -0
  124. package/dist/cli/lib/runIt.d.ts +1 -1
  125. package/dist/cli/lib/runIt.d.ts.map +1 -1
  126. package/dist/cli/lib/runIt.js +59 -69
  127. package/dist/cli/lib/runIt.js.map +1 -1
  128. package/dist/cli/lib/runIt.unitTest.d.ts +2 -0
  129. package/dist/cli/lib/runIt.unitTest.d.ts.map +1 -0
  130. package/dist/cli/lib/runIt.unitTest.js +73 -410
  131. package/dist/cli/lib/runIt.unitTest.js.map +1 -0
  132. package/dist/cli/lib/runTasks.d.ts +1 -1
  133. package/dist/cli/lib/runTasks.d.ts.map +1 -1
  134. package/dist/cli/lib/runTasks.js +28 -31
  135. package/dist/cli/lib/runTasks.js.map +1 -1
  136. package/dist/cli/lib/runTasks.unitTest.d.ts +5 -0
  137. package/dist/cli/lib/runTasks.unitTest.d.ts.map +1 -0
  138. package/dist/cli/lib/runTasks.unitTest.js +35 -31
  139. package/dist/cli/lib/runTasks.unitTest.js.map +1 -0
  140. package/dist/cli/lib/runTest.js +54 -66
  141. package/dist/cli/lib/runTest.js.map +1 -1
  142. package/dist/cli/lib/runTest.unitTest.d.ts +20 -0
  143. package/dist/cli/lib/runTest.unitTest.d.ts.map +1 -0
  144. package/dist/cli/lib/runTest.unitTest.js +274 -289
  145. package/dist/cli/lib/runTest.unitTest.js.map +1 -0
  146. package/dist/cli/lib/runTests.d.ts.map +1 -1
  147. package/dist/cli/lib/runTests.js +123 -141
  148. package/dist/cli/lib/runTests.js.map +1 -1
  149. package/dist/cli/lib/runTests.unitTest.d.ts +6 -0
  150. package/dist/cli/lib/runTests.unitTest.d.ts.map +1 -0
  151. package/dist/cli/lib/runTests.unitTest.js +48 -61
  152. package/dist/cli/lib/runTests.unitTest.js.map +1 -0
  153. package/dist/cli/lib/showTestLoadingError.js +22 -33
  154. package/dist/cli/lib/showTestLoadingError.js.map +1 -1
  155. package/dist/cli/lib/showTestLoadingError.unitTest.d.ts +2 -0
  156. package/dist/cli/lib/showTestLoadingError.unitTest.d.ts.map +1 -0
  157. package/dist/cli/lib/showTestLoadingError.unitTest.js +16 -24
  158. package/dist/cli/lib/showTestLoadingError.unitTest.js.map +1 -0
  159. package/dist/cli/lib/showTestResult.js +88 -88
  160. package/dist/cli/lib/showTestResult.js.map +1 -1
  161. package/dist/cli/lib/showTestResult.unitTest.d.ts +2 -0
  162. package/dist/cli/lib/showTestResult.unitTest.d.ts.map +1 -0
  163. package/dist/cli/lib/showTestResult.unitTest.js +176 -184
  164. package/dist/cli/lib/showTestResult.unitTest.js.map +1 -0
  165. package/dist/cli/lib/testHelpers/makeCustomOut.d.ts +7 -0
  166. package/dist/cli/lib/testHelpers/makeCustomOut.d.ts.map +1 -0
  167. package/dist/cli/lib/testHelpers/makeCustomOut.js +10 -0
  168. package/dist/cli/lib/testHelpers/makeCustomOut.js.map +1 -0
  169. package/dist/cli/lib/timeProfier.js +4 -6
  170. package/dist/cli/lib/timeProfier.js.map +1 -1
  171. package/dist/cli/lib/validateConfig.js +21 -24
  172. package/dist/cli/lib/validateConfig.unitTest.d.ts +2 -0
  173. package/dist/cli/lib/validateConfig.unitTest.d.ts.map +1 -0
  174. package/dist/cli/lib/validateConfig.unitTest.js +17 -18
  175. package/dist/cli/lib/validateConfig.unitTest.js.map +1 -0
  176. package/dist/cli/lib/{watchFiles.js → watchFiles.d.ts} +2 -1
  177. package/dist/cli/lib/watchFiles.d.ts.map +1 -0
  178. package/dist/cli/lib/watchFiles.js.map +1 -0
  179. package/dist/cli/lib/watchFiles.unitTest.d.ts +2 -0
  180. package/dist/cli/lib/watchFiles.unitTest.d.ts.map +1 -0
  181. package/dist/cli/lib/watchFiles.unitTest.js.map +1 -0
  182. package/dist/cli/lib/watchFilesAndRunTests.js +2 -3
  183. package/dist/cli/lib/watchFilesAndRunTests.unitTest.d.ts +2 -0
  184. package/dist/cli/lib/watchFilesAndRunTests.unitTest.d.ts.map +1 -0
  185. package/dist/cli/lib/watchFilesAndRunTests.unitTest.js +86 -96
  186. package/dist/cli/lib/watchFilesAndRunTests.unitTest.js.map +1 -0
  187. package/dist/cli/lib/watchFilesAndRunTestsChokidar.d.ts.map +1 -1
  188. package/dist/cli/lib/watchFilesAndRunTestsChokidar.js +99 -127
  189. package/dist/cli/lib/watchFilesAndRunTestsChokidar.js.map +1 -1
  190. package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.d.ts +2 -0
  191. package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.d.ts.map +1 -0
  192. package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js +90 -99
  193. package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js.map +1 -0
  194. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.d.ts.map +1 -1
  195. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js +108 -148
  196. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js.map +1 -1
  197. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.d.ts +2 -0
  198. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.d.ts.map +1 -0
  199. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js +87 -100
  200. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js.map +1 -0
  201. package/dist/cli/lib/watchFilesChokidar.js +30 -56
  202. package/dist/cli/lib/watchFilesChokidar.js.map +1 -1
  203. package/dist/cli/lib/watchFilesChokidar.unitTest.d.ts +2 -0
  204. package/dist/cli/lib/watchFilesChokidar.unitTest.d.ts.map +1 -0
  205. package/dist/cli/lib/watchFilesChokidar.unitTest.js +77 -81
  206. package/dist/cli/lib/watchFilesChokidar.unitTest.js.map +1 -0
  207. package/dist/cli/lib/watchFilesNodeWatch.js +31 -41
  208. package/dist/cli/lib/watchFilesNodeWatch.js.map +1 -1
  209. package/dist/cli/lib/watchFilesNodeWatch.unitTest.d.ts +2 -0
  210. package/dist/cli/lib/watchFilesNodeWatch.unitTest.d.ts.map +1 -0
  211. package/dist/cli/lib/watchFilesNodeWatch.unitTest.js +41 -46
  212. package/dist/cli/lib/watchFilesNodeWatch.unitTest.js.map +1 -0
  213. package/dist/cli/once.js +35 -42
  214. package/dist/cli/once.js.map +1 -1
  215. package/dist/cli/watch.js +64 -114
  216. package/dist/cli/watch.js.map +1 -1
  217. package/dist/cli/watch.unitTest.d.ts +6 -0
  218. package/dist/cli/watch.unitTest.d.ts.map +1 -0
  219. package/dist/cli/watch.unitTest.js +100 -111
  220. package/dist/cli/watch.unitTest.js.map +1 -0
  221. package/dist/config.d.ts +1 -1
  222. package/dist/config.d.ts.map +1 -1
  223. package/dist/config.js +13 -2
  224. package/dist/config.js.map +1 -1
  225. package/dist/describe.js +20 -34
  226. package/dist/describe.js.map +1 -1
  227. package/dist/describe.unitTest.d.ts +2 -0
  228. package/dist/describe.unitTest.d.ts.map +1 -0
  229. package/dist/describe.unitTest.js +19 -23
  230. package/dist/describe.unitTest.js.map +1 -0
  231. package/dist/index.js +2 -1
  232. package/dist/indexNumberToLetters.js +12 -11
  233. package/dist/output.js +16 -18
  234. package/dist/packages/chalk.d.ts +14 -0
  235. package/dist/packages/chalk.d.ts.map +1 -0
  236. package/dist/packages/chalk.js +22 -0
  237. package/dist/packages/chalk.js.map +1 -0
  238. package/dist/packages/figures.d.ts +6 -0
  239. package/dist/packages/figures.d.ts.map +1 -0
  240. package/dist/packages/figures.js +24 -0
  241. package/dist/packages/figures.js.map +1 -0
  242. package/dist/packages/loadConfig.d.ts +3 -0
  243. package/dist/packages/loadConfig.d.ts.map +1 -0
  244. package/dist/packages/loadConfig.js +28 -0
  245. package/dist/packages/loadConfig.js.map +1 -0
  246. package/dist/packages/mergeStructuredConfig.d.ts +2 -0
  247. package/dist/packages/mergeStructuredConfig.d.ts.map +1 -0
  248. package/dist/packages/mergeStructuredConfig.js +26 -0
  249. package/dist/packages/mergeStructuredConfig.js.map +1 -0
  250. package/dist/packages/slash.d.ts +2 -0
  251. package/dist/packages/slash.d.ts.map +1 -0
  252. package/dist/packages/slash.js +9 -0
  253. package/dist/packages/slash.js.map +1 -0
  254. package/dist/packages/timeProfiler.d.ts +6 -0
  255. package/dist/packages/timeProfiler.d.ts.map +1 -0
  256. package/dist/packages/timeProfiler.js +32 -0
  257. package/dist/packages/timeProfiler.js.map +1 -0
  258. package/dist/types.d.ts +13 -13
  259. package/dist/types.d.ts.map +1 -1
  260. package/package.json +24 -20
  261. package/dist/cli/files.js +0 -20
  262. package/dist/cli/files.unitTest.js +0 -246
  263. package/dist/cli/init.unitTest.js +0 -0
  264. package/dist/cli/lib/defaultConfig.test.js +0 -9
  265. package/dist/cli/lib/loadTestFileStatic.js +0 -41
  266. package/dist/cli/lib/loadTestFileStatic.unitTest.js +0 -30
  267. package/dist/cli/lib/processWatchEvent.js +0 -1
  268. package/dist/cli/lib/processWatchEvent.unitTest.js +0 -15
  269. package/dist/cli/lib/runDescribe.old.js +0 -108
  270. package/dist/cli/lib/runDescribe.old.unitTest.js +0 -440
  271. package/dist/cli/lib/runTest-old.js +0 -160
  272. package/dist/cli/lib/runTest-old.unitTest.js +0 -184
  273. package/dist/cli/lib/watchFiles.unitTest.js +0 -50
  274. package/dist/cli/once.unitTest.js +0 -39
  275. package/dist/describe-old.js +0 -271
  276. package/dist/describe-old.unitTest.js +0 -30
  277. package/dist/exported.eslintrc.js +0 -7
  278. package/dist/lib/arrayRemove.d.ts +0 -2
  279. package/dist/lib/arrayRemove.d.ts.map +0 -1
  280. package/dist/lib/arrayRemove.js +0 -15
  281. package/dist/lib/arrayRemove.js.map +0 -1
  282. package/dist/lib/promiseAllObj.d.ts +0 -2
  283. package/dist/lib/promiseAllObj.d.ts.map +0 -1
  284. package/dist/lib/promiseAllObj.js +0 -14
  285. package/dist/lib/promiseAllObj.js.map +0 -1
  286. package/dist/testsState.js +0 -5
  287. package/dist/timeProfiling.js +0 -9
@@ -1,76 +1,66 @@
1
1
  import { timeProfileAsync } from './timeProfier.js';
2
2
  import { runTasks } from './runTasks.js';
3
3
  import { addExports } from './addExports.js';
4
- export async function runIt(config, it, beforeEachTestFunc, afterEachTestFunc) {
5
- return await timeProfileAsync(`run it ${it.should}`, async () => {
6
- const capturingConsoleLog = config.execution.tests === 'sequential';
7
-
8
- //// capture console.log output
9
- let previousConsoleLog;
10
- const logs = [];
11
- if (capturingConsoleLog) {
12
- previousConsoleLog = console.log; // eslint-disable-line no-console
13
- console.log = async (...texts) => await logs.push(texts); // eslint-disable-line no-console
14
- }
15
- ////
16
-
17
- // run before test/it
18
- const testExports = {};
19
- await configBeforeEachTest(config, testExports);
20
- if (typeof beforeEachTestFunc === 'function') {
21
- const funcExports = await beforeEachTestFunc();
22
- await addExports(testExports, funcExports);
23
- }
24
- const testParcel = {};
25
- await addExports(testParcel, testExports);
26
-
27
- //const thisItCounter = itCounter++ // assign THEN increment
28
-
29
- //// run the it
30
- let success = null;
31
- let error;
32
- const startTime = await new Date().getTime();
33
- try {
34
- await it.test(testParcel);
35
- success = true;
36
- } catch (e) {
37
- success = false;
38
- error = e;
39
- }
40
- const time = (await new Date().getTime()) - startTime;
41
- const itResult = {
42
- //counter: thisItCounter,
43
- counter: it.counter,
44
- should: it.should,
45
- success,
46
- time,
47
- error,
48
- logs
49
- };
50
-
51
- // run after test/it
52
- if (typeof afterEachTestFunc === 'function') await afterEachTestFunc();
53
- await configAfterEachTest(config, testExports);
54
-
55
- //// restore previous console.log
56
- if (capturingConsoleLog) {
57
- console.log = previousConsoleLog; // eslint-disable-line no-console
58
- }
59
- ////
60
-
61
- return itResult;
62
- //testResults.push(testResult)
63
- //testsState.testResults.push(testResult)
64
- });
4
+ export function runIt(config, it, beforeEachTestFunc, afterEachTestFunc) {
5
+ return timeProfileAsync(`run it ${it.should}`, async () => {
6
+ const capturingConsoleLog = config.execution.tests === 'sequential';
7
+ let previousConsoleLog;
8
+ const logs = [];
9
+ if (capturingConsoleLog) {
10
+ previousConsoleLog = console.log; // eslint-disable-line no-console
11
+ console.log = (...texts) => { logs.push(texts); }; // eslint-disable-line no-console
12
+ }
13
+ // run before test/it
14
+ const testExports = {};
15
+ await configBeforeEachTest(config, testExports);
16
+ if (typeof beforeEachTestFunc === 'function') {
17
+ const funcExports = await beforeEachTestFunc();
18
+ if (funcExports)
19
+ addExports(testExports, funcExports);
20
+ }
21
+ const testParcel = {};
22
+ addExports(testParcel, testExports);
23
+ //// run the it
24
+ let success = null;
25
+ let error;
26
+ const startTime = new Date().getTime();
27
+ try {
28
+ await it.test(testParcel);
29
+ success = true;
30
+ }
31
+ catch (e) {
32
+ success = false;
33
+ error = e;
34
+ }
35
+ const time = new Date().getTime() - startTime;
36
+ const itResult = {
37
+ counter: it.counter,
38
+ should: it.should,
39
+ success,
40
+ time,
41
+ error,
42
+ logs
43
+ };
44
+ // run after test/it
45
+ if (typeof afterEachTestFunc === 'function')
46
+ await afterEachTestFunc();
47
+ await configAfterEachTest(config, testExports);
48
+ if (capturingConsoleLog && previousConsoleLog) {
49
+ console.log = previousConsoleLog; // eslint-disable-line no-console
50
+ }
51
+ return itResult;
52
+ });
65
53
  }
66
54
  async function configBeforeEachTest(config, exports) {
67
- if (config.beforeEachTest) {
68
- const theExports = await runTasks(config.beforeEachTest, undefined);
69
- await addExports(exports, theExports);
70
- }
55
+ if (config.beforeEachTest !== undefined) {
56
+ const theExports = await runTasks(config.beforeEachTest, undefined);
57
+ if (theExports)
58
+ addExports(exports, theExports);
59
+ }
71
60
  }
72
61
  async function configAfterEachTest(config, exports) {
73
- if (config.afterEachTest) {
74
- await runTasks(config.afterEachTest, exports);
75
- }
76
- }
62
+ if (config.afterEachTest !== undefined) {
63
+ await runTasks(config.afterEachTest, exports);
64
+ }
65
+ }
66
+ //# sourceMappingURL=runIt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"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AAC,aAAa,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=runIt.unitTest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runIt.unitTest.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/runIt.unitTest.ts"],"names":[],"mappings":""}
@@ -1,414 +1,77 @@
1
- //import { should } from 'chai'
2
1
  import { applyConfigDefaults } from './applyConfigDefaults.js';
3
2
  import { loadTestFile } from './loadTestFile.js';
4
3
  import { parseDescribe } from './parseDescribe.js';
5
4
  import { runIt } from './runIt.js';
6
- const defaultConfig = await applyConfigDefaults({});
7
-
8
- // const beforeAfterTestFile = 'unitTesting/runTest/beforeAfter.test.js'
9
- // const beforeAfterTest = loadTestFile(defaultConfig, beforeAfterTestFile)
10
-
11
- await mochaDescribe('runIt() function', async function () {
12
- await mochaIt('should run an it block that was loaded from a test file', async function () {
13
- const sampleTestFile = 'unitTesting/runTest/1.test.js';
14
- const sampleTest = await loadTestFile(defaultConfig, sampleTestFile);
15
- const sampleDescribe = sampleTest.describes[0];
16
- const parsedDescribe = await parseDescribe(defaultConfig, sampleDescribe);
17
- //console.log('sample describe', sampleDescribe)
18
-
19
- await parsedDescribe.its.length.should.equal(1);
20
- const sampleIt = parsedDescribe.its[0];
21
- const itResult = await runIt(defaultConfig, sampleIt);
22
-
23
- // should causes errors because our obj contains a field called 'should'
24
- await (await chaiExpect(itResult)).to.include.keys(['counter', 'should', 'success', 'time', 'error']);
25
- await itResult['should'].should.equal('1 should equal 1');
26
- await itResult.success.should.equal(true);
27
- await chaiShould.not.exist(itResult.error);
28
- });
29
-
30
- // mochaIt('should return sensible results from a test file without any describes', function() {
31
-
32
- // //const config = applyConfigDefaults({})
33
-
34
- // const sampleTestFile = 'unitTesting/sampletests/blank.test.js'
35
- // const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
36
-
37
- // const testResult = runTest(defaultConfig, sampleTest)
38
-
39
- // //console.log(testResult)
40
- // //console.log(testResult.describeResults[0].itResults)
41
- // //console.log(testResult.describeResults[0].itResultsSummary)
42
-
43
- // testResult.should.include.keys([
44
- // 'file',
45
- // 'success',
46
- // 'describeResults',
47
- // 'describeResultsSummary'
48
- // ])
49
-
50
- // chaiExpect(testResult.success).to.be.null
51
-
52
- // //testResult.describeResultsSummary.total.should.equal(1)
53
- // //testResult.describeResultsSummary.passes.should.equal(1)
54
- // //testResult.describeResultsSummary.itsTotal.should.equal(1)
55
- // //testResult.describeResultsSummary.itsPasses.should.equal(1)
56
-
57
- // })
58
-
59
- // mochaIt('should return sensible results from a test file with describes without any its/tests', function() {
60
-
61
- // //const config = applyConfigDefaults({})
62
-
63
- // const sampleTestFile = 'unitTesting/sampletests/describesWithoutTests.test.js'
64
- // const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
65
-
66
- // const testResult = runTest(defaultConfig, sampleTest)
67
-
68
- // //console.log(testResult)
69
- // //console.log(testResult.describeResults[0].itResults)
70
- // //console.log(testResult.describeResults[0].itResultsSummary)
71
-
72
- // testResult.should.include.keys([
73
- // 'file',
74
- // 'success',
75
- // 'describeResults',
76
- // 'describeResultsSummary'
77
- // ])
78
-
79
- // chaiExpect(testResult.success).to.be.null
80
-
81
- // testResult.describeResultsSummary.total.should.equal(0)
82
- // testResult.describeResultsSummary.passes.should.equal(0)
83
- // testResult.describeResultsSummary.invalid.should.equal(2)
84
- // testResult.describeResultsSummary.itsTotal.should.equal(0)
85
- // testResult.describeResultsSummary.itsPasses.should.equal(0)
86
-
87
- // })
88
-
89
- // mochaIt("should run beforeEachFile tasks (before - can't test)", function() {
90
-
91
- // let functionHasRun = false
92
- // global.beforeEachFileFileHasRun = false
93
-
94
- // const ourConfig = {
95
- // beforeEachFile: [
96
- // function() {
97
- // functionHasRun = true
98
- // },
99
- // 'unitTesting/runTest/beforeEachFile.js'
100
- // ]
101
- // }
102
-
103
- // const config = applyConfigDefaults(ourConfig)
104
-
105
- // runTest(config, beforeAfterTest)
106
-
107
- // functionHasRun.should.equal(true)
108
- // global.beforeEachFileFileHasRun.should.equal(true)
109
-
110
- // })
111
-
112
- // mochaIt("should run afterEachFile tasks (after - can't test)", function() {
113
-
114
- // let functionHasRun = false
115
- // global.afterEachFileFileHasRun = false
116
-
117
- // const ourConfig = {
118
- // afterEachFile: [
119
- // function() {
120
- // functionHasRun = true
121
- // },
122
- // 'unitTesting/runTest/afterEachFile.js'
123
- // ]
124
- // }
125
-
126
- // const config = applyConfigDefaults(ourConfig)
127
-
128
- // runTest(config, beforeAfterTest)
129
-
130
- // functionHasRun.should.equal(true)
131
- // global.afterEachFileFileHasRun.should.equal(true)
132
-
133
- // })
134
-
135
- // mochaIt("should run beforeEachDescribe tasks (before - can't test) each describe block", function() {
136
-
137
- // let functionHasRunTimes = 0
138
- // global.beforeEachDescribeFileHasRun = false
139
-
140
- // const ourConfig = {
141
- // beforeEachDescribe: [
142
- // function() {
143
- // functionHasRunTimes++
144
- // },
145
- // 'unitTesting/runTest/beforeEachDescribe.js'
146
- // ]
147
- // }
148
-
149
- // const config = applyConfigDefaults(ourConfig)
150
-
151
- // runTest(config, beforeAfterTest)
152
-
153
- // functionHasRunTimes.should.equal(2)
154
- // global.beforeEachDescribeFileHasRun.should.equal(true)
155
-
156
- // })
157
-
158
- // mochaIt("should run afterEachDescribe tasks (after - can't test) each describe block", function() {
159
-
160
- // let functionHasRunTimes = 0
161
- // global.afterEachDescribeFileHasRun = false
162
-
163
- // const ourConfig = {
164
- // afterEachDescribe: [
165
- // function() {
166
- // functionHasRunTimes++
167
- // },
168
- // 'unitTesting/runTest/afterEachDescribe.js'
169
- // ]
170
- // }
171
-
172
- // const config = applyConfigDefaults(ourConfig)
173
-
174
- // runTest(config, beforeAfterTest)
175
-
176
- // functionHasRunTimes.should.equal(2)
177
- // global.afterEachDescribeFileHasRun.should.equal(true)
178
-
179
- // })
180
-
181
- // mochaIt("should run beforeEachTest tasks (before - can't test) each test/it block", function() {
182
-
183
- // let functionHasRunTimes = 0
184
- // global.beforeEachTestbeforeEachFileFileHasRun = false
185
-
186
- // const ourConfig = {
187
- // beforeEachTest: [
188
- // function() {
189
- // functionHasRunTimes++
190
- // },
191
- // 'unitTesting/runTest/beforeEachTest.js'
192
- // ]
193
- // }
194
-
195
- // const config = applyConfigDefaults(ourConfig)
196
-
197
- // runTest(config, beforeAfterTest)
198
-
199
- // functionHasRunTimes.should.equal(3)
200
- // global.beforeEachTestFileHasRun.should.equal(true)
201
-
202
- // })
203
-
204
- // mochaIt("should run afterEachTest tasks (after - can't test) each test/it block", function() {
205
-
206
- // let functionHasRunTimes = 0
207
- // global.afterEachTestFileFileHasRun = false
208
-
209
- // const ourConfig = {
210
- // afterEachTest: [
211
- // function() {
212
- // functionHasRunTimes++
213
- // },
214
- // 'unitTesting/runTest/afterEachTest.js'
215
- // ]
216
- // }
217
-
218
- // const config = applyConfigDefaults(ourConfig)
219
-
220
- // runTest(config, beforeAfterTest)
221
-
222
- // functionHasRunTimes.should.equal(3)
223
- // global.afterEachTestFileHasRun.should.equal(true)
224
-
225
- // })
226
-
227
- // // exports provision to test file
228
-
229
- // // current beforeEachFile exports aren't provided
230
- // // perhaps extend sxy-loader to allow this
231
-
232
- // mochaIt("should pass exported/returned data from beforeEachDescribe tasks", function() {
233
-
234
- // const testFile = 'unitTesting/runTest/beforeEachDescribe.test.js'
235
- // const test = loadTestFile(defaultConfig, testFile)
236
-
237
- // const ourConfig = {
238
- // beforeEachDescribe: [
239
- // function() {
240
- // return { functionThing : 'foo' }
241
- // },
242
- // 'unitTesting/runTest/beforeEachDescribeExport.js'
243
- // ]
244
- // }
245
-
246
- // const config = applyConfigDefaults(ourConfig)
247
-
248
- // runTest(config, test)
249
-
250
- // global.functionThing.should.equal('foo')
251
- // global.fileThing.should.equal('bar')
252
-
253
- // })
254
-
255
- // mochaIt("should pass exported/returned data from beforeEachTest tasks", function() {
256
-
257
- // const testFile = 'unitTesting/runTest/beforeEachTest.test.js'
258
- // const test = loadTestFile(defaultConfig, testFile)
259
-
260
- // const ourConfig = {
261
- // beforeEachTest: [
262
- // function() {
263
- // return { functionThing : 'foo' }
264
- // },
265
- // 'unitTesting/runTest/beforeEachTestExport.js'
266
- // ]
267
- // }
268
-
269
- // const config = applyConfigDefaults(ourConfig)
270
-
271
- // runTest(config, test)
272
-
273
- // global.functionThing.should.equal('foo')
274
- // global.fileThing.should.equal('bar')
275
-
276
- // })
277
-
278
- // // exports pass through
279
-
280
- // mochaIt("beforeEachFile exports are passed through to afterEachFile", function() {
281
-
282
- // // don't try to reload test, fails due to module caching
283
- // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
284
- // //const test = loadTestFile(defaultConfig, testFile)
285
-
286
- // let exports
287
-
288
- // const ourConfig = {
289
- // beforeEachFile: [
290
- // function() {
291
- // return { functionThing : 'foo' }
292
- // },
293
- // 'unitTesting/runTest/beforeEachExport.js'
294
- // ],
295
- // afterEachFile: [
296
- // function(theExports) {
297
- // theExports.should.have.keys(['functionThing', 'fileThing'])
298
- // exports = theExports
299
- // },
300
- // ]
301
- // }
302
-
303
- // const config = applyConfigDefaults(ourConfig)
304
-
305
- // runTest(config, beforeAfterTest)
306
-
307
- // exports.functionThing.should.equal('foo')
308
- // exports.fileThing.should.equal('bar')
309
-
310
- // })
311
-
312
- // mochaIt("beforeEachDescribe exports are passed through to afterEachDescribe", function() {
313
-
314
- // // don't try to reload test, fails due to module caching
315
- // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
316
- // //const test = loadTestFile(defaultConfig, testFile)
317
-
318
- // let exports
319
-
320
- // const ourConfig = {
321
- // beforeEachDescribe: [
322
- // function() {
323
- // return { functionThing : 'foo' }
324
- // },
325
- // 'unitTesting/runTest/beforeEachExport.js'
326
- // ],
327
- // afterEachDescribe: [
328
- // function(theExports) {
329
- // exports = theExports
330
- // },
331
- // ]
332
- // }
333
-
334
- // const config = applyConfigDefaults(ourConfig)
335
-
336
- // runTest(config, beforeAfterTest)
337
-
338
- // //console.log('exports', exports)
339
-
340
- // exports.functionThing.should.equal('foo')
341
- // exports.fileThing.should.equal('bar')
342
-
343
- // })
344
-
345
- // mochaIt("beforeEachTest exports are passed through to afterEachTest", function() {
346
-
347
- // // don't try to reload test, fails due to module caching
348
- // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
349
- // //const test = loadTestFile(defaultConfig, testFile)
350
-
351
- // let exports
352
-
353
- // const ourConfig = {
354
- // beforeEachTest: [
355
- // function() {
356
- // return { functionThing : 'foo' }
357
- // },
358
- // 'unitTesting/runTest/beforeEachExport.js'
359
- // ],
360
- // afterEachTest: [
361
- // function(theExports) {
362
- // exports = theExports
363
- // },
364
- // ]
365
- // }
366
-
367
- // const config = applyConfigDefaults(ourConfig)
368
-
369
- // runTest(config, beforeAfterTest)
370
-
371
- // //console.log('exports', exports)
372
-
373
- // exports.functionThing.should.equal('foo')
374
- // exports.fileThing.should.equal('bar')
375
-
376
- // })
377
-
378
- // mochaIt("we can run code beforeEachTest and afterEachTest from within the test file", function() {
379
-
380
- // // don't try to reload test, fails due to module caching
381
- // const testFile = 'unitTesting/runTest/internalBeforeAfterEachTest.test.js'
382
- // const test = loadTestFile(defaultConfig, testFile)
383
-
384
- // const config = applyConfigDefaults({})
385
-
386
- // global.internalBeforeEachTestRanNTimes = 0
387
- // global.internalAfterEachTestRanNTimes = 0
388
- // runTest(config, test)
389
-
390
- // global.internalBeforeAfterEachTest_test1Valid.should.equal(true)
391
- // global.internalBeforeAfterEachTest_test2Valid.should.equal(true)
392
- // global.internalBeforeAfterEachTest_test3Valid.should.equal(true)
393
- // global.internalBeforeEachTestRanNTimes.should.equal(3)
394
- // global.internalAfterEachTestRanNTimes.should.equal(3)
395
-
396
- // })
397
-
398
- // mochaIt("we can run code afterDescribe from within descibe in the test file", function() {
399
-
400
- // // don't try to reload test, fails due to module caching
401
- // const testFile = 'unitTesting/runTest/internalAfterDescribeTest.test.js'
402
- // const test = loadTestFile(defaultConfig, testFile)
403
-
404
- // const config = applyConfigDefaults({})
405
-
406
- // global.internalAfterDescribeRanNTimes = 0
407
- // runTest(config, test)
408
-
409
- // //global.internalAfterDescribe_test1Valid.should.equal(true)
410
- // //global.internalAfterDescribe_test2Valid.should.equal(true)
411
- // global.internalAfterDescribeRanNTimes.should.equal(2)
412
-
413
- // })
414
- });
5
+ const defaultConfig = applyConfigDefaults({});
6
+ function delay(ms) {
7
+ return new Promise(resolve => setTimeout(resolve, ms));
8
+ }
9
+ mochaDescribe('runIt() function', function () {
10
+ mochaIt('should run an it block that was loaded from a test file', async function () {
11
+ const sampleTestFile = 'unitTesting/runTest/1.test.js';
12
+ const sampleTest = await loadTestFile(defaultConfig, sampleTestFile);
13
+ const sampleDescribe = sampleTest.describes?.[0];
14
+ if (!sampleDescribe)
15
+ throw new Error('expected a describe to be loaded');
16
+ const parsedDescribe = await parseDescribe(defaultConfig, sampleDescribe);
17
+ parsedDescribe.its.length.should.equal(1);
18
+ const sampleIt = parsedDescribe.its[0];
19
+ if (!sampleIt)
20
+ throw new Error('expected an it to be parsed');
21
+ const itResult = await runIt(defaultConfig, sampleIt, undefined, undefined);
22
+ // should causes errors because our obj contains a field called 'should'
23
+ chaiExpect(itResult).to.include.keys([
24
+ 'counter',
25
+ 'should',
26
+ 'success',
27
+ 'time',
28
+ 'error'
29
+ ]);
30
+ itResult.should.should.equal('1 should equal 1');
31
+ chaiExpect(itResult.success).to.equal(true);
32
+ chaiShould.not.exist(itResult.error);
33
+ });
34
+ mochaIt('should register a failure when an async test body rejects', async function () {
35
+ const asyncFailingIt = {
36
+ counter: 1,
37
+ should: 'async test that rejects',
38
+ test: async () => {
39
+ await delay(20);
40
+ throw new Error('async failure');
41
+ }
42
+ };
43
+ const itResult = await runIt(defaultConfig, asyncFailingIt, undefined, undefined);
44
+ chaiExpect(itResult.success).to.equal(false);
45
+ chaiShould.exist(itResult.error);
46
+ });
47
+ mochaIt('should await beforeEachTestFunc and pass its async exports to the test', async function () {
48
+ let seen;
49
+ const beforeEachTestFunc = async () => {
50
+ await delay(20);
51
+ return { injected: 'value' };
52
+ };
53
+ const it = {
54
+ counter: 1,
55
+ should: 'receives injected export',
56
+ test: parcel => { seen = parcel.injected; }
57
+ };
58
+ const itResult = await runIt(defaultConfig, it, beforeEachTestFunc, undefined);
59
+ chaiExpect(itResult.success).to.equal(true);
60
+ chaiExpect(seen).to.equal('value');
61
+ });
62
+ mochaIt('should await an async afterEachTestFunc before returning', async function () {
63
+ let afterEachComplete = false;
64
+ const afterEachTestFunc = async () => {
65
+ await delay(50);
66
+ afterEachComplete = true;
67
+ };
68
+ const it = {
69
+ counter: 1,
70
+ should: 'a passing test',
71
+ test: () => { }
72
+ };
73
+ await runIt(defaultConfig, it, undefined, afterEachTestFunc);
74
+ chaiExpect(afterEachComplete).to.equal(true);
75
+ });
76
+ });
77
+ //# sourceMappingURL=runIt.unitTest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runIt.unitTest.js","sourceRoot":"","sources":["../../../src/cli/lib/runIt.unitTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGlC,MAAM,aAAa,GAAG,mBAAmB,CAAC,EAAE,CAAC,CAAA;AAE7C,SAAS,KAAK,CAAC,EAAU;IACrB,OAAO,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAChE,CAAC;AAED,aAAa,CAAC,kBAAkB,EAAE;IAC9B,OAAO,CAAC,yDAAyD,EAAE,KAAK;QACpE,MAAM,cAAc,GAAG,+BAA+B,CAAA;QACtD,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,aAAa,EAAE,cAAc,CAAC,C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CAAC;YACV,MAAM,EAAE,gBAAgB;YACxB,IAAI,EAAE,GAAG,EAAE,GAAe,CAAC;SAC9B,CAAA;QAED,MAAM,KAAK,CAAC,aAAa,EAAE,EAAE,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAA;QAE5D,UAAU,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
@@ -1,3 +1,3 @@
1
1
  import type { ConfigTasks, TaskExports } from '../../types.js';
2
- export declare function runTasks(tasks: ConfigTasks | undefined, parcel?: TaskExports | undefined): TaskExports | null;
2
+ export declare function runTasks(tasks: ConfigTasks | undefined, parcel?: TaskExports | undefined): Promise<TaskExports | null>;
3
3
  //# sourceMappingURL=runTasks.d.ts.map