sxy-test-runner 1.0.3 → 1.0.4

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 (95) hide show
  1. package/package.json +1 -1
  2. package/dist/cli/init.js +0 -170
  3. package/dist/cli/init.unitTest.js +0 -0
  4. package/dist/cli/lib/addBasePath.js +0 -15
  5. package/dist/cli/lib/addBasePath.unitTest.js +0 -31
  6. package/dist/cli/lib/addExports.js +0 -12
  7. package/dist/cli/lib/addExports.unitTest.js +0 -29
  8. package/dist/cli/lib/applyConfigDefaults.js +0 -41
  9. package/dist/cli/lib/applyConfigDefaults.unitTest.js +0 -25
  10. package/dist/cli/lib/buildDependencyTree.js +0 -32
  11. package/dist/cli/lib/buildDependencyTree.unitTest.js +0 -15
  12. package/dist/cli/lib/buildDependencyTrees.js +0 -34
  13. package/dist/cli/lib/buildDependencyTrees.unitTest.js +0 -17
  14. package/dist/cli/lib/configBeforeAfterFuncs.js +0 -35
  15. package/dist/cli/lib/configBeforeAfterFuncs.unitTest.js +0 -0
  16. package/dist/cli/lib/defaultConfig.js +0 -22
  17. package/dist/cli/lib/defaultConfig.test.js +0 -7
  18. package/dist/cli/lib/doUserSetup.js +0 -30
  19. package/dist/cli/lib/doUserSetup.unitTest.js +0 -39
  20. package/dist/cli/lib/doUserTeardown.js +0 -30
  21. package/dist/cli/lib/doUserTeardown.unitTest.js +0 -39
  22. package/dist/cli/lib/findTestFiles.js +0 -24
  23. package/dist/cli/lib/findTestFiles.unitTest.js +0 -22
  24. package/dist/cli/lib/getAllowedFlags.js +0 -11
  25. package/dist/cli/lib/getAllowedFlags.unitTest.js +0 -20
  26. package/dist/cli/lib/globArgCombine.js +0 -1
  27. package/dist/cli/lib/globArgCombine.unitTest.js +0 -18
  28. package/dist/cli/lib/injectProperties.js +0 -11
  29. package/dist/cli/lib/injectProperties.unitTest.js +0 -75
  30. package/dist/cli/lib/load.js +0 -3
  31. package/dist/cli/lib/load.unitTest.js +0 -7
  32. package/dist/cli/lib/loadConfig.js +0 -21
  33. package/dist/cli/lib/loadConfig.unitTest.js +0 -15
  34. package/dist/cli/lib/loadTestFile.js +0 -75
  35. package/dist/cli/lib/loadTestFile.unitTest.js +0 -51
  36. package/dist/cli/lib/loadTestFileStatic.js +0 -40
  37. package/dist/cli/lib/loadTestFileStatic.unitTest.js +0 -29
  38. package/dist/cli/lib/overrideConsoleLog.js +0 -20
  39. package/dist/cli/lib/overrideConsoleLog.unitTest.js +0 -0
  40. package/dist/cli/lib/parseCommandLineArguments.js +0 -57
  41. package/dist/cli/lib/parseCommandLineArguments.unitTest.js +0 -21
  42. package/dist/cli/lib/processWatchEvent.js +0 -0
  43. package/dist/cli/lib/processWatchEvent.unitTest.js +0 -7
  44. package/dist/cli/lib/reservedExportKeys.js +0 -1
  45. package/dist/cli/lib/reservedExportKeys.unitTest.js +0 -7
  46. package/dist/cli/lib/runDescribe.js +0 -141
  47. package/dist/cli/lib/runDescribe.unitTest.js +0 -7
  48. package/dist/cli/lib/runIt.js +0 -70
  49. package/dist/cli/lib/runIt.unitTest.js +0 -7
  50. package/dist/cli/lib/runTasks.js +0 -42
  51. package/dist/cli/lib/runTasks.unitTest.js +0 -30
  52. package/dist/cli/lib/runTest-old.js +0 -159
  53. package/dist/cli/lib/runTest-old.unitTest.js +0 -183
  54. package/dist/cli/lib/runTestFile copy.js +0 -292
  55. package/dist/cli/lib/runTestFile-old.js +0 -348
  56. package/dist/cli/lib/runTestFile.js +0 -105
  57. package/dist/cli/lib/runTestFile.unitTest.js +0 -264
  58. package/dist/cli/lib/runTestFiles.js +0 -141
  59. package/dist/cli/lib/runTestFiles.unitTest.js +0 -147
  60. package/dist/cli/lib/shouldCaptureConsoleLog.js +0 -24
  61. package/dist/cli/lib/shouldCaptureConsoleLog.unitTest.js +0 -31
  62. package/dist/cli/lib/showTestLoadingError.js +0 -22
  63. package/dist/cli/lib/showTestLoadingError.unitTest.js +0 -25
  64. package/dist/cli/lib/showTestResult.js +0 -87
  65. package/dist/cli/lib/showTestResult.unitTest.js +0 -180
  66. package/dist/cli/lib/validateConfig.js +0 -29
  67. package/dist/cli/lib/validateConfig.unitTest.js +0 -22
  68. package/dist/cli/lib/watchFiles.js +0 -1
  69. package/dist/cli/lib/watchFiles.unitTest.js +0 -48
  70. package/dist/cli/lib/watchFilesAndRunTests.js +0 -2
  71. package/dist/cli/lib/watchFilesAndRunTests.unitTest.js +0 -129
  72. package/dist/cli/lib/watchFilesAndRunTestsChokidar.js +0 -142
  73. package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js +0 -133
  74. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js +0 -162
  75. package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js +0 -131
  76. package/dist/cli/lib/watchFilesChokidar.js +0 -56
  77. package/dist/cli/lib/watchFilesChokidar.unitTest.js +0 -85
  78. package/dist/cli/lib/watchFilesNodeWatch.js +0 -42
  79. package/dist/cli/lib/watchFilesNodeWatch.unitTest.js +0 -48
  80. package/dist/cli/once.js +0 -47
  81. package/dist/cli/once.unitTest.js +0 -39
  82. package/dist/cli/watch.js +0 -100
  83. package/dist/cli/watch.unitTest.js +0 -117
  84. package/dist/config.js +0 -7
  85. package/dist/describe-old.js +0 -257
  86. package/dist/describe-old.unitTest.js +0 -21
  87. package/dist/describe.js +0 -24
  88. package/dist/describe.unitTest.js +0 -27
  89. package/dist/exported.eslintrc.cjs +0 -7
  90. package/dist/index.js +0 -1
  91. package/dist/indexNumberToLetters.js +0 -13
  92. package/dist/load.js +0 -3
  93. package/dist/output.js +0 -17
  94. package/dist/testsState.js +0 -4
  95. package/dist/timeProfiling.js +0 -9
@@ -1,24 +0,0 @@
1
- import { loadConfig as sxyLoadConfig, createTimeProfiler } from 'sxy-dev-tools';
2
- import { packageName, cliName, configFileName, configLocations, showTimeProfiling } from '../../config.js';
3
- import chalk from 'chalk-extensions';
4
- import { globby } from 'globby';
5
- import { out, log, debug } from '../../output.js';
6
- const {
7
- timeProfileAsync
8
- } = await createTimeProfiler(showTimeProfiling);
9
- import { addBasePath } from './addBasePath.js';
10
- export async function findTestFiles(config) {
11
- return await timeProfileAsync('find test files', async () => {
12
- const testsGlobs = await addBasePath(config.testsBase, config.tests);
13
- const testsIgnoreGlobs = await addBasePath(config.testsBase, config.testsIgnore);
14
- await debug('testsGlobs', testsGlobs);
15
- await debug('testsIgnoreGlobs', testsIgnoreGlobs);
16
- const globOptions = {
17
- //cwd: projectDir,
18
- ignore: testsIgnoreGlobs
19
- };
20
- const testFiles = await globby(testsGlobs, testsIgnoreGlobs);
21
- await debug('testFiles', testFiles);
22
- return testFiles;
23
- });
24
- }
@@ -1,22 +0,0 @@
1
- import { applyConfigDefaults } from './applyConfigDefaults.js';
2
- import { findTestFiles } from './findTestFiles.js'; // findTestFiles(config)
3
-
4
- await mochaDescribe('findTestFiles() function', async function () {
5
- await mochaIt('finds the tests files', async function () {
6
- // get the default configs
7
- const config = await applyConfigDefaults({
8
- tests: 'unitTesting/**/*.test.js'
9
- });
10
- const testFiles = await findTestFiles(config);
11
- await testFiles.should.include.members(['unitTesting/sampleTests/1.test.js', 'unitTesting/sampleTests/2.test.js']);
12
- });
13
- await mochaIt('respects tests base config entry', async function () {
14
- // get the default configs
15
- const config = await applyConfigDefaults({
16
- testsBase: 'src',
17
- tests: 'unitTesting/**/*.test.js'
18
- });
19
- const testFiles = await findTestFiles(config);
20
- await testFiles.length.should.equal(0);
21
- });
22
- });
@@ -1,11 +0,0 @@
1
- export async function getAllowedFlags(allowedArguments) {
2
- const allowedFlags = {};
3
-
4
- for (const option in allowedArguments) {
5
- if ('flag' in allowedArguments[option]) {
6
- allowedFlags[allowedArguments[option].flag] = option;
7
- }
8
- }
9
-
10
- return allowedFlags;
11
- }
@@ -1,20 +0,0 @@
1
- import { getAllowedFlags } from './getAllowedFlags.js'; // findTestFiles(config)
2
-
3
- await mochaDescribe('getAllowedFlags() function', async function () {
4
- await mochaIt('extracts the flags from an allowedArguments object', async function () {
5
- const allowedArguments = {
6
- 'config': {
7
- flag: 'c',
8
- hasValue: true
9
- },
10
- 'watch': {
11
- flag: 'w',
12
- hasValue: false
13
- }
14
- };
15
- const allowedFlags = await getAllowedFlags(allowedArguments);
16
- await allowedFlags.should.have.keys(['c', 'w']);
17
- await allowedFlags.c.should.equal('config');
18
- await allowedFlags.w.should.equal('watch');
19
- });
20
- });
@@ -1 +0,0 @@
1
- export const globArgCombine = patterns => Array.isArray(patterns) ? patterns.length > 1 ? '{' + patterns.join(',') + '}' : patterns[0] : patterns;
@@ -1,18 +0,0 @@
1
- import { globArgCombine } from "./globArgCombine.js";
2
- await mochaDescribe('globArgCombine() function', async function () {
3
- await mochaIt('leaves strings alone', async function () {
4
- const testString = '*.test.js';
5
- const result = await globArgCombine(testString);
6
- await result.should.equal(testString);
7
- });
8
- await mochaIt('extracts the item from a single item array', async function () {
9
- const testStringsArray = ['*.test.js'];
10
- const result = await globArgCombine(testStringsArray);
11
- await result.should.equal(testStringsArray[0]);
12
- });
13
- await mochaIt('combined an array into a multi option glob e.g. {a,b}', async function () {
14
- const testStringsArray = ['*.test.js', '*.spec.js'];
15
- const result = await globArgCombine(testStringsArray);
16
- await result.should.equal(`{${testStringsArray[0]},${testStringsArray[1]}}`);
17
- });
18
- });
@@ -1,11 +0,0 @@
1
- import { out as mainOut, log, debug } from '../../output.js';
2
- const reservedKeys = ['describe', 'test', 'it', 'before', 'after', 'beforeEach', 'afterEach', 'beforeAll', 'afterAll'];
3
- export async function injectProperties(basePackage, injectProperties, from, customOut = undefined) {
4
- const out = customOut ? async (...texts) => await customOut(...texts) : async (...texts) => await mainOut(...texts);
5
-
6
- for (const key in injectProperties) {
7
- if (await reservedKeys.includes(key)) {
8
- await out(`Error: key '${key}' is reserved. Please do not use this key. From '${from}'.`); //process.exit(1)
9
- }
10
- }
11
- }
@@ -1,75 +0,0 @@
1
- import { injectProperties } from "./injectProperties.js";
2
- import chalk from 'chalk-extensions';
3
- await mochaDescribe('injectProperties() function', async function () {
4
- await mochaIt('complains if a reserved property is given', async function () {
5
- let outBuffer = '';
6
-
7
- const customOut = (...texts) => {
8
- //console.log(chalk.red`outBuffer1`, outBuffer)
9
- console.log(...texts);
10
- outBuffer += texts.join(' ') + '\n'; // join and save to the buffer
11
- //console.log(chalk.red`outBuffer2`, outBuffer)
12
- };
13
-
14
- const errorString = 'is reserved';
15
- const basePacket = {};
16
- let properties;
17
- outBuffer = '';
18
- properties = {
19
- describe: true
20
- };
21
- await injectProperties(basePacket, properties, '', customOut);
22
- await outBuffer.should.include(errorString);
23
- outBuffer = '';
24
- properties = {
25
- it: true
26
- };
27
- await injectProperties(basePacket, properties, '', customOut);
28
- await outBuffer.should.include(errorString);
29
- outBuffer = '';
30
- properties = {
31
- test: true
32
- };
33
- await injectProperties(basePacket, properties, '', customOut);
34
- await outBuffer.should.include(errorString);
35
- outBuffer = '';
36
- properties = {
37
- before: true
38
- };
39
- await injectProperties(basePacket, properties, '', customOut);
40
- await outBuffer.should.include(errorString);
41
- outBuffer = '';
42
- properties = {
43
- after: true
44
- };
45
- await injectProperties(basePacket, properties, '', customOut);
46
- await outBuffer.should.include(errorString);
47
- outBuffer = '';
48
- properties = {
49
- beforeEach: true
50
- };
51
- await injectProperties(basePacket, properties, '', customOut);
52
- await outBuffer.should.include(errorString);
53
- outBuffer = '';
54
- properties = {
55
- afterEach: true
56
- };
57
- await injectProperties(basePacket, properties, '', customOut);
58
- await outBuffer.should.include(errorString);
59
- }); // mochaIt('complains if a passed property conflics with a base property', function() {
60
- // let outBuffer = ''
61
- // const customOut = sync((...texts) => {
62
- // console.log(...texts)
63
- // outBuffer += texts.join(' ') + '\n' // join and save to the buffer
64
- // })
65
- // const errorString = 'is reserved'
66
- // const basePacket = {}
67
- // let properties
68
- // outBuffer = ''
69
- // properties = {
70
- // describe: true
71
- // }
72
- // injectProperties(basePacket, properties, '', customOut)
73
- // outBuffer.should.include(errorString)
74
- // })
75
- });
@@ -1,3 +0,0 @@
1
- import sxyLoaderConfig from '../../../sxy-loader.config.js';
2
- import { createLoad } from 'sxy-loader';
3
- export const load = await createLoad(import.meta.url, sxyLoaderConfig);
@@ -1,7 +0,0 @@
1
- import { load } from "./load.js";
2
- await mochaDescribe('load import (sxy loader)', async function () {
3
- await mochaIt('load is a function with a cache', async function () {
4
- await load.should.be.a('function');
5
- await load.should.include.key('cache');
6
- });
7
- });
@@ -1,21 +0,0 @@
1
- import { loadConfig as sxyLoadConfig, loadConfigExact as sxyLoadConfigExact, createTimeProfiler } from 'sxy-dev-tools';
2
- import { packageName, cliName, configFileName, configLocations, showTimeProfiling } from '../../config.js';
3
- import chalk from 'chalk-extensions';
4
- import { out, log, debug } from '../../output.js';
5
- const {
6
- timeProfileAsync
7
- } = await createTimeProfiler(showTimeProfiling);
8
- export async function loadConfig(customLocation = undefined) {
9
- return await timeProfileAsync('load config', async () => {
10
- const configOrNull = customLocation !== undefined ? await sxyLoadConfigExact(customLocation) : await sxyLoadConfig(configFileName, configLocations);
11
- await debug('configOrNull', typeof configOrNull, configOrNull);
12
-
13
- if (!configOrNull) {
14
- 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
- await process.exit(0);
16
- } //log('user config', configOrNull)
17
-
18
-
19
- return configOrNull;
20
- });
21
- }
@@ -1,15 +0,0 @@
1
- import { loadConfig } from "./loadConfig.js"; // loadConfig(location)
2
- // location is option
3
-
4
- await mochaDescribe('loadConfig() function', async function () {
5
- await mochaIt('loads a user config', async function () {
6
- const userConfig = await loadConfig();
7
- userConfig.should.not.be.null;
8
- });
9
- await mochaIt('loads a user config from a location passed to it', async function () {
10
- const configLocation = 'unitTesting/sampleConfig/sxy-test-runner.config.js';
11
- const userConfig = await loadConfig(configLocation);
12
- userConfig.should.not.be.null;
13
- await userConfig.tests.should.equal('alt-config-location');
14
- });
15
- });
@@ -1,75 +0,0 @@
1
- import { createTimeProfiler } from 'sxy-dev-tools';
2
- import { showTimeProfiling } from '../../config.js';
3
- import { out, log, debug, error } from '../../output.js';
4
- import { join } from 'path';
5
- import chalk from 'chalk-extensions';
6
- const {
7
- timeProfileAsync
8
- } = await createTimeProfiler(showTimeProfiling);
9
- import { load } from './load.js';
10
- let loading = null;
11
- export async function loadTestFile(config, testFile) {
12
- if (loading !== null) {
13
- await debug(chalk.yellow`loadTestFile - another file is loading - waiting for it to finish`);
14
- await loading;
15
- await debug(chalk.yellow`previous file complete - will now load the file`);
16
- }
17
-
18
- const loadPromise = timeProfileAsync(`load test ${testFile}`, async () => {
19
- const projectDir = await process.cwd(); // eslint-disable-next-line camelcase
20
-
21
- global.__sxy_test_runner__ = {
22
- describes: [],
23
- describeCounter: 1
24
- };
25
- const testFileFullUrl = 'file://' + (await join(projectDir, testFile)); //console.log('testFileFullUrl', testFileFullUrl)
26
-
27
- const test = {
28
- file: testFile
29
- };
30
- const capturingConsoleLog = config.execution.files === 'sequential'; //// capture console.log output
31
-
32
- let previousConsoleLog;
33
- const logs = [];
34
-
35
- if (capturingConsoleLog) {
36
- previousConsoleLog = console.log; // eslint-disable-line no-console
37
-
38
- console.log = async (...texts) => await logs.push(texts); // eslint-disable-line no-console
39
-
40
- } ////
41
-
42
-
43
- try {
44
- await load(testFileFullUrl, {// scopeObject: { // experimental idea
45
- // name: 'scope',
46
- // contents: {},
47
- // exposeObject: 'scope'
48
- // }
49
- });
50
- test.describes = global.__sxy_test_runner__.describes;
51
- test.error = false;
52
- } catch (e) {
53
- //error(chalk.red`Error loading file ${testFileFullUrl}`)
54
- test.error = `Error loading file`;
55
- } finally {
56
- test.logs = logs; //// restore previous console.log function
57
-
58
- if (capturingConsoleLog) {
59
- if (capturingConsoleLog) {
60
- console.log = previousConsoleLog; // eslint-disable-line no-console
61
- }
62
- } ////
63
-
64
- } // console.log()
65
- // console.log('test', test)
66
- // console.log('describes', test.describes)
67
- // console.log('its', test.describes[0].its)
68
- // console.log()
69
-
70
-
71
- return test;
72
- });
73
- loading = loadPromise;
74
- return await loadPromise;
75
- }
@@ -1,51 +0,0 @@
1
- import { defaultConfig } from './defaultConfig.js';
2
- import { applyConfigDefaults } from './applyConfigDefaults.js';
3
- import { loadTestFile } from './loadTestFile.js'; // loadTestFile(config, testFile) ???
4
-
5
- await mochaDescribe('loadTestFile() function', async function () {
6
- await mochaIt('should load a test file, retreiving describes', async function () {
7
- const config = defaultConfig;
8
- const sampleTestFile = 'unitTesting/sampleTests/1.test.js';
9
- const test = await loadTestFile(config, sampleTestFile);
10
- await test.describes.length.should.equal(1);
11
- await (await test.describes.at(-1)).counter.should.equal(1);
12
- await test.describes[0].tests.should.be.a('function'); //test.describes.at(-1).its.at(-1).counter.should.equal(1)
13
- });
14
- await mochaIt('should correctly load a second test file', async function () {
15
- const config = defaultConfig;
16
- const sampleTestFile = 'unitTesting/sampleTests/2.test.js';
17
- const test = await loadTestFile(config, sampleTestFile);
18
- await test.describes.length.should.equal(1);
19
- await (await test.describes.at(-1)).counter.should.equal(1);
20
- await test.describes[0].tests.should.be.a('function'); //test.describes.at(-1).its.at(-1).counter.should.equal(2)
21
- });
22
- await mochaIt('should correctly load a file with describes without any its/tests', async function () {
23
- const config = defaultConfig;
24
- const sampleTestFile = 'unitTesting/sampleTests/describesWithoutTests.test.js';
25
- const test = await loadTestFile(config, sampleTestFile); //console.log('ut test', test)
26
-
27
- await test.describes.length.should.equal(2);
28
- await (await test.describes.at(-1)).counter.should.equal(2);
29
- await test.describes[0].tests.should.be.a('function'); //test.describes.at(-1).its.at(-1).counter.should.equal(2)
30
- });
31
- await mochaIt('should capture console.log output from a test file, when files are running sequentially', async function () {
32
- const config = await applyConfigDefaults({
33
- execution: {
34
- files: 'sequential'
35
- }
36
- });
37
- const sampleTestFile = 'unitTesting/sampleTests/consoleLog.test.js';
38
- const testBlock = await loadTestFile(config, sampleTestFile);
39
- await testBlock.consoleLogs.should.deep.equal([['foo'], ['bar']]);
40
- });
41
- await mochaIt('should capture console.log output from a test file, when files are running sequentially', async function () {
42
- const config = await applyConfigDefaults({
43
- execution: {
44
- files: 'parallel'
45
- }
46
- });
47
- const sampleTestFile = 'unitTesting/sampleTests/consoleLog.test.js';
48
- const testBlock = await loadTestFile(config, sampleTestFile);
49
- await chaiShould.not.exist(testBlock.consoleLogs);
50
- }); // should not log output when running in parallel
51
- });
@@ -1,40 +0,0 @@
1
- /*
2
-
3
- I can't remember what this was for.
4
-
5
- Would need updating to the new file load system if used
6
-
7
- import { createTimeProfiler } from 'sxy-dev-tools'
8
- import { packageName, cliName, configFileName, configLocations, showTimeProfiling } from '../../config.js'
9
- import { join } from 'path'
10
- const { timeProfileAsync } = createTimeProfiler(showTimeProfiling)
11
-
12
- // could be used within runTests
13
- // think its not used now
14
-
15
- export function loadTestFileStatic(config, testFile) {
16
-
17
- return timeProfileAsync(`load test ${testFile} statically (standard import)`, () => {
18
-
19
- //console.log('loadTestFileStatic', config, testFile)
20
-
21
- const projectDir = process.cwd()
22
-
23
- global.testState = {
24
- describes: [],
25
- describeCounter: 1
26
- }
27
-
28
- import( 'file://' + join(projectDir, testFile) )
29
-
30
- const test = {
31
- file: testFile,
32
- describes: global.testState.describes
33
- }
34
-
35
- return test
36
-
37
- } )
38
-
39
- }
40
- */
@@ -1,29 +0,0 @@
1
- /*
2
- import { loadTestFileStatic } from "./loadTestFileStatic.js"
3
- import { applyConfigDefaults } from './applyConfigDefaults.js'
4
-
5
- // loadTestFile(config, testFile) ???
6
-
7
- mochaDescribe('loadTestFileStatic() function', function() {
8
-
9
- mochaIt('should load a test file, retreiving describes', function() {
10
-
11
- const config = applyConfigDefaults({})
12
-
13
- const sampleTestFile = 'unitTesting/sampleTests/1.test.js'
14
-
15
- const test = loadTestFileStatic(config, sampleTestFile)
16
-
17
- test.describes.length.should.equal(1)
18
- test.describes[0].counter.should.equal(1)
19
- test.describes[0].its[0].counter.should.equal(1)
20
-
21
- })
22
-
23
- // mochaIt('should be able to load a test file again, after cache is cleard', function() {
24
-
25
-
26
- // })
27
-
28
- })
29
- */
@@ -1,20 +0,0 @@
1
- export async function overrideConsoleLog() {
2
- // save the original func
3
- const originalConsoleLog = console.log; // eslint-disable-line no-console
4
- // create a catcher func
5
-
6
- async function logCatcher(...texts) {
7
- await logCatcher.logs.push(texts);
8
- } // initise a variable on it
9
-
10
-
11
- logCatcher.logs = []; // assign the new func to console.log
12
-
13
- console.log = logCatcher; // eslint-disable-line no-console
14
- // return the original func (for restoring) and the new func (for retreiving caught logging)
15
-
16
- return {
17
- originalConsoleLog,
18
- replacementConsoleLog: logCatcher
19
- };
20
- }
File without changes
@@ -1,57 +0,0 @@
1
- // watch:
2
- // once:
3
- // // --config configLocation
4
- import { createTimeProfiler } from 'sxy-dev-tools';
5
- import { packageName, cliName, configFileName, configLocations, showTimeProfiling } from '../../config.js';
6
- import { join } from 'path';
7
- import { out, log, debug } from '../../output.js';
8
- const {
9
- timeProfileAsync
10
- } = await createTimeProfiler(showTimeProfiling);
11
- import { getAllowedFlags } from './getAllowedFlags.js';
12
- export async function parseCommandLineArguments(allowedArguments) {
13
- const allowedFlags = await getAllowedFlags(allowedArguments);
14
- const returnArgs = {};
15
-
16
- for (let position = 0; position < commandLineArguments.length; position++) {
17
- const arg = commandLineArguments[position];
18
-
19
- if ((await arg.slice(0, 2)) === '--') {
20
- const longFlag = await arg.slice(2);
21
-
22
- if (longFlag in allowedArguments) {
23
- if (allowedArguments[longFlag].hasValue) {
24
- const value = commandLineArguments[++position]; // increment position
25
-
26
- returnArgs[longFlag] = value;
27
- } else {
28
- returnArgs[longFlag] = true;
29
- }
30
- } else {
31
- await log(`[${packageName}] Unknown option ${longFlag}`);
32
- }
33
- } else if ((await arg.slice(0, 1)) === '-') {
34
- const shortFlag = await arg.slice(1);
35
-
36
- if (shortFlag in allowedFlags) {
37
- const longFlag = allowedFlags[shortFlag];
38
-
39
- if (longFlag in returnArgs) {
40
- await log(`[${packageName}] Option ${longFlag} already set, being overwritten by ${shortFlag}`);
41
- }
42
-
43
- if (allowedArguments[longFlag].hasValue) {
44
- const value = commandLineArguments[++position]; // increment position
45
-
46
- returnArgs[longFlag] = value;
47
- } else {
48
- returnArgs[longFlag] = true;
49
- }
50
- } else {
51
- await log(`[${packageName}] Unknown flag ${shortFlag}`);
52
- }
53
- }
54
- }
55
-
56
- return returnArgs;
57
- }
@@ -1,21 +0,0 @@
1
- import { parseCommandLineArguments } from './parseCommandLineArguments.js'; // parseCommandLineArguments(allowedArguments)
2
-
3
- await mochaDescribe('getAllowedFlags() function', async function () {
4
- await mochaIt('extracts the flags from an allowedArguments object', async function () {
5
- const allowedArguments = {
6
- 'config': {
7
- flag: 'c',
8
- hasValue: true
9
- },
10
- 'watch': {
11
- flag: 'w',
12
- hasValue: false
13
- }
14
- };
15
- global.commandLineArguments = ['--config', 'foo bar'];
16
- const parsedArgs = await parseCommandLineArguments(allowedArguments); //console.log('parsed Args', parsedArgs)
17
-
18
- await parsedArgs.should.have.key('config');
19
- await parsedArgs.config.should.equal('foo bar');
20
- });
21
- });
File without changes
@@ -1,7 +0,0 @@
1
- //import { processWatchEvent } from './processWatchEvent.js'
2
- // parseCommandLineArguments(allowedArguments)
3
- // mochaDescribe('processWatchEvent() function', function() {
4
- // mochaIt('identifies a test in a watch event', function() {
5
- // processWatchEvent('temp/a.test.js', 'update')
6
- // })
7
- // })
@@ -1 +0,0 @@
1
- export const reservedExportKeys = ['describe', 'test', 'it', 'before', 'after', 'beforeEach', 'afterEach', 'beforeAll', 'afterAll'];
@@ -1,7 +0,0 @@
1
- import { reservedExportKeys } from './reservedExportKeys.js'; // applyConfigDefaults( userConfig: {} )
2
-
3
- await mochaDescribe('the reservedExportKeys', async function () {
4
- await mochaIt('has sensible defaults', async function () {
5
- await reservedExportKeys.should.include.members(['describe', 'test', 'it', 'before']);
6
- });
7
- });