sxy-test-runner 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/cli/index.js +2 -6
  2. package/dist/cli/init.js +19 -14
  3. package/dist/cli/lib/addBasePath.js +0 -1
  4. package/dist/cli/lib/addBasePath.unitTest.js +3 -1
  5. package/dist/cli/lib/addExports.unitTest.js +4 -1
  6. package/dist/cli/lib/applyConfigDefaults.js +12 -7
  7. package/dist/cli/lib/applyConfigDefaults.unitTest.js +9 -3
  8. package/dist/cli/lib/buildDependencyTree.js +10 -5
  9. package/dist/cli/lib/buildDependencyTree.unitTest.js +3 -1
  10. package/dist/cli/lib/buildDependencyTrees.js +6 -4
  11. package/dist/cli/lib/buildDependencyTrees.unitTest.js +3 -1
  12. package/dist/cli/lib/defaultConfig.test.js +3 -1
  13. package/dist/cli/lib/doUserSetup.js +0 -3
  14. package/dist/cli/lib/doUserSetup.unitTest.js +3 -1
  15. package/dist/cli/lib/doUserTeardown.js +0 -3
  16. package/dist/cli/lib/doUserTeardown.unitTest.js +3 -1
  17. package/dist/cli/lib/findTestFiles.unitTest.js +3 -1
  18. package/dist/cli/lib/getAllowedFlags.js +0 -2
  19. package/dist/cli/lib/getAllowedFlags.unitTest.js +3 -1
  20. package/dist/cli/lib/injectProperties.js +2 -2
  21. package/dist/cli/lib/injectProperties.unitTest.js +9 -2
  22. package/dist/cli/lib/loadConfig.js +2 -2
  23. package/dist/cli/lib/loadConfig.unitTest.js +3 -2
  24. package/dist/cli/lib/loadTestFile.js +17 -15
  25. package/dist/cli/lib/loadTestFile.unitTest.js +8 -3
  26. package/dist/cli/lib/loadTestFileStatic.js +1 -0
  27. package/dist/cli/lib/loadTestFileStatic.unitTest.js +1 -0
  28. package/dist/cli/lib/parseCommandLineArguments.js +1 -9
  29. package/dist/cli/lib/parseCommandLineArguments.unitTest.js +6 -2
  30. package/dist/cli/lib/parseDescribe.js +12 -18
  31. package/dist/cli/lib/parseDescribe.unitTest.js +6 -2
  32. package/dist/cli/lib/processWatchEvent.unitTest.js +9 -1
  33. package/dist/cli/lib/reservedExportKeys.unitTest.js +3 -1
  34. package/dist/cli/lib/runDescribe.js +4 -7
  35. package/dist/cli/lib/runDescribe.old.js +19 -25
  36. package/dist/cli/lib/runDescribe.unitTest.js +120 -2
  37. package/dist/cli/lib/runDescribeRun.js +3 -7
  38. package/dist/cli/lib/runDescribeRun.unitTest.js +125 -4
  39. package/dist/cli/lib/runIt.js +16 -18
  40. package/dist/cli/lib/runIt.unitTest.js +124 -4
  41. package/dist/cli/lib/runTasks.js +2 -7
  42. package/dist/cli/lib/runTasks.unitTest.js +3 -1
  43. package/dist/cli/lib/runTest-old.js +1 -0
  44. package/dist/cli/lib/runTest-old.unitTest.js +1 -0
  45. package/dist/cli/lib/runTest.js +15 -12
  46. package/dist/cli/lib/runTest.unitTest.js +38 -11
  47. package/dist/cli/lib/runTests.js +36 -35
  48. package/dist/cli/lib/runTests.unitTest.js +15 -8
  49. package/dist/cli/lib/showTestLoadingError.js +6 -6
  50. package/dist/cli/lib/showTestLoadingError.unitTest.js +5 -3
  51. package/dist/cli/lib/showTestResult.js +10 -16
  52. package/dist/cli/lib/showTestResult.unitTest.js +26 -17
  53. package/dist/cli/lib/validateConfig.js +0 -5
  54. package/dist/cli/lib/validateConfig.unitTest.js +2 -3
  55. package/dist/cli/lib/watchFiles.unitTest.js +5 -3
  56. package/dist/cli/lib/watchFilesAndRunTests.js +3 -1
  57. package/dist/cli/lib/watchFilesAndRunTests.unitTest.js +18 -15
  58. package/dist/cli/lib/watchFilesAndRunTestsChokidar.js +22 -29
  59. package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js +19 -17
  60. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js +28 -31
  61. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js +21 -16
  62. package/dist/cli/lib/watchFilesChokidar.js +15 -11
  63. package/dist/cli/lib/watchFilesChokidar.unitTest.js +11 -8
  64. package/dist/cli/lib/watchFilesNodeWatch.js +9 -6
  65. package/dist/cli/lib/watchFilesNodeWatch.unitTest.js +6 -3
  66. package/dist/cli/once.js +0 -6
  67. package/dist/cli/watch.js +18 -14
  68. package/dist/cli/watch.unitTest.js +16 -16
  69. package/dist/describe-old.js +35 -20
  70. package/dist/describe-old.unitTest.js +10 -1
  71. package/dist/describe.js +8 -3
  72. package/dist/describe.unitTest.js +5 -2
  73. package/dist/indexNumberToLetters.js +1 -3
  74. package/dist/output.js +7 -0
  75. package/dist/testsState.js +2 -1
  76. package/package.json +14 -7
  77. package/readme.md +1 -1
  78. package/sxy-loader.config.js +10 -10
@@ -1,6 +1,7 @@
1
1
  // watch:
2
2
  // once:
3
3
  // // --config configLocation
4
+
4
5
  import { createTimeProfiler } from 'sxy-dev-tools';
5
6
  import { packageName, cliName, configFileName, configLocations, showTimeProfiling } from '../../config.js';
6
7
  import { join } from 'path';
@@ -12,17 +13,13 @@ import { getAllowedFlags } from './getAllowedFlags.js';
12
13
  export async function parseCommandLineArguments(allowedArguments) {
13
14
  const allowedFlags = await getAllowedFlags(allowedArguments);
14
15
  const returnArgs = {};
15
-
16
16
  for (let position = 0; position < commandLineArguments.length; position++) {
17
17
  const arg = commandLineArguments[position];
18
-
19
18
  if ((await arg.slice(0, 2)) === '--') {
20
19
  const longFlag = await arg.slice(2);
21
-
22
20
  if (longFlag in allowedArguments) {
23
21
  if (allowedArguments[longFlag].hasValue) {
24
22
  const value = commandLineArguments[++position]; // increment position
25
-
26
23
  returnArgs[longFlag] = value;
27
24
  } else {
28
25
  returnArgs[longFlag] = true;
@@ -32,17 +29,13 @@ export async function parseCommandLineArguments(allowedArguments) {
32
29
  }
33
30
  } else if ((await arg.slice(0, 1)) === '-') {
34
31
  const shortFlag = await arg.slice(1);
35
-
36
32
  if (shortFlag in allowedFlags) {
37
33
  const longFlag = allowedFlags[shortFlag];
38
-
39
34
  if (longFlag in returnArgs) {
40
35
  await log(`[${packageName}] Option ${longFlag} already set, being overwritten by ${shortFlag}`);
41
36
  }
42
-
43
37
  if (allowedArguments[longFlag].hasValue) {
44
38
  const value = commandLineArguments[++position]; // increment position
45
-
46
39
  returnArgs[longFlag] = value;
47
40
  } else {
48
41
  returnArgs[longFlag] = true;
@@ -52,6 +45,5 @@ export async function parseCommandLineArguments(allowedArguments) {
52
45
  }
53
46
  }
54
47
  }
55
-
56
48
  return returnArgs;
57
49
  }
@@ -1,4 +1,6 @@
1
- import { parseCommandLineArguments } from './parseCommandLineArguments.js'; // parseCommandLineArguments(allowedArguments)
1
+ import { parseCommandLineArguments } from './parseCommandLineArguments.js';
2
+
3
+ // parseCommandLineArguments(allowedArguments)
2
4
 
3
5
  await mochaDescribe('getAllowedFlags() function', async function () {
4
6
  await mochaIt('extracts the flags from an allowedArguments object', async function () {
@@ -13,7 +15,9 @@ await mochaDescribe('getAllowedFlags() function', async function () {
13
15
  }
14
16
  };
15
17
  global.commandLineArguments = ['--config', 'foo bar'];
16
- const parsedArgs = await parseCommandLineArguments(allowedArguments); //console.log('parsed Args', parsedArgs)
18
+ const parsedArgs = await parseCommandLineArguments(allowedArguments);
19
+
20
+ //console.log('parsed Args', parsedArgs)
17
21
 
18
22
  await parsedArgs.should.have.key('config');
19
23
  await parsedArgs.config.should.equal('foo bar');
@@ -6,49 +6,45 @@ import { runIt } from './runIt.js';
6
6
  export async function parseDescribe(config, describe) {
7
7
  return await timeProfileAsync(`parse its from describe ${describe.thing}`, async () => {
8
8
  let itCounter = 1;
9
- const its = []; // create functions to pass back
10
- // afterDescribe
9
+ const its = [];
11
10
 
12
- let afterDescribeFunc;
11
+ // create functions to pass back
13
12
 
13
+ // afterDescribe
14
+ let afterDescribeFunc;
14
15
  async function afterDescribe(func) {
15
16
  if (typeof func !== 'function') {
16
17
  throw new Error(`afterDescribe() error, argument passed to afterDescribe() must be a function,` + ` received ${typeof func}`);
17
18
  }
18
-
19
19
  afterDescribeFunc = func;
20
- } // beforeEachTest
21
-
20
+ }
22
21
 
22
+ // beforeEachTest
23
23
  let beforeEachTestFunc;
24
-
25
24
  async function beforeEachTest(func) {
26
25
  if (typeof func !== 'function') {
27
26
  throw new Error(`afterDescribe() error, argument passed to afterDescribe() must be a function,` + ` received ${typeof func}`);
28
27
  }
29
-
30
28
  beforeEachTestFunc = func;
31
- } // afterEachTest
32
-
29
+ }
33
30
 
31
+ // afterEachTest
34
32
  let afterEachTestFunc;
35
-
36
33
  async function afterEachTest(func) {
37
34
  if (typeof func !== 'function') {
38
35
  throw new Error(`afterDescribe() error, argument passed to afterDescribe() must be a function,` + ` received ${typeof func}`);
39
36
  }
40
-
41
37
  afterEachTestFunc = func;
42
- } // it
43
-
38
+ }
44
39
 
40
+ // it
45
41
  async function it(should, test) {
46
42
  const thisItCounter = itCounter++;
47
43
  await its.push({
48
44
  counter: thisItCounter,
49
45
  should,
50
- test //beforeEachTestExports
51
-
46
+ test
47
+ //beforeEachTestExports
52
48
  });
53
49
  }
54
50
 
@@ -73,14 +69,12 @@ export async function parseDescribe(config, describe) {
73
69
  };
74
70
  });
75
71
  }
76
-
77
72
  async function configBeforeEachDescribe(config, exports) {
78
73
  if (config.beforeEachDescribe) {
79
74
  const theExports = await runTasks(config.beforeEachDescribe, undefined);
80
75
  await addExports(exports, theExports);
81
76
  }
82
77
  }
83
-
84
78
  async function configAfterEachDescribe(config, exports) {
85
79
  if (config.afterEachDescribe) {
86
80
  await runTasks(config.afterEachDescribe, exports);
@@ -1,7 +1,9 @@
1
1
  import { applyConfigDefaults } from './applyConfigDefaults.js';
2
2
  import { loadTestFile } from './loadTestFile.js';
3
3
  import { parseDescribe } from './parseDescribe.js';
4
- const defaultConfig = await applyConfigDefaults({}); // const beforeAfterTestFile = 'unitTesting/runTest/beforeAfter.test.js'
4
+ const defaultConfig = await applyConfigDefaults({});
5
+
6
+ // const beforeAfterTestFile = 'unitTesting/runTest/beforeAfter.test.js'
5
7
  // const beforeAfterTest = loadTestFile(defaultConfig, beforeAfterTestFile)
6
8
 
7
9
  await mochaDescribe('runDescribe() function', async function () {
@@ -10,7 +12,9 @@ await mochaDescribe('runDescribe() function', async function () {
10
12
  const sampleTest = await loadTestFile(defaultConfig, sampleTestFile);
11
13
  const sampleDescribe = sampleTest.describes[0];
12
14
  const parsedDescribe = await parseDescribe(defaultConfig, sampleDescribe);
13
- await parsedDescribe.should.include.keys(['its', 'beforeDescribeExports', 'afterDescribeFunc', 'beforeEachTestFunc', 'afterEachTestFunc']); //console.log('parsedDescribe', parsedDescribe)
15
+ await parsedDescribe.should.include.keys(['its', 'beforeDescribeExports', 'afterDescribeFunc', 'beforeEachTestFunc', 'afterEachTestFunc']);
16
+
17
+ //console.log('parsedDescribe', parsedDescribe)
14
18
 
15
19
  await parsedDescribe.its[0]['should'].should.equal('1 should equal 1');
16
20
  });
@@ -1,7 +1,15 @@
1
+
2
+
1
3
  //import { processWatchEvent } from './processWatchEvent.js'
4
+
2
5
  // parseCommandLineArguments(allowedArguments)
6
+
3
7
  // mochaDescribe('processWatchEvent() function', function() {
8
+
4
9
  // mochaIt('identifies a test in a watch event', function() {
5
- // processWatchEvent('temp/a.test.js', 'update')
10
+
11
+ // processWatchEvent('watchTests/a.test.js', 'update')
12
+
6
13
  // })
14
+
7
15
  // })
@@ -1,4 +1,6 @@
1
- import { reservedExportKeys } from './reservedExportKeys.js'; // applyConfigDefaults( userConfig: {} )
1
+ import { reservedExportKeys } from './reservedExportKeys.js';
2
+
3
+ // applyConfigDefaults( userConfig: {} )
2
4
 
3
5
  await mochaDescribe('the reservedExportKeys', async function () {
4
6
  await mochaIt('has sensible defaults', async function () {
@@ -3,23 +3,20 @@ import { parseDescribe } from './parseDescribe.js';
3
3
  import { runDescribeRun } from './runDescribeRun.js';
4
4
  export async function runDescribe(config, describe) {
5
5
  return await timeProfileAsync(`run describe ${describe.thing}`, async () => {
6
- const capturingConsoleLog = config.execution.describes === 'sequential'; //// capture console.log output
6
+ const capturingConsoleLog = config.execution.describes === 'sequential';
7
7
 
8
+ //// capture console.log output
8
9
  let previousConsoleLog;
9
10
  const logs = [];
10
-
11
11
  if (capturingConsoleLog) {
12
12
  previousConsoleLog = console.log; // eslint-disable-line no-console
13
-
14
13
  console.log = async (...texts) => await logs.push(texts); // eslint-disable-line no-console
15
-
16
- } ////
17
-
14
+ }
15
+ ////
18
16
 
19
17
  const parsedDescribe = await parseDescribe(config, describe);
20
18
  const describeResult = await runDescribeRun(config, describe, parsedDescribe);
21
19
  describeResult.logs = logs;
22
-
23
20
  if (capturingConsoleLog) {
24
21
  console.log = previousConsoleLog; // eslint-disable-line no-console
25
22
  }
@@ -6,49 +6,45 @@ import { runIt } from './runIt.js';
6
6
  export async function runDescribeOld(config, describe) {
7
7
  return await timeProfileAsync(`run describe ${describe.thing}`, async () => {
8
8
  let itCounter = 1;
9
- const its = []; // create functions to pass back
10
- // afterDescribe
9
+ const its = [];
11
10
 
12
- let afterDescribeFunc;
11
+ // create functions to pass back
13
12
 
13
+ // afterDescribe
14
+ let afterDescribeFunc;
14
15
  async function afterDescribe(func) {
15
16
  if (typeof func !== 'function') {
16
17
  throw new Error(`afterDescribe() error, argument passed to afterDescribe() must be a function,` + ` received ${typeof func}`);
17
18
  }
18
-
19
19
  afterDescribeFunc = func;
20
- } // beforeEachTest
21
-
20
+ }
22
21
 
22
+ // beforeEachTest
23
23
  let beforeEachTestFunc;
24
-
25
24
  async function beforeEachTest(func) {
26
25
  if (typeof func !== 'function') {
27
26
  throw new Error(`afterDescribe() error, argument passed to afterDescribe() must be a function,` + ` received ${typeof func}`);
28
27
  }
29
-
30
28
  beforeEachTestFunc = func;
31
- } // afterEachTest
32
-
29
+ }
33
30
 
31
+ // afterEachTest
34
32
  let afterEachTestFunc;
35
-
36
33
  async function afterEachTest(func) {
37
34
  if (typeof func !== 'function') {
38
35
  throw new Error(`afterDescribe() error, argument passed to afterDescribe() must be a function,` + ` received ${typeof func}`);
39
36
  }
40
-
41
37
  afterEachTestFunc = func;
42
- } // it
43
-
38
+ }
44
39
 
40
+ // it
45
41
  async function it(should, test) {
46
42
  const thisItCounter = itCounter++;
47
43
  await its.push({
48
44
  counter: thisItCounter,
49
45
  should,
50
- test //beforeEachTestExports
51
-
46
+ test
47
+ //beforeEachTestExports
52
48
  });
53
49
  }
54
50
 
@@ -63,29 +59,28 @@ export async function runDescribeOld(config, describe) {
63
59
  afterEachTest
64
60
  };
65
61
  await addExports(describeParcel, describeExports);
66
- await describe.tests(describeParcel); //console.log('its', its)
62
+ await describe.tests(describeParcel);
63
+
64
+ //console.log('its', its)
65
+
67
66
  // const beforeEachDescribeExports = (config.beforeEachDescribe)
68
67
  // ? runTasks(config, config.beforeEachDescribe)
69
68
  // : {}
69
+
70
70
  //const thisDescribeCounter = describeCounter++ // assign THEN increment
71
71
  //let itCounter = 1
72
-
73
72
  const itResults = [];
74
-
75
73
  for (const it of its) {
76
74
  await itResults.push(await runIt(config, it, beforeEachTestFunc, afterEachTestFunc));
77
75
  }
78
-
79
76
  const itResultsSummary = {
80
77
  total: 0,
81
78
  passes: 0
82
79
  };
83
-
84
80
  for (const itResult of itResults) {
85
81
  itResultsSummary.total += +(itResult.success !== null);
86
82
  itResultsSummary.passes += +itResult.success;
87
83
  }
88
-
89
84
  await debug('itResultsSummary', itResultsSummary);
90
85
  const describeResult = {
91
86
  counter: describe.counter,
@@ -93,21 +88,20 @@ export async function runDescribeOld(config, describe) {
93
88
  success: itResultsSummary.total > 0 ? itResultsSummary.passes === itResultsSummary.total : null,
94
89
  itResults,
95
90
  itResultsSummary
96
- }; // run after
91
+ };
97
92
 
93
+ // run after
98
94
  if (typeof afterDescribeFunc === 'function') await afterDescribeFunc();
99
95
  await configAfterEachDescribe(config, describeExports);
100
96
  return describeResult;
101
97
  });
102
98
  }
103
-
104
99
  async function configBeforeEachDescribe(config, exports) {
105
100
  if (config.beforeEachDescribe) {
106
101
  const theExports = await runTasks(config.beforeEachDescribe, undefined);
107
102
  await addExports(exports, theExports);
108
103
  }
109
104
  }
110
-
111
105
  async function configAfterEachDescribe(config, exports) {
112
106
  if (config.afterEachDescribe) {
113
107
  await runTasks(config.afterEachDescribe, exports);