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.
- package/dist/cli/index.js +2 -6
- package/dist/cli/init.js +19 -14
- package/dist/cli/lib/addBasePath.js +0 -1
- package/dist/cli/lib/addBasePath.unitTest.js +3 -1
- package/dist/cli/lib/addExports.unitTest.js +4 -1
- package/dist/cli/lib/applyConfigDefaults.js +12 -7
- package/dist/cli/lib/applyConfigDefaults.unitTest.js +9 -3
- package/dist/cli/lib/buildDependencyTree.js +10 -5
- package/dist/cli/lib/buildDependencyTree.unitTest.js +3 -1
- package/dist/cli/lib/buildDependencyTrees.js +6 -4
- package/dist/cli/lib/buildDependencyTrees.unitTest.js +3 -1
- package/dist/cli/lib/defaultConfig.test.js +3 -1
- package/dist/cli/lib/doUserSetup.js +0 -3
- package/dist/cli/lib/doUserSetup.unitTest.js +3 -1
- package/dist/cli/lib/doUserTeardown.js +0 -3
- package/dist/cli/lib/doUserTeardown.unitTest.js +3 -1
- package/dist/cli/lib/findTestFiles.unitTest.js +3 -1
- package/dist/cli/lib/getAllowedFlags.js +0 -2
- package/dist/cli/lib/getAllowedFlags.unitTest.js +3 -1
- package/dist/cli/lib/injectProperties.js +2 -2
- package/dist/cli/lib/injectProperties.unitTest.js +9 -2
- package/dist/cli/lib/loadConfig.js +2 -2
- package/dist/cli/lib/loadConfig.unitTest.js +3 -2
- package/dist/cli/lib/loadTestFile.js +17 -15
- package/dist/cli/lib/loadTestFile.unitTest.js +8 -3
- package/dist/cli/lib/loadTestFileStatic.js +1 -0
- package/dist/cli/lib/loadTestFileStatic.unitTest.js +1 -0
- package/dist/cli/lib/parseCommandLineArguments.js +1 -9
- package/dist/cli/lib/parseCommandLineArguments.unitTest.js +6 -2
- package/dist/cli/lib/parseDescribe.js +12 -18
- package/dist/cli/lib/parseDescribe.unitTest.js +6 -2
- package/dist/cli/lib/processWatchEvent.unitTest.js +9 -1
- package/dist/cli/lib/reservedExportKeys.unitTest.js +3 -1
- package/dist/cli/lib/runDescribe.js +4 -7
- package/dist/cli/lib/runDescribe.old.js +19 -25
- package/dist/cli/lib/runDescribe.unitTest.js +120 -2
- package/dist/cli/lib/runDescribeRun.js +3 -7
- package/dist/cli/lib/runDescribeRun.unitTest.js +125 -4
- package/dist/cli/lib/runIt.js +16 -18
- package/dist/cli/lib/runIt.unitTest.js +124 -4
- package/dist/cli/lib/runTasks.js +2 -7
- package/dist/cli/lib/runTasks.unitTest.js +3 -1
- package/dist/cli/lib/runTest-old.js +1 -0
- package/dist/cli/lib/runTest-old.unitTest.js +1 -0
- package/dist/cli/lib/runTest.js +15 -12
- package/dist/cli/lib/runTest.unitTest.js +38 -11
- package/dist/cli/lib/runTests.js +36 -35
- package/dist/cli/lib/runTests.unitTest.js +15 -8
- package/dist/cli/lib/showTestLoadingError.js +6 -6
- package/dist/cli/lib/showTestLoadingError.unitTest.js +5 -3
- package/dist/cli/lib/showTestResult.js +10 -16
- package/dist/cli/lib/showTestResult.unitTest.js +26 -17
- package/dist/cli/lib/validateConfig.js +0 -5
- package/dist/cli/lib/validateConfig.unitTest.js +2 -3
- package/dist/cli/lib/watchFiles.unitTest.js +5 -3
- package/dist/cli/lib/watchFilesAndRunTests.js +3 -1
- package/dist/cli/lib/watchFilesAndRunTests.unitTest.js +18 -15
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.js +22 -29
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js +19 -17
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js +28 -31
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js +21 -16
- package/dist/cli/lib/watchFilesChokidar.js +15 -11
- package/dist/cli/lib/watchFilesChokidar.unitTest.js +11 -8
- package/dist/cli/lib/watchFilesNodeWatch.js +9 -6
- package/dist/cli/lib/watchFilesNodeWatch.unitTest.js +6 -3
- package/dist/cli/once.js +0 -6
- package/dist/cli/watch.js +18 -14
- package/dist/cli/watch.unitTest.js +16 -16
- package/dist/describe-old.js +35 -20
- package/dist/describe-old.unitTest.js +10 -1
- package/dist/describe.js +8 -3
- package/dist/describe.unitTest.js +5 -2
- package/dist/indexNumberToLetters.js +1 -3
- package/dist/output.js +7 -0
- package/dist/testsState.js +2 -1
- package/package.json +14 -7
- package/readme.md +1 -1
- package/sxy-loader.config.js +10 -10
package/dist/cli/lib/runTests.js
CHANGED
|
@@ -3,9 +3,10 @@ import { showTimeProfiling } from '../../config.js';
|
|
|
3
3
|
import chalk from 'chalk-extensions';
|
|
4
4
|
import { out as mainOut, log, debug } from '../../output.js';
|
|
5
5
|
import { join } from 'path';
|
|
6
|
-
import figures from 'figures';
|
|
7
|
-
|
|
6
|
+
import figures from 'figures';
|
|
7
|
+
//import { testsState } from '../../testsState.js'
|
|
8
8
|
import 'sxy-standard';
|
|
9
|
+
import objects from 'sxy-lib/objects.js';
|
|
9
10
|
import { loadTestFile } from './loadTestFile.js';
|
|
10
11
|
import { runTest } from './runTest.js';
|
|
11
12
|
import { showTestLoadingError } from './showTestLoadingError.js';
|
|
@@ -22,15 +23,15 @@ export async function runTests(config, testFiles, failingTests, customOut = unde
|
|
|
22
23
|
const testRunOutPromises = {}; // exp
|
|
23
24
|
|
|
24
25
|
await timeProfileAsync('run tests', async () => {
|
|
25
|
-
const projectDir =
|
|
26
|
+
//const projectDir = process.cwd()
|
|
27
|
+
|
|
28
|
+
////out(``) // spacer before tests output
|
|
26
29
|
|
|
27
30
|
if (testFiles.length > 0) {
|
|
28
31
|
// clear load cache to allow accesing the new tets
|
|
29
32
|
await load.cache.clear();
|
|
30
|
-
|
|
31
33
|
for (const testFile of testFiles) {
|
|
32
34
|
const test = await loadTestFile(config, testFile);
|
|
33
|
-
|
|
34
35
|
if (test.error) {
|
|
35
36
|
erroringTests[testFile] = test;
|
|
36
37
|
await showTestLoadingError(config, test);
|
|
@@ -41,17 +42,17 @@ export async function runTests(config, testFiles, failingTests, customOut = unde
|
|
|
41
42
|
testRunOutPromises[testFile] = testRunPromise.then(async testResult => {
|
|
42
43
|
if (testResult.success === true || testResult.success === null) {
|
|
43
44
|
if (await failingTests.includes(testResult.file)) {
|
|
44
|
-
await failingTests.remove(testResult.file);
|
|
45
|
+
await failingTests.remove(testResult.file); // arrayRemove?
|
|
45
46
|
}
|
|
46
47
|
} else {
|
|
47
48
|
if (!(await failingTests.includes(testResult.file))) {
|
|
48
49
|
await failingTests.push(testResult.file);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
|
|
52
52
|
await showTestResult(config, testResult, customOut);
|
|
53
|
-
});
|
|
53
|
+
});
|
|
54
54
|
|
|
55
|
+
// wait for the test to complete before proceeding if we are in 'sequential' mode
|
|
55
56
|
if (config.execution.files === 'sequential') await testRunOutPromises[testFile];
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -59,8 +60,9 @@ export async function runTests(config, testFiles, failingTests, customOut = unde
|
|
|
59
60
|
});
|
|
60
61
|
let runTestResults = {};
|
|
61
62
|
await timeProfileAsync('wait for tests to finish', async () => {
|
|
62
|
-
runTestResults = await Promise.allObj(testRunPromises);
|
|
63
|
+
runTestResults = await Promise.allObj(testRunPromises);
|
|
63
64
|
|
|
65
|
+
// wait for the output to complete
|
|
64
66
|
await Promise.allObj(testRunOutPromises);
|
|
65
67
|
});
|
|
66
68
|
await timeProfileAsync('show initial test run results', async () => {
|
|
@@ -73,12 +75,16 @@ export async function runTests(config, testFiles, failingTests, customOut = unde
|
|
|
73
75
|
describesPasses: 0,
|
|
74
76
|
describesInvalid: 0,
|
|
75
77
|
itsTotal: 0,
|
|
76
|
-
itsPasses: 0
|
|
78
|
+
itsPasses: 0
|
|
79
|
+
// itsInvalid: 0 // we don't check whether tests run any asserts (we don't control the assertion lib)
|
|
80
|
+
};
|
|
77
81
|
|
|
78
|
-
|
|
82
|
+
//console.log('runTestResults', runTestResults)
|
|
79
83
|
|
|
80
84
|
for (const testFile in runTestResults) {
|
|
81
|
-
const runTestResult = runTestResults[testFile];
|
|
85
|
+
const runTestResult = runTestResults[testFile];
|
|
86
|
+
|
|
87
|
+
//console.log('runTestResult', runTestResult)
|
|
82
88
|
|
|
83
89
|
testsResultsSummary.total += +(runTestResult.success !== null);
|
|
84
90
|
testsResultsSummary.passes += +runTestResult.success;
|
|
@@ -87,55 +93,50 @@ export async function runTests(config, testFiles, failingTests, customOut = unde
|
|
|
87
93
|
testsResultsSummary.describesPasses += +runTestResult.describeResultsSummary.passes;
|
|
88
94
|
testsResultsSummary.describesInvalid += +runTestResult.describeResultsSummary.invalid;
|
|
89
95
|
testsResultsSummary.itsTotal += +runTestResult.describeResultsSummary.itsTotal;
|
|
90
|
-
testsResultsSummary.itsPasses += +runTestResult.describeResultsSummary.itsPasses;
|
|
96
|
+
testsResultsSummary.itsPasses += +runTestResult.describeResultsSummary.itsPasses;
|
|
97
|
+
//testsResultsSummary.itsInvalid += +runTestResult.describeResultsSummary.itsInvalid // see comment above, not doing invalid tests
|
|
91
98
|
}
|
|
92
99
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
testsResultsSummary.total += await objects.count(erroringTests);
|
|
101
|
+
//for ( const testFile in erroringTests ) {
|
|
102
|
+
// testsResultsSummary.total++
|
|
103
|
+
//}
|
|
96
104
|
|
|
105
|
+
//console.log('testsResultsSummary', testsResultsSummary)
|
|
97
106
|
|
|
98
107
|
await out(`\n`);
|
|
99
|
-
|
|
100
108
|
if (testsResultsSummary.itsPasses === testsResultsSummary.itsTotal) {
|
|
101
109
|
await out(await chalk.mediumgreen(`${figures.tick}`));
|
|
102
110
|
} else {
|
|
103
111
|
await out(await chalk.mediumred(`${figures.cross}`));
|
|
104
|
-
}
|
|
105
|
-
|
|
112
|
+
}
|
|
106
113
|
|
|
114
|
+
// number of tests successful
|
|
107
115
|
const testsText = `Tests: ${testsResultsSummary.itsPasses}/${testsResultsSummary.itsTotal}`;
|
|
108
|
-
|
|
109
116
|
if (testsResultsSummary.itsPasses === testsResultsSummary.itsTotal) {
|
|
110
|
-
await out(await chalk.mediumgreen(`${testsText}`
|
|
111
|
-
/* ${figures.tick}`*/
|
|
112
|
-
));
|
|
117
|
+
await out(await chalk.mediumgreen(`${testsText}` /* ${figures.tick}`*/));
|
|
113
118
|
} else {
|
|
114
|
-
await out(await chalk.mediumred(`${testsText}`
|
|
115
|
-
|
|
116
|
-
));
|
|
117
|
-
} // number of items successful
|
|
118
|
-
|
|
119
|
+
await out(await chalk.mediumred(`${testsText}` /* ${figures.cross}`*/));
|
|
120
|
+
}
|
|
119
121
|
|
|
122
|
+
// number of items successful
|
|
120
123
|
const describesText = `Items: ${testsResultsSummary.describesPasses}/${testsResultsSummary.describesTotal}`;
|
|
121
|
-
const invalidDescribesText = testsResultsSummary.describesInvalid >= 1 ? testsResultsSummary.describesInvalid === 1 ? await chalk.grey(`(1 describe without tests)`) : await chalk.grey(`(
|
|
122
|
-
|
|
124
|
+
const invalidDescribesText = testsResultsSummary.describesInvalid >= 1 ? testsResultsSummary.describesInvalid === 1 ? await chalk.grey(`(+1 describe without tests)`) : await chalk.grey(`(+${testsResultsSummary.describesInvalid} describes without tests)`) : '';
|
|
123
125
|
if (testsResultsSummary.describesPasses === testsResultsSummary.describesTotal) {
|
|
124
126
|
await out((await chalk.mediumgreen(`${describesText}`)) + ' ' + invalidDescribesText);
|
|
125
127
|
} else {
|
|
126
128
|
await out((await chalk.mediumred(`${describesText}`)) + ' ' + invalidDescribesText);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
+
}
|
|
129
130
|
|
|
131
|
+
// number of test files successful
|
|
130
132
|
const testFilesText = `Test Files: ${testsResultsSummary.passes}/${testsResultsSummary.total}`;
|
|
131
133
|
const invalidTestFilesText = testsResultsSummary.invalid >= 1 ? testsResultsSummary.invalid === 1 ? await chalk.grey(`(+1 file without tests)`) : await chalk.grey(`(+${testsResultsSummary.invalid} files without tests)`) : '';
|
|
132
|
-
|
|
133
134
|
if (testsResultsSummary.passes === testsResultsSummary.total) {
|
|
134
135
|
await out((await chalk.mediumgreen(`${testFilesText}`)) + ' ' + invalidTestFilesText);
|
|
135
136
|
} else {
|
|
136
137
|
await out((await chalk.mediumred(`${testFilesText}`)) + ' ' + invalidTestFilesText);
|
|
137
138
|
}
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
await out(chalk.orange`To do: account for tests with loading errors`);
|
|
140
|
+
// out(``)
|
|
140
141
|
});
|
|
141
142
|
}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { applyConfigDefaults } from './applyConfigDefaults.js';
|
|
2
|
-
import { runTests } from './runTests.js';
|
|
2
|
+
import { runTests } from './runTests.js';
|
|
3
|
+
|
|
4
|
+
// runTests(config, testFiles, failingTests)
|
|
3
5
|
|
|
4
6
|
await mochaDescribe('runTests() function', async function () {
|
|
5
7
|
await mochaIt('should run provided test files and produce an output of results', async function () {
|
|
6
8
|
// create a custom out function to capture the output
|
|
7
9
|
let outBuffer = '';
|
|
8
|
-
|
|
9
10
|
const customOut = (...texts) => {
|
|
10
11
|
outBuffer += texts.join(' ') + '\n'; // join and save to the buffer
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
const config = await applyConfigDefaults({});
|
|
14
15
|
const testFiles = ['unitTesting/sampleTests/1.test.js'];
|
|
15
|
-
const results = await runTests(config, testFiles, [], customOut);
|
|
16
|
+
const results = await runTests(config, testFiles, [], customOut);
|
|
17
|
+
|
|
18
|
+
//console.log(results)
|
|
19
|
+
|
|
16
20
|
//console.log(outBuffer)
|
|
17
21
|
|
|
18
22
|
await outBuffer.should.include('1 should equal 1');
|
|
@@ -23,22 +27,24 @@ await mochaDescribe('runTests() function', async function () {
|
|
|
23
27
|
await mochaIt('should sensibly handle tallies when test files with no describes are included', async function () {
|
|
24
28
|
// create a custom out function to capture the output
|
|
25
29
|
let outBuffer = '';
|
|
26
|
-
|
|
27
30
|
const customOut = (...texts) => {
|
|
28
31
|
outBuffer += texts.join(' ') + '\n'; // join and save to the buffer
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
const config = await applyConfigDefaults({});
|
|
32
35
|
const testFiles = ['unitTesting/sampleTests/1.test.js', 'unitTesting/sampleTests/blank.test.js', 'unitTesting/sampleTests/describesWithoutTests.test.js'];
|
|
33
|
-
const results = await runTests(config, testFiles, [], customOut);
|
|
34
|
-
|
|
36
|
+
const results = await runTests(config, testFiles, [], customOut);
|
|
37
|
+
|
|
38
|
+
//console.log('results', results)
|
|
39
|
+
|
|
40
|
+
//console.log('outBuffer', outBuffer)
|
|
35
41
|
|
|
36
42
|
await outBuffer.should.include('1 should equal 1');
|
|
37
43
|
await outBuffer.should.include('Tests: 1/1');
|
|
38
44
|
await outBuffer.should.include('Items: 1/1');
|
|
39
|
-
await outBuffer.should.include('(2 describes without tests)');
|
|
45
|
+
await outBuffer.should.include('(+2 describes without tests)');
|
|
40
46
|
await outBuffer.should.include('Test Files: 1/1');
|
|
41
|
-
await outBuffer.should.include('(2 files without tests)');
|
|
47
|
+
await outBuffer.should.include('(+2 files without tests)');
|
|
42
48
|
});
|
|
43
49
|
await mochaIt('runs test files sequentially in test mode', async function () {
|
|
44
50
|
// create a custom out function to capture the output
|
|
@@ -46,6 +52,7 @@ await mochaDescribe('runTests() function', async function () {
|
|
|
46
52
|
// const customOut = sync((...texts) => {
|
|
47
53
|
// outBuffer += texts.join(' ') + '\n' // join and save to the buffer
|
|
48
54
|
// })
|
|
55
|
+
|
|
49
56
|
const config = await applyConfigDefaults({
|
|
50
57
|
execution: {
|
|
51
58
|
files: 'sequential'
|
|
@@ -2,8 +2,8 @@ import { createTimeProfiler } from 'sxy-dev-tools';
|
|
|
2
2
|
import { packageName, cliName, configFileName, configLocations, showTimeProfiling } from '../../config.js';
|
|
3
3
|
import chalk from 'chalk-extensions';
|
|
4
4
|
import { out as mainOut, log, debug } from '../../output.js';
|
|
5
|
-
import figures from 'figures';
|
|
6
|
-
|
|
5
|
+
import figures from 'figures';
|
|
6
|
+
//import { testsState } from '../../testsState.js'
|
|
7
7
|
import 'sxy-standard/light.js';
|
|
8
8
|
import { indexNumberToLetters } from '../../indexNumberToLetters.js';
|
|
9
9
|
const {
|
|
@@ -11,15 +11,16 @@ const {
|
|
|
11
11
|
} = await createTimeProfiler(showTimeProfiling);
|
|
12
12
|
export async function showTestLoadingError(config, test, customOut = undefined) {
|
|
13
13
|
await debug('customOut', customOut);
|
|
14
|
-
const out = customOut ? async (...texts) => await customOut(...texts) : async (...texts) => await mainOut(...texts);
|
|
14
|
+
const out = customOut ? async (...texts) => await customOut(...texts) : async (...texts) => await mainOut(...texts);
|
|
15
|
+
|
|
16
|
+
//console.log('testResult', testResult)
|
|
15
17
|
|
|
16
18
|
await timeProfileAsync('show test loading error', () => {
|
|
17
19
|
const indent = ' ';
|
|
18
20
|
out();
|
|
19
21
|
out(chalk.grey`File ${test.file}`);
|
|
20
22
|
out(chalk.mediumred`Loading error:\n${test.error}`);
|
|
21
|
-
|
|
22
|
-
if (test.logs.length > 0) {
|
|
23
|
+
if (test.logs && test.logs.length > 0) {
|
|
23
24
|
out();
|
|
24
25
|
out(indent + chalk.grey`console.logs:`);
|
|
25
26
|
test.logs.forEach(async log => {
|
|
@@ -27,7 +28,6 @@ export async function showTestLoadingError(config, test, customOut = undefined)
|
|
|
27
28
|
await out(...log);
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
|
|
31
31
|
out();
|
|
32
32
|
});
|
|
33
33
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { defaultConfig } from './defaultConfig.js';
|
|
2
2
|
import { showTestLoadingError } from './showTestLoadingError.js';
|
|
3
|
-
import { expect } from 'chai';
|
|
3
|
+
import { expect } from 'chai';
|
|
4
|
+
|
|
5
|
+
// showTestLoadingError(config, test) ???
|
|
4
6
|
|
|
5
7
|
await mochaDescribe('showTestLoadingError() function', async function () {
|
|
6
8
|
await mochaIt('should show the loading error of a test after loading failure', async function () {
|
|
@@ -8,10 +10,10 @@ await mochaDescribe('showTestLoadingError() function', async function () {
|
|
|
8
10
|
const test = {
|
|
9
11
|
file: 'foo.js',
|
|
10
12
|
error: 'There was an error'
|
|
11
|
-
};
|
|
13
|
+
};
|
|
12
14
|
|
|
15
|
+
// create a custom out function to capture the output
|
|
13
16
|
let outBuffer = '';
|
|
14
|
-
|
|
15
17
|
const customOut = (...texts) => {
|
|
16
18
|
//console.log('custom out received:', ...texts)
|
|
17
19
|
outBuffer += texts.join(' ') + '\n'; // join and save to the buffer
|
|
@@ -2,8 +2,8 @@ import { createTimeProfiler } from 'sxy-dev-tools';
|
|
|
2
2
|
import { packageName, cliName, configFileName, configLocations, showTimeProfiling } from '../../config.js';
|
|
3
3
|
import chalk from 'chalk-extensions';
|
|
4
4
|
import { out as mainOut, log, debug } from '../../output.js';
|
|
5
|
-
import figures from 'figures';
|
|
6
|
-
|
|
5
|
+
import figures from 'figures';
|
|
6
|
+
//import { testsState } from '../../testsState.js'
|
|
7
7
|
import 'sxy-standard/light.js';
|
|
8
8
|
import { indexNumberToLetters } from '../../indexNumberToLetters.js';
|
|
9
9
|
const {
|
|
@@ -11,13 +11,14 @@ const {
|
|
|
11
11
|
} = await createTimeProfiler(showTimeProfiling);
|
|
12
12
|
export async function showTestResult(config, testResult, customOut = undefined) {
|
|
13
13
|
await debug('customOut', customOut);
|
|
14
|
-
const out = customOut ? async (...texts) => await customOut(...texts) : async (...texts) => await mainOut(...texts);
|
|
14
|
+
const out = customOut ? async (...texts) => await customOut(...texts) : async (...texts) => await mainOut(...texts);
|
|
15
|
+
|
|
16
|
+
//console.log('testResult', testResult)
|
|
15
17
|
|
|
16
18
|
await timeProfileAsync('show test result', () => {
|
|
17
19
|
out();
|
|
18
20
|
out(chalk.grey`File ${testResult.file}`);
|
|
19
21
|
const indent = ' ';
|
|
20
|
-
|
|
21
22
|
if (testResult.logs.length > 0) {
|
|
22
23
|
out();
|
|
23
24
|
out(indent + chalk.grey`console.logs:`);
|
|
@@ -27,15 +28,12 @@ export async function showTestResult(config, testResult, customOut = undefined)
|
|
|
27
28
|
});
|
|
28
29
|
out();
|
|
29
30
|
}
|
|
30
|
-
|
|
31
31
|
let first = true;
|
|
32
|
-
|
|
33
32
|
for (const describeResult of testResult.describeResults) {
|
|
34
33
|
if (!first) out();
|
|
35
34
|
first = false;
|
|
36
35
|
out(chalk.lightgrey`${describeResult.counter}) describing ` + chalk.brightblue(describeResult.thing));
|
|
37
36
|
out();
|
|
38
|
-
|
|
39
37
|
if (describeResult.logs.length > 0) {
|
|
40
38
|
out(indent + chalk.grey`console.logs:`);
|
|
41
39
|
describeResult.logs.forEach(async log => {
|
|
@@ -44,35 +42,31 @@ export async function showTestResult(config, testResult, customOut = undefined)
|
|
|
44
42
|
});
|
|
45
43
|
out();
|
|
46
44
|
}
|
|
47
|
-
|
|
48
45
|
for (const itResult of describeResult.itResults) {
|
|
49
46
|
//console.log('itResult', itResult)
|
|
50
|
-
const letters = indexNumberToLetters(itResult.counter);
|
|
51
47
|
|
|
48
|
+
const letters = indexNumberToLetters(itResult.counter);
|
|
52
49
|
if (itResult.success) {
|
|
53
50
|
out(chalk.lightgrey`${indent}${letters})` + chalk.mediumgreen` ${figures.tick} ${itResult.should}`);
|
|
54
51
|
} else {
|
|
55
52
|
out(chalk.lightgrey`${indent}${letters})` + chalk.mediumred` ${figures.cross} ${itResult.should}`);
|
|
56
53
|
out();
|
|
57
54
|
const spacer = `${indent}${' '.repeat(letters.length)} `;
|
|
58
|
-
|
|
59
55
|
if ('actual' in itResult.error && 'expected' in itResult.error) {
|
|
60
|
-
out(chalk.mediumred(`${spacer}${itResult.error.name}: ${itResult.error.message}`
|
|
56
|
+
out(chalk.mediumred(`${spacer}${itResult.error.name}: ${itResult.error.message}`
|
|
57
|
+
//+ `\n${spacer}expected: ${itResult.error.expected}`
|
|
61
58
|
//+ `\n${spacer}received: ${itResult.error.actual}`
|
|
62
59
|
));
|
|
63
60
|
} else {
|
|
64
61
|
out(chalk.mediumred(`${spacer}${itResult.error.name}: ${itResult.error.message}`));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
}
|
|
63
|
+
// stack trace
|
|
68
64
|
if (config.showErrorTrace) {
|
|
69
65
|
out();
|
|
70
66
|
out(chalk.grey(itResult.error.stack));
|
|
71
67
|
}
|
|
72
68
|
}
|
|
73
|
-
|
|
74
69
|
out();
|
|
75
|
-
|
|
76
70
|
if (itResult.logs.length > 0) {
|
|
77
71
|
out(indent + indent + chalk.grey`console.logs:`);
|
|
78
72
|
itResult.logs.forEach(async log => {
|
|
@@ -2,7 +2,9 @@ import { defaultConfig } from './defaultConfig.js';
|
|
|
2
2
|
import { showTestResult } from './showTestResult.js';
|
|
3
3
|
import { applyConfigDefaults } from './applyConfigDefaults.js';
|
|
4
4
|
import { loadTestFile } from './loadTestFile.js';
|
|
5
|
-
import { runTest } from './runTest.js';
|
|
5
|
+
import { runTest } from './runTest.js';
|
|
6
|
+
|
|
7
|
+
// loadTestFile(config, testFile) ???
|
|
6
8
|
|
|
7
9
|
await mochaDescribe('showTestResult() function', async function () {
|
|
8
10
|
await mochaIt('should show the result of a single test that has been run', async function () {
|
|
@@ -35,33 +37,34 @@ await mochaDescribe('showTestResult() function', async function () {
|
|
|
35
37
|
itsTotal: 1,
|
|
36
38
|
itsPasses: 1
|
|
37
39
|
}
|
|
38
|
-
};
|
|
40
|
+
};
|
|
39
41
|
|
|
42
|
+
// create a custom out function to capture the output
|
|
40
43
|
let outBuffer = '';
|
|
41
|
-
|
|
42
44
|
const customOut = (...texts) => {
|
|
43
45
|
//console.log('custom out received:', ...texts)
|
|
44
46
|
outBuffer += texts.join(' ') + '\n'; // join and save to the buffer
|
|
45
47
|
//console.log('outBuffer:', outBuffer)
|
|
46
48
|
};
|
|
47
49
|
|
|
48
|
-
await showTestResult(config, sampleTestResult, customOut);
|
|
50
|
+
await showTestResult(config, sampleTestResult, customOut);
|
|
51
|
+
|
|
52
|
+
//console.log(outBuffer)
|
|
49
53
|
|
|
50
|
-
await outBuffer.should.include(sampleTestResult.file);
|
|
54
|
+
await outBuffer.should.include(sampleTestResult.file);
|
|
51
55
|
|
|
56
|
+
//console.log('---', sampleTestResult.describeResults[0].thing)
|
|
52
57
|
await outBuffer.should.include(sampleTestResult.describeResults[0].thing);
|
|
53
58
|
await outBuffer.should.include(sampleTestResult.describeResults[0].itResults[0].should);
|
|
54
59
|
});
|
|
55
60
|
await mochaIt('should show the result of a test with an error', async function () {
|
|
56
61
|
const config = defaultConfig;
|
|
57
62
|
let error;
|
|
58
|
-
|
|
59
63
|
try {
|
|
60
64
|
await (await chaiExpect(1)).to.equal(2);
|
|
61
65
|
} catch (e) {
|
|
62
66
|
error = e;
|
|
63
67
|
}
|
|
64
|
-
|
|
65
68
|
const sampleTestResult = {
|
|
66
69
|
file: 'unitTesting/sampleTests/1.test.js',
|
|
67
70
|
success: true,
|
|
@@ -89,17 +92,19 @@ await mochaDescribe('showTestResult() function', async function () {
|
|
|
89
92
|
itsTotal: 1,
|
|
90
93
|
itsPasses: 1
|
|
91
94
|
}
|
|
92
|
-
};
|
|
95
|
+
};
|
|
93
96
|
|
|
97
|
+
// create a custom out function to capture the output
|
|
94
98
|
let outBuffer = '';
|
|
95
|
-
|
|
96
99
|
const customOut = (...texts) => {
|
|
97
100
|
//console.log('custom out received:', ...texts)
|
|
98
101
|
outBuffer += texts.join(' ') + '\n'; // join and save to the buffer
|
|
99
102
|
//console.log('outBuffer:', outBuffer)
|
|
100
103
|
};
|
|
101
104
|
|
|
102
|
-
await showTestResult(config, sampleTestResult, customOut);
|
|
105
|
+
await showTestResult(config, sampleTestResult, customOut);
|
|
106
|
+
|
|
107
|
+
//console.log(outBuffer)
|
|
103
108
|
|
|
104
109
|
await outBuffer.should.include('AssertionError');
|
|
105
110
|
await outBuffer.should.include('expected 1 to equal 2');
|
|
@@ -134,20 +139,23 @@ await mochaDescribe('showTestResult() function', async function () {
|
|
|
134
139
|
itsTotal: 1,
|
|
135
140
|
itsPasses: 1
|
|
136
141
|
}
|
|
137
|
-
};
|
|
142
|
+
};
|
|
138
143
|
|
|
144
|
+
// create a custom out function to capture the output
|
|
139
145
|
let outBuffer = '';
|
|
140
|
-
|
|
141
146
|
const customOut = (...texts) => {
|
|
142
147
|
//console.log('custom out received:', ...texts)
|
|
143
148
|
outBuffer += texts.join(' ') + '\n'; // join and save to the buffer
|
|
144
149
|
//console.log('outBuffer:', outBuffer)
|
|
145
150
|
};
|
|
146
151
|
|
|
147
|
-
await showTestResult(config, sampleTestResult, customOut);
|
|
152
|
+
await showTestResult(config, sampleTestResult, customOut);
|
|
153
|
+
|
|
154
|
+
//console.log(outBuffer)
|
|
148
155
|
|
|
149
|
-
await outBuffer.should.include(sampleTestResult.file);
|
|
156
|
+
await outBuffer.should.include(sampleTestResult.file);
|
|
150
157
|
|
|
158
|
+
//console.log('---', sampleTestResult.describeResults[0].thing)
|
|
151
159
|
await outBuffer.should.include(sampleTestResult.describeResults[0].thing);
|
|
152
160
|
await outBuffer.should.include('foo');
|
|
153
161
|
await outBuffer.should.include(sampleTestResult.describeResults[0].itResults[0].should);
|
|
@@ -163,10 +171,10 @@ await mochaDescribe('showTestResult() function', async function () {
|
|
|
163
171
|
});
|
|
164
172
|
const sampleTestFile = 'unitTesting/sampleTests/logging.test.js';
|
|
165
173
|
const sampleTest = await loadTestFile(config, sampleTestFile);
|
|
166
|
-
const testResult = await runTest(config, sampleTest);
|
|
174
|
+
const testResult = await runTest(config, sampleTest);
|
|
167
175
|
|
|
176
|
+
// create a custom out function to capture the output
|
|
168
177
|
let outBuffer = '';
|
|
169
|
-
|
|
170
178
|
const customOut = (...texts) => {
|
|
171
179
|
//console.log('custom out received:', ...texts)
|
|
172
180
|
outBuffer += texts.join(' ') + '\n'; // join and save to the buffer
|
|
@@ -175,8 +183,9 @@ await mochaDescribe('showTestResult() function', async function () {
|
|
|
175
183
|
|
|
176
184
|
await showTestResult(config, testResult, customOut);
|
|
177
185
|
await console.log(outBuffer);
|
|
178
|
-
await outBuffer.should.include(testResult.file);
|
|
186
|
+
await outBuffer.should.include(testResult.file);
|
|
179
187
|
|
|
188
|
+
//console.log('---', sampleTestResult.describeResults[0].thing)
|
|
180
189
|
await outBuffer.should.include(testResult.describeResults[0].thing);
|
|
181
190
|
await outBuffer.should.include(testResult.describeResults[0].itResults[0].should);
|
|
182
191
|
await outBuffer.should.include('1st test log');
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { out as mainOut, log, debug } from '../../output.js';
|
|
2
2
|
export async function validateConfig(config, customOut = undefined) {
|
|
3
3
|
const out = customOut ? async (...texts) => await customOut(...texts) : async (...texts) => await mainOut(...texts);
|
|
4
|
-
|
|
5
4
|
if (config.execution === undefined) {
|
|
6
5
|
const message = `Config error, config.execution is not defined`;
|
|
7
6
|
await doError(message);
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
if (config.execution.files !== 'parallel' && config.execution.files !== 'sequential') {
|
|
11
9
|
const message = `Config error, config.execution.files should be 'parallel' or 'sequential'`;
|
|
12
10
|
await doError(message);
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
if (config.execution.describes !== 'parallel' && config.execution.describes !== 'sequential') {
|
|
16
13
|
const message = `Config error, config.execution.describes should be 'parallel' or 'sequential'`;
|
|
17
14
|
await doError(message);
|
|
18
15
|
}
|
|
19
|
-
|
|
20
16
|
if (config.execution.tests !== 'parallel' && config.execution.tests !== 'sequential') {
|
|
21
17
|
const message = `Config error, config.execution.tests should be 'parallel' or 'sequential'`;
|
|
22
18
|
await doError(message);
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
async function doError(message) {
|
|
26
21
|
await out(message);
|
|
27
22
|
throw new Error(message);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { applyConfigDefaults } from './applyConfigDefaults.js';
|
|
2
|
-
import { validateConfig } from './validateConfig.js';
|
|
2
|
+
import { validateConfig } from './validateConfig.js';
|
|
3
|
+
// loadTestFile(config, testFile) ???
|
|
3
4
|
|
|
4
5
|
import { makeCustomOut } from '../../../unitTesting/makeCustomOut.js';
|
|
5
6
|
await mochaDescribe('validateConfig() function', async function () {
|
|
@@ -10,12 +11,10 @@ await mochaDescribe('validateConfig() function', async function () {
|
|
|
10
11
|
files: 'typo'
|
|
11
12
|
}
|
|
12
13
|
});
|
|
13
|
-
|
|
14
14
|
try {
|
|
15
15
|
await validateConfig(config, customOut);
|
|
16
16
|
} catch (e) {} // eslint-disable-line
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
await (await customOut.getOutBuffer()).should.include('Config error');
|
|
20
19
|
await (await customOut.getOutBuffer()).should.include('execution.files');
|
|
21
20
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { promises as fs } from 'fs';
|
|
2
2
|
import { watchFiles } from './watchFiles.js';
|
|
3
|
-
import { applyConfigDefaults } from './applyConfigDefaults.js';
|
|
3
|
+
import { applyConfigDefaults } from './applyConfigDefaults.js';
|
|
4
|
+
|
|
5
|
+
// watchFiles(config, callback)
|
|
4
6
|
|
|
5
7
|
await mochaDescribe('watchFiles() function', async function () {
|
|
6
8
|
await mochaIt('should call back when when a file change occurs', async function () {
|
|
@@ -10,7 +12,7 @@ await mochaDescribe('watchFiles() function', async function () {
|
|
|
10
12
|
await watchFiles(config, async (filename, event) => {
|
|
11
13
|
eventComplete = true;
|
|
12
14
|
});
|
|
13
|
-
await fs.writeFile('
|
|
15
|
+
await fs.writeFile('watchTests/watchFiles-file.js', 'abc');
|
|
14
16
|
await new Promise(async (resolve, reject) => {
|
|
15
17
|
const interval = await setInterval(async () => {
|
|
16
18
|
if (eventComplete) {
|
|
@@ -23,7 +25,7 @@ await mochaDescribe('watchFiles() function', async function () {
|
|
|
23
25
|
});
|
|
24
26
|
await mochaIt('should call back when when a file change occurs in specified folder', async function () {
|
|
25
27
|
await this.timeout(10000);
|
|
26
|
-
const tempFolder = '
|
|
28
|
+
const tempFolder = 'watchTests/watchFiles';
|
|
27
29
|
const config = await applyConfigDefaults({
|
|
28
30
|
watch: {
|
|
29
31
|
watchFilesBase: tempFolder,
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { watchFilesAndRunTestsNodeWatch as watchFilesAndRunTests } from './watchFilesAndRunTestsNodeWatch.js';
|
|
1
|
+
export { watchFilesAndRunTestsNodeWatch as watchFilesAndRunTests } from './watchFilesAndRunTestsNodeWatch.js';
|
|
2
|
+
|
|
3
|
+
//export { watchFilesAndRunTestsChokidar as watchFilesAndRunTests }
|
|
2
4
|
// from './watchFilesAndRunTestsChokidar.js'
|