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
@@ -2,10 +2,10 @@ import { createTimeProfiler } from 'sxy-dev-tools';
2
2
  import { showTimeProfiling } from '../../config.js';
3
3
  import chalk from 'chalk-extensions';
4
4
  import minimatch from 'minimatch';
5
- import slash from 'slash'; //import watch from 'node-watch'
6
-
7
- import chokidar from 'chokidar'; //import nsfw from 'nsfw'
8
-
5
+ import slash from 'slash';
6
+ //import watch from 'node-watch'
7
+ import chokidar from 'chokidar';
8
+ //import nsfw from 'nsfw'
9
9
  import fs, { watch } from 'fs';
10
10
  import { out, log, debug } from '../../output.js';
11
11
  import { globArgCombine } from './globArgCombine.js';
@@ -17,20 +17,20 @@ export async function watchFilesChokidar(config, onEvent) {
17
17
  return await timeProfileAsync('start watching', async () => {
18
18
  //const testGlobs = addBaseToGlobs(config.testsBase, config.tests)
19
19
  //const ignoreGlobs = addBaseToGlobs(config.testsBase, config.testsIgnore)
20
- // indentify a test file
21
- const testFilter = file => minimatch(file, globArgCombine(config.tests)) && (!config.testsIgnore || !minimatch(file, globArgCombine(config.testsIgnore))); // identify a file we should be watching and responding to
22
20
 
21
+ // indentify a test file
22
+ const testFilter = file => minimatch(file, globArgCombine(config.tests)) && (!config.testsIgnore || !minimatch(file, globArgCombine(config.testsIgnore)));
23
23
 
24
+ // identify a file we should be watching and responding to
24
25
  const watchFilter = file => (!config.watch.watchFiles || minimatch(file, globArgCombine(config.watch.watchFiles))) && (!config.watch.watchFilesIgnore || !minimatch(file, globArgCombine(config.watch.watchFilesIgnore)));
25
-
26
26
  if (!config.watch.watchFilesBase) {
27
27
  await out(`No config.watch.watchFilesBase provided, defaulting to '.'`);
28
28
  config.watch.watchFilesBase = '.';
29
29
  }
30
+ const ignoreGlob = config.watch.watchFilesIgnore ? await addBasePath(config.watch.watchFilesBase, config.watch.watchFilesIgnore) : null;
30
31
 
31
- const ignoreGlob = config.watch.watchFilesIgnore ? await addBasePath(config.watch.watchFilesBase, config.watch.watchFilesIgnore) : null; //log(`watch: ${config.watch.watchFilesBase}`)
32
+ //log(`watch: ${config.watch.watchFilesBase}`)
32
33
  // log(`ignore: ${ignoreGlob}`)
33
-
34
34
  const watcher = await chokidar.watch(config.watch.watchFilesBase, {
35
35
  ignored: ignoreGlob,
36
36
  ignoreInitial: true
@@ -47,10 +47,14 @@ export async function watchFilesChokidar(config, onEvent) {
47
47
  await debug('chokidar watcher ready');
48
48
  await resolve(watcher);
49
49
  });
50
- }); // watch(config.watch.watchFilesBase, { recursive: true, filter: watchFilter }, function(event, filename) {
50
+ });
51
+
52
+ // watch(config.watch.watchFilesBase, { recursive: true, filter: watchFilter }, function(event, filename) {
51
53
  // filename = slash(filename)
52
54
  // debug('watch event')
53
55
  // onEvent(filename, event)
54
56
  // })
55
- }); //return new Promise( () => {} ) // infinite promise to let us watch
57
+ });
58
+
59
+ //return new Promise( () => {} ) // infinite promise to let us watch
56
60
  }
@@ -1,6 +1,8 @@
1
1
  import { promises as fs } from 'fs';
2
2
  import { watchFilesChokidar } from './watchFilesChokidar.js';
3
- import { applyConfigDefaults } from './applyConfigDefaults.js'; // watchFiles(config, testFiles, dependencyTrees, failingTests) ???
3
+ import { applyConfigDefaults } from './applyConfigDefaults.js';
4
+
5
+ // watchFiles(config, testFiles, dependencyTrees, failingTests) ???
4
6
 
5
7
  await mochaDescribe('watchFilesChokidar() function', async function () {
6
8
  await mochaIt('should call back when when a file change occurs', async function () {
@@ -10,7 +12,7 @@ await mochaDescribe('watchFilesChokidar() function', async function () {
10
12
  await watchFilesChokidar(config, async (filename, event) => {
11
13
  eventComplete = true;
12
14
  });
13
- await fs.writeFile('temp/watchFilesChokidar-file.js', 'abc');
15
+ await fs.writeFile('watchTests/watchFilesChokidar-file.js', 'abc');
14
16
  await new Promise(async (resolve, reject) => {
15
17
  const interval = await setInterval(async () => {
16
18
  if (eventComplete) {
@@ -25,7 +27,7 @@ await mochaDescribe('watchFilesChokidar() function', async function () {
25
27
  await this.timeout(12000);
26
28
  const config = await applyConfigDefaults({
27
29
  watch: {
28
- watchFilesBase: 'temp/watchFilesChokidar',
30
+ watchFilesBase: 'watchTests/watchFilesChokidar',
29
31
  watchFiles: '**/*.js'
30
32
  }
31
33
  });
@@ -33,7 +35,7 @@ await mochaDescribe('watchFilesChokidar() function', async function () {
33
35
  await watchFilesChokidar(config, async (filename, event) => {
34
36
  eventComplete = true;
35
37
  });
36
- await fs.writeFile('temp/watchFilesChokidar/a-file.js', 'abc');
38
+ await fs.writeFile('watchTests/watchFilesChokidar/a-file.js', 'abc');
37
39
  await new Promise(async (resolve, reject) => {
38
40
  const interval = await setInterval(async () => {
39
41
  if (eventComplete) {
@@ -48,7 +50,7 @@ await mochaDescribe('watchFilesChokidar() function', async function () {
48
50
  await this.timeout(12000);
49
51
  const config = await applyConfigDefaults({
50
52
  watch: {
51
- watchFilesBase: 'temp/watchFilesChokidar',
53
+ watchFilesBase: 'watchTests/watchFilesChokidar',
52
54
  watchFiles: '**/*.js',
53
55
  watchFilesIgnore: 'ignore-file.js'
54
56
  }
@@ -57,7 +59,7 @@ await mochaDescribe('watchFilesChokidar() function', async function () {
57
59
  await watchFilesChokidar(config, async (filename, event) => {
58
60
  eventComplete = true;
59
61
  });
60
- await fs.writeFile('temp/watchFilesChokidar/ignore-file.js', 'abc');
62
+ await fs.writeFile('watchTests/watchFilesChokidar/ignore-file.js', 'abc');
61
63
  await new Promise(async (resolve, reject) => {
62
64
  await setTimeout(resolve, 1000);
63
65
  });
@@ -65,9 +67,10 @@ await mochaDescribe('watchFilesChokidar() function', async function () {
65
67
  });
66
68
  await mochaIt('ignores a file based on ignore globs array', async function () {
67
69
  //this.timeout(100000)
70
+
68
71
  const config = await applyConfigDefaults({
69
72
  watch: {
70
- watchFilesBase: 'temp/watchFilesChokidar',
73
+ watchFilesBase: 'watchTests/watchFilesChokidar',
71
74
  watchFiles: '**/*.js',
72
75
  watchFilesIgnore: ['first-ignore-file.js', 'ignore-file.js']
73
76
  }
@@ -76,7 +79,7 @@ await mochaDescribe('watchFilesChokidar() function', async function () {
76
79
  await watchFilesChokidar(config, async (filename, event) => {
77
80
  eventComplete = true;
78
81
  });
79
- await fs.writeFile('temp/watchFilesChokidar/ignore-file.js', 'abc');
82
+ await fs.writeFile('watchTests/watchFilesChokidar/ignore-file.js', 'abc');
80
83
  await new Promise(async (resolve, reject) => {
81
84
  await setTimeout(resolve, 1000);
82
85
  });
@@ -3,9 +3,9 @@ import { showTimeProfiling } from '../../config.js';
3
3
  import chalk from 'chalk-extensions';
4
4
  import minimatch from 'minimatch';
5
5
  import slash from 'slash';
6
- import watch from 'node-watch'; //import chokidar from 'chokidar'
6
+ import watch from 'node-watch';
7
+ //import chokidar from 'chokidar'
7
8
  //import nsfw from 'nsfw'
8
-
9
9
  import fs from 'fs';
10
10
  import { out, log, debug } from '../../output.js';
11
11
  import { globArgCombine } from './globArgCombine.js';
@@ -16,15 +16,15 @@ export async function watchFilesNodeWatch(config, onEvent) {
16
16
  await timeProfileAsync('start watching', async () => {
17
17
  //const testGlobs = addBaseToGlobs(config.testsBase, config.tests)
18
18
  //const ignoreGlobs = addBaseToGlobs(config.testsBase, config.testsIgnore)
19
+
19
20
  // indentify a test file
21
+
20
22
  // identify a file we should be watching and responding to
21
23
  const watchFilter = file => (!config.watch.watchFiles || minimatch(file, globArgCombine(config.watch.watchFiles))) && (!config.watch.watchFilesIgnore || !minimatch(file, globArgCombine(config.watch.watchFilesIgnore)));
22
-
23
24
  if (!config.watch.watchFilesBase) {
24
25
  await out(`No config.watch.watchFilesBase provided, defaulting to '.'`);
25
26
  config.watch.watchFilesBase = '.';
26
27
  }
27
-
28
28
  const watcher = await watch(config.watch.watchFilesBase, {
29
29
  recursive: true,
30
30
  filter: watchFilter
@@ -32,11 +32,14 @@ export async function watchFilesNodeWatch(config, onEvent) {
32
32
  filename = await slash(filename);
33
33
  await debug('watch event');
34
34
  await onEvent(filename, event);
35
- }); // wait until the watcher is ready
35
+ });
36
36
 
37
+ // wait until the watcher is ready
37
38
  await new Promise(async (resolve, reject) => {
38
39
  await watcher.on('ready', resolve);
39
40
  });
40
41
  return watcher;
41
- }); //return new Promise( () => {} ) // infinite promise to let us watch
42
+ });
43
+
44
+ //return new Promise( () => {} ) // infinite promise to let us watch
42
45
  }
@@ -1,16 +1,19 @@
1
1
  import { promises as fs } from 'fs';
2
2
  import { watchFilesNodeWatch } from './watchFilesNodeWatch.js';
3
- import { applyConfigDefaults } from './applyConfigDefaults.js'; // watchFiles(config, callback)
3
+ import { applyConfigDefaults } from './applyConfigDefaults.js';
4
+
5
+ // watchFiles(config, callback)
4
6
 
5
7
  await mochaDescribe('watchFilesNodeWatch() function', async function () {
6
8
  await mochaIt('should call back when when a file change occurs', async function () {
7
9
  //this.timeout(100000)
10
+
8
11
  const config = await applyConfigDefaults({});
9
12
  let eventComplete = false;
10
13
  await watchFilesNodeWatch(config, async (filename, event) => {
11
14
  eventComplete = true;
12
15
  });
13
- await fs.writeFile('temp/watchFiles-file.js', 'abc');
16
+ await fs.writeFile('watchTests/watchFiles-file.js', 'abc');
14
17
  await new Promise(async (resolve, reject) => {
15
18
  const interval = await setInterval(async () => {
16
19
  if (eventComplete) {
@@ -23,7 +26,7 @@ await mochaDescribe('watchFilesNodeWatch() function', async function () {
23
26
  });
24
27
  await mochaIt('should call back when when a file change occurs in specified folder', async function () {
25
28
  //this.timeout(100000)
26
- const tempFolder = 'temp/watchFilesNodeWatcher';
29
+ const tempFolder = 'watchTests/watchFilesNodeWatcher';
27
30
  const config = await applyConfigDefaults({
28
31
  watch: {
29
32
  watchFilesBase: tempFolder,
package/dist/cli/once.js CHANGED
@@ -11,20 +11,16 @@ export async function once() {
11
11
  const {
12
12
  loadConfig
13
13
  } = await import('./lib/loadConfig.js'); //// async function
14
-
15
14
  const userConfig = await loadConfig();
16
15
  const {
17
16
  applyConfigDefaults
18
17
  } = await import('./lib/applyConfigDefaults.js'); //// sync function
19
-
20
18
  const config = await applyConfigDefaults(userConfig);
21
19
  await log(chalk.brightblue`finding tests...`);
22
20
  const {
23
21
  findTestFiles
24
22
  } = await import('./lib/findTestFiles.js'); //// async function
25
-
26
23
  const testFiles = await findTestFiles(config);
27
-
28
24
  if (testFiles.length === 0) {
29
25
  await out(await chalk.orange(`[${packageName}] Found no tests.` + `\nTests patterns [${await config.tests.join(', ')}].` + `\nCreate tests matching the patterns, ` + `\nor set new patterns in ${configFileName}.* { tests: }`));
30
26
  const endTime = await new Date().getTime();
@@ -32,11 +28,9 @@ export async function once() {
32
28
  await out(await chalk.brightblue(`[${packageName}] time: ${await time.toLocaleString()}ms`));
33
29
  await process.exit(0);
34
30
  }
35
-
36
31
  const {
37
32
  runTests
38
33
  } = await import('./lib/runTests.js');
39
-
40
34
  if (testFiles.length > 0) {
41
35
  await log(chalk.brightblue`running tests...`);
42
36
  await runTests(config, testFiles, []); //// async function, run in thread
package/dist/cli/watch.js CHANGED
@@ -10,7 +10,6 @@ export async function watch() {
10
10
  const {
11
11
  parseCommandLineArguments
12
12
  } = await import('./lib/parseCommandLineArguments.js'); //// async function
13
-
14
13
  const allowedClArguments = {
15
14
  'config': {
16
15
  flag: 'c',
@@ -22,17 +21,14 @@ export async function watch() {
22
21
  const {
23
22
  loadConfig
24
23
  } = await import('./lib/loadConfig.js'); //// async function
25
-
26
24
  const userConfig = 'config' in clArguments ? await loadConfig(clArguments.config) : await loadConfig();
27
25
  const {
28
26
  applyConfigDefaults
29
27
  } = await import('./lib/applyConfigDefaults.js'); //// sync function
30
-
31
28
  const config = await applyConfigDefaults(userConfig);
32
29
  const {
33
30
  validateConfig
34
31
  } = await import('./lib/validateConfig.js'); //// sync function
35
-
36
32
  await validateConfig(config);
37
33
  const {
38
34
  doUserSetup
@@ -42,14 +38,13 @@ export async function watch() {
42
38
  const {
43
39
  findTestFiles
44
40
  } = await import('./lib/findTestFiles.js'); //// async function
45
-
46
41
  const testFiles = await findTestFiles(config);
47
- await debug(testFiles); // global store of the dependencies of tests
48
-
49
- let dependencyTrees = {}; // store failing tests so we can re-run them.
42
+ await debug(testFiles);
50
43
 
44
+ // global store of the dependencies of tests
45
+ let dependencyTrees = {};
46
+ // store failing tests so we can re-run them.
51
47
  const failingTests = [];
52
-
53
48
  if (testFiles.length > 0) {
54
49
  const {
55
50
  buildDependencyTrees
@@ -64,33 +59,42 @@ export async function watch() {
64
59
  await out(chalk.brightblue`running initial tests...`);
65
60
  runTests(config, testFiles, failingTests).then(async () => {
66
61
  await out(chalk.brightblue`watching...`);
67
- }); //// async function, run in separate thread
62
+ });
63
+ //// async function, run in separate thread
68
64
  }
69
65
  } else {
70
66
  await out(chalk.brightblue`no tests founds`);
67
+ await out(chalk.brightblue`watching...`);
71
68
  }
72
-
73
69
  const {
74
70
  watchFilesAndRunTests
75
71
  } = await import('./lib/watchFilesAndRunTests.js');
76
72
  await watchFilesAndRunTests(config, testFiles, dependencyTrees, failingTests); //// async function run in thread
77
73
 
78
- await new Promise(async () => {}); // won't run because promise will never finish
74
+ await new Promise(async () => {});
79
75
 
76
+ // won't run because promise will never finish
80
77
  const {
81
78
  doUserTeardown
82
79
  } = await import('./lib/doUserTeardown.js');
83
- await doUserTeardown(config); /////// SET UP?
80
+ await doUserTeardown(config);
81
+
82
+ /////// SET UP?
83
+
84
84
  // if ( typeof config.setup === 'function' ) {
85
85
  // await timeProfile('run setup function', config.setup(/* can we pass anything here? */))
86
86
  // }
87
- } // runInitialTests
87
+ }
88
+
89
+ // runInitialTests
90
+
88
91
  //--find tests
89
92
  //if found tests,
90
93
  // find dependencyTrees
91
94
  // also, run tests
92
95
  //else
93
96
  // warn
97
+
94
98
  // dn't run initial tests
95
99
  // do we need to find initial test? yes
96
100
  // find tests
@@ -1,22 +1,23 @@
1
1
  import figures from 'figures';
2
- import { applyConfigDefaults } from './lib/applyConfigDefaults.js';
2
+
3
+ //import { applyConfigDefaults } from './lib/applyConfigDefaults.js'
3
4
  import { watch } from './watch.js';
4
5
  await mochaDescribe('watch command', async function () {
5
6
  await mochaIt('should run tests and output results and display correct tallies', async function () {
6
7
  await this.timeout(10000);
7
8
  const originalConsoleLog = console.log;
8
9
  let consoleLogBuffer = '';
9
-
10
10
  console.log = function testLog(...texts) {
11
11
  consoleLogBuffer += texts.join(' ') + '\n';
12
12
  };
13
-
14
13
  global.commandLineArguments = ['--config', 'unitTesting/watch/sxy-test-runner.config.js'];
15
14
  watch();
16
15
  await new Promise(async (resolve, reject) => {
17
16
  await setTimeout(resolve, 8000);
18
17
  });
19
- console.log = originalConsoleLog; //console.log(consoleLogBuffer)
18
+ console.log = originalConsoleLog;
19
+
20
+ //console.log(consoleLogBuffer)
20
21
 
21
22
  const testFileName = `unitTesting/watch/1.test.js`;
22
23
  const thing = 'Sample test 1';
@@ -33,17 +34,17 @@ await mochaDescribe('watch command', async function () {
33
34
  await this.timeout(10000);
34
35
  const originalConsoleLog = console.log;
35
36
  let consoleLogBuffer = '';
36
-
37
37
  console.log = function testLog(...texts) {
38
38
  consoleLogBuffer += texts.join(' ') + '\n';
39
39
  };
40
-
41
40
  global.commandLineArguments = ['--config', 'unitTesting/watch/sxy-test-runner.config.js'];
42
41
  watch();
43
42
  await new Promise(async (resolve, reject) => {
44
43
  await setTimeout(resolve, 8000);
45
44
  });
46
- console.log = originalConsoleLog; //console.log(consoleLogBuffer)
45
+ console.log = originalConsoleLog;
46
+
47
+ //console.log(consoleLogBuffer)
47
48
 
48
49
  const testFileName = `unitTesting/watch/1.test.js`;
49
50
  const thing = 'Sample test 1';
@@ -57,17 +58,17 @@ await mochaDescribe('watch command', async function () {
57
58
  await this.timeout(6000);
58
59
  const originalConsoleLog = console.log;
59
60
  let consoleLogBuffer = '';
60
-
61
61
  console.log = function testLog(...texts) {
62
62
  consoleLogBuffer += texts.join(' ') + '\n';
63
63
  };
64
-
65
64
  global.commandLineArguments = ['--config', 'sxy-test-runner.no-tests.config.js'];
66
65
  watch();
67
66
  await new Promise(async (resolve, reject) => {
68
67
  await setTimeout(resolve, 4000);
69
68
  });
70
- console.log = originalConsoleLog; //console.log('saved console.log output:')
69
+ console.log = originalConsoleLog;
70
+
71
+ //console.log('saved console.log output:')
71
72
  //console.log(consoleLogBuffer)
72
73
 
73
74
  await consoleLogBuffer.should.include('no tests found');
@@ -77,20 +78,21 @@ await mochaDescribe('watch command', async function () {
77
78
  await this.timeout(6000);
78
79
  const originalConsoleLog = console.log;
79
80
  let consoleLogBuffer = '';
80
-
81
81
  console.log = function testLog(...texts) {
82
82
  consoleLogBuffer += texts.join(' ') + '\n';
83
83
  };
84
-
85
84
  global.commandLineArguments = ['--config', 'sxy-test-runner.no-initial-tests.config.js'];
86
85
  watch();
87
86
  await new Promise(async (resolve, reject) => {
88
87
  await setTimeout(resolve, 4000);
89
88
  });
90
- console.log = originalConsoleLog; //console.log('saved console.log output:')
89
+ console.log = originalConsoleLog;
90
+
91
+ //console.log('saved console.log output:')
91
92
  //console.log(consoleLogBuffer)
92
93
 
93
- await consoleLogBuffer.should.not.include('no tests found');
94
+ //consoleLogBuffer.should.not.include( 'no tests found' ) // not sure - removing for now
95
+ await consoleLogBuffer.should.not.include('running initial tests');
94
96
  await consoleLogBuffer.should.not.include('describing');
95
97
  await consoleLogBuffer.should.include('watching');
96
98
  });
@@ -100,11 +102,9 @@ await mochaDescribe('watch command', async function () {
100
102
  global.watchSetupFileHasRun = false;
101
103
  const originalConsoleLog = console.log;
102
104
  let consoleLogBuffer = '';
103
-
104
105
  console.log = function testLog(...texts) {
105
106
  consoleLogBuffer += texts.join(' ') + '\n';
106
107
  };
107
-
108
108
  global.commandLineArguments = ['--config', 'sxy-test-runner.setup-tasks.config.js'];
109
109
  watch();
110
110
  await new Promise(async (resolve, reject) => {
@@ -1,76 +1,91 @@
1
1
  import chalk from 'chalk-extensions';
2
2
  import { out, log, debug } from './output.js';
3
3
  import { showTimeProfiling } from './config.js';
4
- import { createTimeProfiler } from 'sxy-dev-tools'; //console.log('sxyDevTools', sxyDevTools)
4
+ import { createTimeProfiler } from 'sxy-dev-tools';
5
+
6
+ //console.log('sxyDevTools', sxyDevTools)
5
7
  //console.log('createTimeProfiler', createTimeProfiler)
6
8
 
7
9
  const {
8
10
  timeProfile,
9
11
  timeProfileAsync
10
- } = await createTimeProfiler(showTimeProfiling); //console.log('chalk', chalk)
12
+ } = await createTimeProfiler(showTimeProfiling);
13
+
14
+ //console.log('chalk', chalk)
11
15
 
12
16
  import { runTasks } from './cli/lib/runTasks.js';
13
17
  export async function describe(theThing, tests) {
14
- const config = global.__sxy_test_runner__.config; // if config.beforeEachDescribe
18
+ const config = global.__sxy_test_runner__.config;
19
+
20
+ // if config.beforeEachDescribe
15
21
  // const beforeEachDescribeExports = runTasks(config, config.beforeEachDescribe)
16
22
 
17
23
  const thisDescribeCounter = global.testState.describeCounter++; // ++: assign the value, THEN increment
18
24
 
19
25
  let itCounter = 1;
20
- const its = []; // create functions to pass back
21
- // it
26
+ const its = [];
27
+
28
+ // create functions to pass back
22
29
 
30
+ // it
23
31
  async function it(should, test) {
24
32
  // if config.beforeEachTest
25
33
  // const beforeEachTestExports = runTasks(config, config.beforeEachTest)
34
+
26
35
  const thisItCounter = itCounter++;
27
36
  await its.push({
28
37
  counter: thisItCounter,
29
38
  should,
30
- test //beforeEachTestExports
39
+ test
40
+ //beforeEachTestExports
41
+ });
31
42
 
32
- }); // if config.afterEachTest
43
+ // if config.afterEachTest
33
44
  // runTasks(config, config.afterEachTest)
34
- } // before
35
-
45
+ }
36
46
 
47
+ // before
37
48
  let beforeFunc;
38
-
39
49
  async function before(func) {
40
50
  beforeFunc = func;
41
- } // after
42
-
51
+ }
43
52
 
53
+ // after
44
54
  let afterFunc;
45
-
46
55
  async function after(func) {
47
56
  afterFunc = func;
48
57
  }
49
-
50
58
  const provides = {
51
59
  it,
52
60
  before,
53
61
  after
54
- }; // addExports(provides, beforeEachDescribeExports)
55
- // run the callback, to set the its
62
+ };
63
+
64
+ // addExports(provides, beforeEachDescribeExports)
56
65
 
66
+ // run the callback, to set the its
57
67
  await tests({
58
68
  it,
59
69
  before,
60
70
  after
61
- }); //tests(provides)
71
+ });
72
+ //tests(provides)
62
73
 
63
74
  const describe = {
64
75
  counter: thisDescribeCounter,
65
76
  thing: theThing,
66
- its //beforeEachDescribeExports
67
-
77
+ its
78
+ //beforeEachDescribeExports
68
79
  };
69
- await global.testState.describes.push(describe); // if config.afterEachDescribe
80
+
81
+ await global.testState.describes.push(describe);
82
+
83
+ // if config.afterEachDescribe
70
84
  // runTasks(config, config.afterEachDescribe)
71
85
 
72
86
  await debug(chalk.lightgrey`${thisDescribeCounter})` + chalk.lightgrey` Done with ` + chalk.brightblue`${theThing}\n`);
73
87
  }
88
+
74
89
  /*
75
90
 
76
91
 
@@ -1,21 +1,30 @@
1
1
  import { describe } from './describe-old.js';
2
- await mochaDescribe('watch command', async function () {// mochaIt('should run tests and output results', async function() {
2
+ await mochaDescribe('watch command', async function () {
3
+
4
+ // mochaIt('should run tests and output results', async function() {
3
5
  // this.timeout(6000)
6
+
4
7
  // const originalConsoleLog = console.log
5
8
  // let consoleLogBuffer = ''
6
9
  // console.log = sync(function testLog(...texts) {
7
10
  // consoleLogBuffer += texts.join(' ') + '\n'
8
11
  // })
12
+
9
13
  // global.commandLineArguments = []
14
+
10
15
  // promise( watch() )
11
16
  // await new Promise( (resolve, reject) => { setTimeout(resolve, 3000) } )
17
+
12
18
  // console.log = originalConsoleLog
19
+
13
20
  // const testFileName = `dist/testing/example.test.js`
14
21
  // const thing = 'The example'
15
22
  // const should = '1 should equal 1'
23
+
16
24
  // consoleLogBuffer.should.include( testFileName )
17
25
  // consoleLogBuffer.should.include( thing )
18
26
  // consoleLogBuffer.should.include( should )
19
27
  // consoleLogBuffer.should.include( figures.tick )
28
+
20
29
  // })
21
30
  });
package/dist/describe.js CHANGED
@@ -1,13 +1,17 @@
1
1
  import chalk from 'chalk-extensions';
2
2
  import { out, log, debug } from './output.js';
3
3
  import { showTimeProfiling } from './config.js';
4
- import { createTimeProfiler } from 'sxy-dev-tools'; //console.log('sxyDevTools', sxyDevTools)
4
+ import { createTimeProfiler } from 'sxy-dev-tools';
5
+
6
+ //console.log('sxyDevTools', sxyDevTools)
5
7
  //console.log('createTimeProfiler', createTimeProfiler)
6
8
 
7
9
  const {
8
10
  timeProfile,
9
11
  timeProfileAsync
10
- } = await createTimeProfiler(showTimeProfiling); //console.log('chalk', chalk)
12
+ } = await createTimeProfiler(showTimeProfiling);
13
+
14
+ //console.log('chalk', chalk)
11
15
 
12
16
  export async function describe(theThing, tests) {
13
17
  //const thisDescribeCounter = global.testState.describeCounter++ // ++: assign the value, THEN increment
@@ -17,8 +21,9 @@ export async function describe(theThing, tests) {
17
21
  counter: thisDescribeCounter,
18
22
  thing: theThing,
19
23
  tests
20
- }; //global.testState.describes.push( describe )
24
+ };
21
25
 
26
+ //global.testState.describes.push( describe )
22
27
  await global.__sxy_test_runner__.describes.push(describe);
23
28
  await debug(chalk.lightgrey`${thisDescribeCounter})` + chalk.lightgrey` Done with ` + chalk.brightblue`${theThing}\n`);
24
29
  }
@@ -1,11 +1,14 @@
1
1
  import { expect } from 'chai';
2
- import { describe } from './describe.js'; //import { createLoad } from 'sxy-loader'
2
+ import { describe } from './describe.js';
3
+
4
+ //import { createLoad } from 'sxy-loader'
3
5
  //const load = createLoad(import.meta.url)
4
6
 
5
7
  await mochaDescribe('new describe() function', async function () {
6
8
  await mochaIt('should run tests and output results', async function () {
7
- await this.timeout(6000); // eslint-disable-next-line camelcase
9
+ await this.timeout(6000);
8
10
 
11
+ // eslint-disable-next-line camelcase
9
12
  global.__sxy_test_runner__ = {
10
13
  describes: [],
11
14
  describeCounter: 1
@@ -1,13 +1,11 @@
1
1
  export const indexNumberToLetters = function indexNumberToLetters(number, uppercase = false) {
2
2
  const charCodeStart = uppercase ? 65 : 97;
3
3
  var text = '',
4
- letterIndex;
5
-
4
+ letterIndex;
6
5
  while (number > 0) {
7
6
  letterIndex = (number - 1) % 26;
8
7
  text = String.fromCharCode(charCodeStart + letterIndex) + text;
9
8
  number = (number - letterIndex) / 26 | 0;
10
9
  }
11
-
12
10
  return text || undefined;
13
11
  };