sxy-test-runner 1.0.14 → 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 +79 -72
  77. package/readme.md +1 -1
  78. package/sxy-loader.config.js +10 -10
package/dist/cli/index.js CHANGED
@@ -1,31 +1,27 @@
1
1
  #!/usr/bin/env node
2
+
3
+ // need to change this to a safe version
2
4
  import 'sxy-standard';
3
5
  import 'sxy-standard-object-copy';
4
6
  const args = await process.argv.slice(2);
5
-
6
7
  if (args.length > 0) {
7
8
  const command = args[0];
8
-
9
9
  switch (command) {
10
10
  case 'init':
11
11
  await doCommand(command, await args.slice(1));
12
12
  break;
13
-
14
13
  case 'once':
15
14
  await doCommand(command, await args.slice(1));
16
15
  break;
17
-
18
16
  case 'watch':
19
17
  await doCommand(command, await args.slice(1));
20
18
  break;
21
-
22
19
  default:
23
20
  await doCommand('watch', args);
24
21
  }
25
22
  } else {
26
23
  await doCommand('watch', args);
27
24
  }
28
-
29
25
  async function doCommand(command, args) {
30
26
  global.commandLineArguments = args;
31
27
  await (await import(`./${command}.js`))[command]();
package/dist/cli/init.js CHANGED
@@ -5,43 +5,33 @@ import { out, log, debug } from '../output.js';
5
5
  import fs from 'fs';
6
6
  export async function init() {
7
7
  const projectDir = await process.cwd();
8
-
9
8
  for (const configLocation of configLocations) {
10
9
  let loc;
11
10
  loc = await join(projectDir, configLocation, configFileName + '.js');
12
-
13
11
  if (await fs.existsSync(loc)) {
14
12
  await configAlreadyExists(loc);
15
13
  }
16
-
17
14
  loc = await join(projectDir, configLocation, configFileName + '.cjs');
18
-
19
15
  if (await fs.existsSync(loc)) {
20
16
  await configAlreadyExists(loc);
21
17
  }
22
-
23
18
  loc = await join(projectDir, configLocation, configFileName + '.mjs');
24
-
25
19
  if (await fs.existsSync(loc)) {
26
20
  await configAlreadyExists(loc);
27
21
  }
28
22
  }
29
-
30
23
  async function configAlreadyExists(loc) {
31
24
  await out(chalk.orange`[${packageName}] A matching config already exists at ${loc}` + `\nPlease remove this config before generating a new one with \`${cliName} init\``);
32
25
  }
33
-
34
26
  const projectPackageJsonLocation = await join(projectDir, 'package.json');
35
-
36
27
  if (!(await fs.existsSync(projectPackageJsonLocation))) {
37
28
  await out(chalk.orange`[${packageName}] No package.json exists in this location` + `\nPlease initialise the package with \`yarn init\` on \`npm init\`` + ` before running this command, and run this command from the project root folder`);
38
- } //const packageJsonRaw = await fs.promises.readFile( projectPackageJsonLocation )
39
-
29
+ }
40
30
 
31
+ //const packageJsonRaw = await fs.promises.readFile( projectPackageJsonLocation )
41
32
  const packageJsonRaw = await fs.readFileSync(projectPackageJsonLocation);
42
33
  const packageJson = await JSON.parse(packageJsonRaw);
43
34
  let targetConfigName;
44
-
45
35
  if (packageJson.type === 'module') {
46
36
  // ES6 module
47
37
  targetConfigName = await join(projectDir, configLocations[0], configFileName + '.js');
@@ -49,7 +39,6 @@ export async function init() {
49
39
  // common
50
40
  targetConfigName = await join(projectDir, configLocations[0], configFileName + '.mjs');
51
41
  }
52
-
53
42
  const defaultConfig = `export default {
54
43
 
55
44
  // base folder for tests match and ignore patterns
@@ -130,9 +119,12 @@ export async function init() {
130
119
 
131
120
  },
132
121
 
133
- }`; // `export default {
122
+ }`;
123
+ // `export default {
124
+
134
125
  // // base folder for tests match and ignore patterns
135
126
  // testsBase: '.',
127
+
136
128
  // // glob pattern or array of glob patterns of test files
137
129
  // tests: [
138
130
  // '**/*.test.{js,mjs,jsx}',
@@ -140,29 +132,42 @@ export async function init() {
140
132
  // '**/tests?/*.{js,mjs,jsx}',
141
133
  // '**/__tests?__/*.{js,mjs,jsx}'
142
134
  // ],
135
+
143
136
  // // glob pattern or array of patterns of test files to ignore
144
137
  // testsIgnore: ['**/node_modules/**/*'],
138
+
145
139
  // // function to run on startup
146
140
  // setup: undefined,
141
+
147
142
  // // function to run before each test file
148
143
  // setupEach: undefined,
144
+
149
145
  // // function to run after test run
150
146
  // teardown: undefined,
147
+
151
148
  // // function to run after each test file
152
149
  // teardownEach: undefined,
150
+
153
151
  // // watch mode configurations
154
152
  // watch: {
153
+
155
154
  // //// the base directory to watch files in
156
155
  // watchFilesBase: '.',
156
+
157
157
  // //// glob filter or array of glob filters of files to watch
158
158
  // watchFiles: '**/*.js',
159
+
159
160
  // //// glob filter or array of globl filters of files to ignore
160
161
  // watchFilesIgnore: '**/node_modules/**/*',
162
+
161
163
  // // run all tests when starting the watcher
162
164
  // runAllOnStartup: true,
165
+
163
166
  // // re run all previously failed tests on each test run, until they pass
164
167
  // reRunFailingTests: true,
168
+
165
169
  // },
170
+
166
171
  // }`
167
172
 
168
173
  await fs.writeFileSync(targetConfigName, defaultConfig);
@@ -9,7 +9,6 @@ export async function addBasePath(base, items) {
9
9
  if (base !== undefined && base !== '.' && base !== '') {
10
10
  items = (await Array.isArray(items)) ? await items.map(item => `${base}/${item}`) : `${base}/${items}`;
11
11
  }
12
-
13
12
  return items;
14
13
  });
15
14
  }
@@ -1,5 +1,7 @@
1
1
  import { addBasePath } from './addBasePath.js';
2
- import { join } from 'path'; // addBaseToGlobs(base, globs)
2
+ import { join } from 'path';
3
+
4
+ // addBaseToGlobs(base, globs)
3
5
  // base: string
4
6
  // globs: string or array of strings
5
7
 
@@ -1,6 +1,8 @@
1
1
  import { expect } from 'chai';
2
2
  import { defaultConfig } from './defaultConfig.js';
3
- import { addExports } from './addExports.js'; // applyConfigDefaults( userConfig: {} )
3
+ import { addExports } from './addExports.js';
4
+
5
+ // applyConfigDefaults( userConfig: {} )
4
6
 
5
7
  import { makeCustomOut } from '../../../unitTesting/makeCustomOut.js';
6
8
  await mochaDescribe('addExports() function', async function () {
@@ -15,6 +17,7 @@ await mochaDescribe('addExports() function', async function () {
15
17
  });
16
18
  await mochaIt('should complain about duplicates', async function () {
17
19
  //const { customOut, getOutBuffer, setOutBuffer } = makeCustomOut()
20
+
18
21
  const exports = {
19
22
  a: 1,
20
23
  b: 2
@@ -1,7 +1,9 @@
1
1
  import { mergeStructuredConfig, createTimeProfiler } from 'sxy-dev-tools';
2
+ import objectCopy from 'sxy-lib-object-copy';
2
3
  import { packageName, cliName, configFileName, configLocations, showTimeProfiling } from '../../config.js';
3
- import chalk from 'chalk-extensions';
4
- import { out, log, debug } from '../../output.js';
4
+ //import chalk from 'chalk-extensions'
5
+ //import { out, log, debug } from '../../output.js'
6
+
5
7
  import { defaultConfig } from './defaultConfig.js';
6
8
  const {
7
9
  timeProfileAsync
@@ -11,22 +13,26 @@ export async function applyConfigDefaults(userConfig) {
11
13
  const configStructure = {
12
14
  execution: {},
13
15
  watch: {}
14
- }; //const config = mergeConfig(configStructure, defaultConfig, userConfig)
16
+ };
17
+
18
+ //const config = mergeConfig(configStructure, defaultConfig, userConfig)
19
+ const config = await mergeStructuredConfig(configStructure, defaultConfig, userConfig);
15
20
 
16
- const config = await mergeStructuredConfig(configStructure, defaultConfig, userConfig); // I don't think we need to do these - the glob combine func can handle it
21
+ // I don't think we need to do these - the glob combine func can handle it
17
22
  //if ( ! Array.isArray(config.tests) ) config.tests = [config.tests]
18
23
  //if ( ! Array.isArray(config.testsIgnore) ) config.tests = [config.testsIgnore]
19
24
  // watchFiles
20
25
  // watchFilesIgnore
26
+
21
27
  //log('final config', config)
22
28
 
23
29
  return config;
24
30
  });
25
31
  }
26
32
 
33
+ // is this an old func now replaced?
27
34
  async function mergeConfig(structure, baseConfig, ...extraConfigs) {
28
- const finalConfig = await Object.copy(baseConfig);
29
-
35
+ const finalConfig = await objectCopy(baseConfig);
30
36
  for (const extraConfig of extraConfigs) {
31
37
  for (const key in extraConfig) {
32
38
  if (key in structure) {
@@ -36,6 +42,5 @@ async function mergeConfig(structure, baseConfig, ...extraConfigs) {
36
42
  }
37
43
  }
38
44
  }
39
-
40
45
  return finalConfig;
41
46
  }
@@ -1,5 +1,7 @@
1
1
  import { defaultConfig } from './defaultConfig.js';
2
- import { applyConfigDefaults } from './applyConfigDefaults.js'; // applyConfigDefaults( userConfig: {} )
2
+ import { applyConfigDefaults } from './applyConfigDefaults.js';
3
+
4
+ // applyConfigDefaults( userConfig: {} )
3
5
 
4
6
  await mochaDescribe('applyConfigDefaults() function', async function () {
5
7
  await mochaIt('has sensible defaults when passed an empty user config', async function () {
@@ -9,7 +11,9 @@ await mochaDescribe('applyConfigDefaults() function', async function () {
9
11
  await mochaIt('retains a passed config setting', async function () {
10
12
  const finalConfig = await applyConfigDefaults({
11
13
  tests: 'foo'
12
- }); //console.log(finalConfig)
14
+ });
15
+
16
+ //console.log(finalConfig)
13
17
 
14
18
  await finalConfig.tests.should.equal('foo');
15
19
  });
@@ -18,7 +22,9 @@ await mochaDescribe('applyConfigDefaults() function', async function () {
18
22
  watch: {
19
23
  watchFilesBase: 'src'
20
24
  }
21
- }); //console.log(finalConfig)
25
+ });
26
+
27
+ //console.log(finalConfig)
22
28
 
23
29
  await finalConfig.watch.watchFiles.should.equal(defaultConfig.watch.watchFiles);
24
30
  });
@@ -4,6 +4,7 @@ import slash from 'slash';
4
4
  import 'sxy-standard/light.js';
5
5
  export async function buildDependencyTree(config, filename) {
6
6
  filename = await slash(filename); // convert to forward slashes
7
+
7
8
  // const filter = path =>
8
9
  // minimatch(path, watchFiles)
9
10
  // && ! minimatch(path, watchFilesIgnores)
@@ -14,19 +15,23 @@ export async function buildDependencyTree(config, filename) {
14
15
  //directory: './src',
15
16
  directory: config.watch.watchFilesBase,
16
17
  filter: path => path.indexOf('node_modules') === -1
17
- }; //// this filter needs to be replaced
18
+ };
19
+ //// this filter needs to be replaced
18
20
 
19
- const dt = await dependencyTree(dependencyTreeConfig); // process the results into final format
20
- // (forward slashes and convert full path to rel path)
21
+ const dt = await dependencyTree(dependencyTreeConfig);
21
22
 
23
+ // process the results into final format
24
+ // (forward slashes and convert full path to rel path)
22
25
  const cwd = await process.cwd();
23
- await dt.process(file => slash(file).slice(cwd.length + 1)); // remove the current file
26
+ await dt.process(file => slash(file).slice(cwd.length + 1));
24
27
 
28
+ // remove the current file
25
29
  await dt.forEach(file => {
26
30
  if (file === filename) {
27
- dt.remove(file);
31
+ dt.remove(file); // arrayRemove?
28
32
  }
29
33
  });
34
+
30
35
  await debug('found dep tree', dt);
31
36
  return dt;
32
37
  }
@@ -1,6 +1,8 @@
1
1
  import { applyConfigDefaults } from './applyConfigDefaults.js';
2
2
  import { buildDependencyTree } from './buildDependencyTree.js';
3
- import { join } from 'path'; // buildDependencyTree(config, file)
3
+ import { join } from 'path';
4
+
5
+ // buildDependencyTree(config, file)
4
6
  // config:
5
7
  // file: relative to config.watch.watchFilesBase
6
8
 
@@ -11,19 +11,21 @@ export async function buildDependencyTrees(config, testFiles) {
11
11
  return await timeProfileAsync('build dependency trees', async () => {
12
12
  const projectDir = await process.cwd();
13
13
  const dependencyTrees = {};
14
-
15
14
  for (const testFile of testFiles) {
16
15
  //newTest(testFile.replace('./', ''))
16
+
17
17
  const dependencyTree = await buildDependencyTree(config, testFile);
18
- dependencyTrees[testFile] = dependencyTree; // .map ( sync( file => immed(immed(slash(file)).slice(projectDir.length + 1) )) )
18
+ dependencyTrees[testFile] = dependencyTree;
19
+ // .map ( sync( file => immed(immed(slash(file)).slice(projectDir.length + 1) )) )
19
20
  // .filter( sync(f => immed(f !== testFile)) )
20
21
 
21
22
  await debug('final dep tree', dependencyTrees[testFile]);
22
23
  }
23
-
24
24
  return dependencyTrees;
25
25
  });
26
- } // function newTest(testFile) {
26
+ }
27
+
28
+ // function newTest(testFile) {
27
29
  // debug('new test', testFile)
28
30
  // const dependencyTree = buildDependencyTree(testFile)
29
31
  // //out('AA dependencyTree', testFile, dependencyTree)
@@ -1,6 +1,8 @@
1
1
  import { applyConfigDefaults } from './applyConfigDefaults.js';
2
2
  import { buildDependencyTrees } from './buildDependencyTrees.js';
3
- import { join } from 'path'; // buildDependencyTrees(config, files)
3
+ import { join } from 'path';
4
+
5
+ // buildDependencyTrees(config, files)
4
6
  // config:
5
7
  // files: relative to config.watch.watchFilesBase
6
8
 
@@ -1,4 +1,6 @@
1
- import { defaultConfig } from './defaultConfig.js'; // applyConfigDefaults( userConfig: {} )
1
+ import { defaultConfig } from './defaultConfig.js';
2
+
3
+ // applyConfigDefaults( userConfig: {} )
2
4
 
3
5
  await mochaDescribe('the defaultConfig', async function () {
4
6
  await mochaIt('has sensible defaults', async function () {
@@ -3,7 +3,6 @@ import { out, log, debug } from '../../output.js';
3
3
  export async function doUserSetup(config) {
4
4
  if (config.setup) {
5
5
  const setupTasks = (await Array.isArray(config.setup)) ? config.setup : [config.setup];
6
-
7
6
  for (const setupTask of setupTasks) {
8
7
  //console.log( typeof setupTask, setupTask)
9
8
  switch (typeof setupTask) {
@@ -12,13 +11,11 @@ export async function doUserSetup(config) {
12
11
  await setupTask();
13
12
  break;
14
13
  }
15
-
16
14
  case 'string':
17
15
  {
18
16
  await import(`file://${await join(await process.cwd(), setupTask)}`);
19
17
  break;
20
18
  }
21
-
22
19
  default:
23
20
  {
24
21
  await out(`Error: setup entry has an invalid type, expected 'function' or 'string' of an file to import.`);
@@ -1,5 +1,7 @@
1
1
  import { applyConfigDefaults } from './applyConfigDefaults.js';
2
- import { doUserSetup } from './doUserSetup.js'; // applyConfigDefaults( userConfig: {} )
2
+ import { doUserSetup } from './doUserSetup.js';
3
+
4
+ // applyConfigDefaults( userConfig: {} )
3
5
 
4
6
  await mochaDescribe('the doUserSetup() function', async function () {
5
7
  await mochaIt('executes a user setup function', async function () {
@@ -3,7 +3,6 @@ import { out, log, debug } from '../../output.js';
3
3
  export async function doUserTeardown(config) {
4
4
  if (config.teardown) {
5
5
  const teardownTasks = (await Array.isArray(config.teardown)) ? config.teardown : [config.teardown];
6
-
7
6
  for (const teardownTask of teardownTasks) {
8
7
  //console.log( typeof teardownTask, teardownTask)
9
8
  switch (typeof teardownTask) {
@@ -12,13 +11,11 @@ export async function doUserTeardown(config) {
12
11
  await teardownTask();
13
12
  break;
14
13
  }
15
-
16
14
  case 'string':
17
15
  {
18
16
  await import(`file://${await join(await process.cwd(), teardownTask)}`);
19
17
  break;
20
18
  }
21
-
22
19
  default:
23
20
  {
24
21
  await out(`Error: teardown entry has an invalid type, expected 'function' or 'string' of an file to import.`);
@@ -1,5 +1,7 @@
1
1
  import { applyConfigDefaults } from './applyConfigDefaults.js';
2
- import { doUserTeardown } from './doUserTeardown.js'; // applyConfigDefaults( userConfig: {} )
2
+ import { doUserTeardown } from './doUserTeardown.js';
3
+
4
+ // applyConfigDefaults( userConfig: {} )
3
5
 
4
6
  await mochaDescribe('the doUserTeardown() function', async function () {
5
7
  await mochaIt('executes a user teardown function', async function () {
@@ -1,5 +1,7 @@
1
1
  import { applyConfigDefaults } from './applyConfigDefaults.js';
2
- import { findTestFiles } from './findTestFiles.js'; // findTestFiles(config)
2
+ import { findTestFiles } from './findTestFiles.js';
3
+
4
+ // findTestFiles(config)
3
5
 
4
6
  await mochaDescribe('findTestFiles() function', async function () {
5
7
  await mochaIt('finds the tests files', async function () {
@@ -1,11 +1,9 @@
1
1
  export async function getAllowedFlags(allowedArguments) {
2
2
  const allowedFlags = {};
3
-
4
3
  for (const option in allowedArguments) {
5
4
  if ('flag' in allowedArguments[option]) {
6
5
  allowedFlags[allowedArguments[option].flag] = option;
7
6
  }
8
7
  }
9
-
10
8
  return allowedFlags;
11
9
  }
@@ -1,4 +1,6 @@
1
- import { getAllowedFlags } from './getAllowedFlags.js'; // findTestFiles(config)
1
+ import { getAllowedFlags } from './getAllowedFlags.js';
2
+
3
+ // findTestFiles(config)
2
4
 
3
5
  await mochaDescribe('getAllowedFlags() function', async function () {
4
6
  await mochaIt('extracts the flags from an allowedArguments object', async function () {
@@ -2,10 +2,10 @@ import { out as mainOut, log, debug } from '../../output.js';
2
2
  const reservedKeys = ['describe', 'test', 'it', 'before', 'after', 'beforeEach', 'afterEach', 'beforeAll', 'afterAll'];
3
3
  export async function injectProperties(basePackage, injectProperties, from, customOut = undefined) {
4
4
  const out = customOut ? async (...texts) => await customOut(...texts) : async (...texts) => await mainOut(...texts);
5
-
6
5
  for (const key in injectProperties) {
7
6
  if (await reservedKeys.includes(key)) {
8
- await out(`Error: key '${key}' is reserved. Please do not use this key. From '${from}'.`); //process.exit(1)
7
+ await out(`Error: key '${key}' is reserved. Please do not use this key. From '${from}'.`);
8
+ //process.exit(1)
9
9
  }
10
10
  }
11
11
  }
@@ -3,7 +3,6 @@ import chalk from 'chalk-extensions';
3
3
  await mochaDescribe('injectProperties() function', async function () {
4
4
  await mochaIt('complains if a reserved property is given', async function () {
5
5
  let outBuffer = '';
6
-
7
6
  const customOut = (...texts) => {
8
7
  //console.log(chalk.red`outBuffer1`, outBuffer)
9
8
  console.log(...texts);
@@ -56,20 +55,28 @@ await mochaDescribe('injectProperties() function', async function () {
56
55
  };
57
56
  await injectProperties(basePacket, properties, '', customOut);
58
57
  await outBuffer.should.include(errorString);
59
- }); // mochaIt('complains if a passed property conflics with a base property', function() {
58
+ });
59
+
60
+ // mochaIt('complains if a passed property conflics with a base property', function() {
61
+
60
62
  // let outBuffer = ''
61
63
  // const customOut = sync((...texts) => {
62
64
  // console.log(...texts)
63
65
  // outBuffer += texts.join(' ') + '\n' // join and save to the buffer
64
66
  // })
67
+
65
68
  // const errorString = 'is reserved'
69
+
66
70
  // const basePacket = {}
71
+
67
72
  // let properties
73
+
68
74
  // outBuffer = ''
69
75
  // properties = {
70
76
  // describe: true
71
77
  // }
72
78
  // injectProperties(basePacket, properties, '', customOut)
73
79
  // outBuffer.should.include(errorString)
80
+
74
81
  // })
75
82
  });
@@ -9,12 +9,12 @@ export async function loadConfig(customLocation = undefined) {
9
9
  return await timeProfileAsync('load config', async () => {
10
10
  const configOrNull = customLocation !== undefined ? await sxyLoadConfigExact(customLocation) : await sxyLoadConfig(configFileName, configLocations);
11
11
  await debug('configOrNull', typeof configOrNull, configOrNull);
12
-
13
12
  if (!configOrNull) {
14
13
  await out(await chalk.orange(`[${packageName}] No config found.` + `\nPlease create a ${configFileName}.js/cjs/mjs file in your project root or /config folder.` + `\nOr run \`npx ${cliName} init\` to create one.`));
15
14
  await process.exit(0);
16
- } //log('user config', configOrNull)
15
+ }
17
16
 
17
+ //log('user config', configOrNull)
18
18
 
19
19
  return configOrNull;
20
20
  });
@@ -1,6 +1,7 @@
1
- import { loadConfig } from "./loadConfig.js"; // loadConfig(location)
2
- // location is option
1
+ import { loadConfig } from "./loadConfig.js";
3
2
 
3
+ // loadConfig(location)
4
+ // location is option
4
5
  await mochaDescribe('loadConfig() function', async function () {
5
6
  await mochaIt('loads a user config', async function () {
6
7
  const userConfig = await loadConfig();
@@ -14,34 +14,35 @@ export async function loadTestFile(config, testFile) {
14
14
  await loading;
15
15
  await debug(chalk.yellow`previous file complete - will now load the file`);
16
16
  }
17
-
18
17
  const loadPromise = timeProfileAsync(`load test ${testFile}`, async () => {
19
- const projectDir = await process.cwd(); // eslint-disable-next-line camelcase
18
+ const projectDir = await process.cwd();
20
19
 
20
+ // eslint-disable-next-line camelcase
21
21
  global.__sxy_test_runner__ = {
22
22
  describes: [],
23
23
  describeCounter: 1
24
24
  };
25
- const testFileFullUrl = 'file://' + (await join(projectDir, testFile)); //console.log('testFileFullUrl', testFileFullUrl)
25
+ const testFileFullUrl = 'file://' + (await join(projectDir, testFile));
26
+
27
+ //console.log('testFileFullUrl', testFileFullUrl)
26
28
 
27
29
  const test = {
28
30
  file: testFile
29
31
  };
30
- const capturingConsoleLog = config.execution.files === 'sequential'; //// capture console.log output
32
+ const capturingConsoleLog = config.execution.files === 'sequential';
31
33
 
34
+ //// capture console.log output
32
35
  let previousConsoleLog;
33
36
  const logs = [];
34
-
35
37
  if (capturingConsoleLog) {
36
38
  previousConsoleLog = console.log; // eslint-disable-line no-console
37
-
38
39
  console.log = async (...texts) => await logs.push(texts); // eslint-disable-line no-console
39
-
40
- } ////
41
-
40
+ }
41
+ ////
42
42
 
43
43
  try {
44
- await load(testFileFullUrl, {// scopeObject: { // experimental idea
44
+ await load(testFileFullUrl, {
45
+ // scopeObject: { // experimental idea
45
46
  // name: 'scope',
46
47
  // contents: {},
47
48
  // exposeObject: 'scope'
@@ -53,21 +54,22 @@ export async function loadTestFile(config, testFile) {
53
54
  //error(chalk.red`Error loading file ${testFileFullUrl}`)
54
55
  test.error = `Error loading file\n${e}`;
55
56
  } finally {
56
- test.logs = logs; //// restore previous console.log function
57
-
57
+ test.logs = logs;
58
+ //// restore previous console.log function
58
59
  if (capturingConsoleLog) {
59
60
  if (capturingConsoleLog) {
60
61
  console.log = previousConsoleLog; // eslint-disable-line no-console
61
62
  }
62
- } ////
63
+ }
64
+ ////
65
+ }
63
66
 
64
- } // console.log()
67
+ // console.log()
65
68
  // console.log('test', test)
66
69
  // console.log('describes', test.describes)
67
70
  // console.log('its', test.describes[0].its)
68
71
  // console.log()
69
72
 
70
-
71
73
  return test;
72
74
  });
73
75
  loading = loadPromise;
@@ -1,5 +1,7 @@
1
1
  import { loadTestFile } from "./loadTestFile.js";
2
- import { defaultConfig } from './defaultConfig.js'; // loadTestFile(config, testFile) ???
2
+ import { defaultConfig } from './defaultConfig.js';
3
+
4
+ // loadTestFile(config, testFile) ???
3
5
 
4
6
  await mochaDescribe('loadTestFile() function', async function () {
5
7
  /*
@@ -36,10 +38,13 @@ await mochaDescribe('loadTestFile() function', async function () {
36
38
  await mochaIt('should correctly load a file with describes without any its/tests', async function () {
37
39
  const config = defaultConfig;
38
40
  const sampleTestFile = 'unitTesting/sampleTests/describesWithoutTests.test.js';
39
- const test = await loadTestFile(config, sampleTestFile); //console.log('ut test', test)
41
+ const test = await loadTestFile(config, sampleTestFile);
42
+
43
+ //console.log('ut test', test)
40
44
 
41
45
  await test.describes.length.should.equal(2);
42
46
  await (await test.describes.at(-1)).counter.should.equal(2);
43
- await test.describes[0].tests.should.be.a('function'); //test.describes.at(-1).its.at(-1).counter.should.equal(2)
47
+ await test.describes[0].tests.should.be.a('function');
48
+ //test.describes.at(-1).its.at(-1).counter.should.equal(2)
44
49
  });
45
50
  });
@@ -1,3 +1,4 @@
1
+
1
2
  /*
2
3
 
3
4
  I can't remember what this was for.
@@ -1,3 +1,4 @@
1
+
1
2
  /*
2
3
  import { loadTestFileStatic } from "./loadTestFileStatic.js"
3
4
  import { applyConfigDefaults } from './applyConfigDefaults.js'