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.
- package/package.json +1 -1
- package/dist/cli/init.js +0 -170
- package/dist/cli/init.unitTest.js +0 -0
- package/dist/cli/lib/addBasePath.js +0 -15
- package/dist/cli/lib/addBasePath.unitTest.js +0 -31
- package/dist/cli/lib/addExports.js +0 -12
- package/dist/cli/lib/addExports.unitTest.js +0 -29
- package/dist/cli/lib/applyConfigDefaults.js +0 -41
- package/dist/cli/lib/applyConfigDefaults.unitTest.js +0 -25
- package/dist/cli/lib/buildDependencyTree.js +0 -32
- package/dist/cli/lib/buildDependencyTree.unitTest.js +0 -15
- package/dist/cli/lib/buildDependencyTrees.js +0 -34
- package/dist/cli/lib/buildDependencyTrees.unitTest.js +0 -17
- package/dist/cli/lib/configBeforeAfterFuncs.js +0 -35
- package/dist/cli/lib/configBeforeAfterFuncs.unitTest.js +0 -0
- package/dist/cli/lib/defaultConfig.js +0 -22
- package/dist/cli/lib/defaultConfig.test.js +0 -7
- package/dist/cli/lib/doUserSetup.js +0 -30
- package/dist/cli/lib/doUserSetup.unitTest.js +0 -39
- package/dist/cli/lib/doUserTeardown.js +0 -30
- package/dist/cli/lib/doUserTeardown.unitTest.js +0 -39
- package/dist/cli/lib/findTestFiles.js +0 -24
- package/dist/cli/lib/findTestFiles.unitTest.js +0 -22
- package/dist/cli/lib/getAllowedFlags.js +0 -11
- package/dist/cli/lib/getAllowedFlags.unitTest.js +0 -20
- package/dist/cli/lib/globArgCombine.js +0 -1
- package/dist/cli/lib/globArgCombine.unitTest.js +0 -18
- package/dist/cli/lib/injectProperties.js +0 -11
- package/dist/cli/lib/injectProperties.unitTest.js +0 -75
- package/dist/cli/lib/load.js +0 -3
- package/dist/cli/lib/load.unitTest.js +0 -7
- package/dist/cli/lib/loadConfig.js +0 -21
- package/dist/cli/lib/loadConfig.unitTest.js +0 -15
- package/dist/cli/lib/loadTestFile.js +0 -75
- package/dist/cli/lib/loadTestFile.unitTest.js +0 -51
- package/dist/cli/lib/loadTestFileStatic.js +0 -40
- package/dist/cli/lib/loadTestFileStatic.unitTest.js +0 -29
- package/dist/cli/lib/overrideConsoleLog.js +0 -20
- package/dist/cli/lib/overrideConsoleLog.unitTest.js +0 -0
- package/dist/cli/lib/parseCommandLineArguments.js +0 -57
- package/dist/cli/lib/parseCommandLineArguments.unitTest.js +0 -21
- package/dist/cli/lib/processWatchEvent.js +0 -0
- package/dist/cli/lib/processWatchEvent.unitTest.js +0 -7
- package/dist/cli/lib/reservedExportKeys.js +0 -1
- package/dist/cli/lib/reservedExportKeys.unitTest.js +0 -7
- package/dist/cli/lib/runDescribe.js +0 -141
- package/dist/cli/lib/runDescribe.unitTest.js +0 -7
- package/dist/cli/lib/runIt.js +0 -70
- package/dist/cli/lib/runIt.unitTest.js +0 -7
- package/dist/cli/lib/runTasks.js +0 -42
- package/dist/cli/lib/runTasks.unitTest.js +0 -30
- package/dist/cli/lib/runTest-old.js +0 -159
- package/dist/cli/lib/runTest-old.unitTest.js +0 -183
- package/dist/cli/lib/runTestFile copy.js +0 -292
- package/dist/cli/lib/runTestFile-old.js +0 -348
- package/dist/cli/lib/runTestFile.js +0 -105
- package/dist/cli/lib/runTestFile.unitTest.js +0 -264
- package/dist/cli/lib/runTestFiles.js +0 -141
- package/dist/cli/lib/runTestFiles.unitTest.js +0 -147
- package/dist/cli/lib/shouldCaptureConsoleLog.js +0 -24
- package/dist/cli/lib/shouldCaptureConsoleLog.unitTest.js +0 -31
- package/dist/cli/lib/showTestLoadingError.js +0 -22
- package/dist/cli/lib/showTestLoadingError.unitTest.js +0 -25
- package/dist/cli/lib/showTestResult.js +0 -87
- package/dist/cli/lib/showTestResult.unitTest.js +0 -180
- package/dist/cli/lib/validateConfig.js +0 -29
- package/dist/cli/lib/validateConfig.unitTest.js +0 -22
- package/dist/cli/lib/watchFiles.js +0 -1
- package/dist/cli/lib/watchFiles.unitTest.js +0 -48
- package/dist/cli/lib/watchFilesAndRunTests.js +0 -2
- package/dist/cli/lib/watchFilesAndRunTests.unitTest.js +0 -129
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.js +0 -142
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js +0 -133
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js +0 -162
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js +0 -131
- package/dist/cli/lib/watchFilesChokidar.js +0 -56
- package/dist/cli/lib/watchFilesChokidar.unitTest.js +0 -85
- package/dist/cli/lib/watchFilesNodeWatch.js +0 -42
- package/dist/cli/lib/watchFilesNodeWatch.unitTest.js +0 -48
- package/dist/cli/once.js +0 -47
- package/dist/cli/once.unitTest.js +0 -39
- package/dist/cli/watch.js +0 -100
- package/dist/cli/watch.unitTest.js +0 -117
- package/dist/config.js +0 -7
- package/dist/describe-old.js +0 -257
- package/dist/describe-old.unitTest.js +0 -21
- package/dist/describe.js +0 -24
- package/dist/describe.unitTest.js +0 -27
- package/dist/exported.eslintrc.cjs +0 -7
- package/dist/index.js +0 -1
- package/dist/indexNumberToLetters.js +0 -13
- package/dist/load.js +0 -3
- package/dist/output.js +0 -17
- package/dist/testsState.js +0 -4
- package/dist/timeProfiling.js +0 -9
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
// to be populated with the func from runTestFile.js
|
|
2
|
-
import { createTimeProfiler } from 'sxy-dev-tools';
|
|
3
|
-
import { showTimeProfiling } from '../../config.js';
|
|
4
|
-
import { out, log, debug } from '../../output.js';
|
|
5
|
-
import { shouldCaptureConsoleLog } from './shouldCaptureConsoleLog.js';
|
|
6
|
-
import { overrideConsoleLog } from './overrideConsoleLog.js';
|
|
7
|
-
import { addExports } from './addExports.js';
|
|
8
|
-
import { configBeforeEachDescribe, configAfterEachDescribe } from './configBeforeAfterFuncs.js';
|
|
9
|
-
import { runIt } from './runIt.js';
|
|
10
|
-
const {
|
|
11
|
-
timeProfileAsync
|
|
12
|
-
} = await createTimeProfiler(showTimeProfiling);
|
|
13
|
-
export async function runDescribe(config, describe) {
|
|
14
|
-
return await timeProfileAsync(`run describe ${describe.thing}`, async () => {
|
|
15
|
-
// afterDescribe
|
|
16
|
-
let afterDescribeFunc;
|
|
17
|
-
|
|
18
|
-
async function afterDescribe(func) {
|
|
19
|
-
if (typeof func !== 'function') {
|
|
20
|
-
throw new Error(`afterDescribe() error, argument passed to afterDescribe() must be a function,` + ` received ${typeof func}`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
afterDescribeFunc = func;
|
|
24
|
-
} // beforeEachTest
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let beforeEachTestFunc;
|
|
28
|
-
|
|
29
|
-
async function beforeEachTest(func) {
|
|
30
|
-
if (typeof func !== 'function') {
|
|
31
|
-
throw new Error(`afterDescribe() error, argument passed to afterDescribe() must be a function,` + ` received ${typeof func}`);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
beforeEachTestFunc = func;
|
|
35
|
-
} // afterEachTest
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
let afterEachTestFunc;
|
|
39
|
-
|
|
40
|
-
async function afterEachTest(func) {
|
|
41
|
-
if (typeof func !== 'function') {
|
|
42
|
-
throw new Error(`afterDescribe() error, argument passed to afterDescribe() must be a function,` + ` received ${typeof func}`);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
afterEachTestFunc = func;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let itCounter = 1;
|
|
49
|
-
const its = []; // create functions to pass back
|
|
50
|
-
// it
|
|
51
|
-
|
|
52
|
-
async function it(should, test) {
|
|
53
|
-
const thisItCounter = itCounter++;
|
|
54
|
-
await its.push({
|
|
55
|
-
counter: thisItCounter,
|
|
56
|
-
should,
|
|
57
|
-
test
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const test = it;
|
|
62
|
-
const describeExports = {};
|
|
63
|
-
await configBeforeEachDescribe(config, describeExports);
|
|
64
|
-
const describeParcel = {
|
|
65
|
-
it,
|
|
66
|
-
test,
|
|
67
|
-
afterDescribe,
|
|
68
|
-
beforeEachTest,
|
|
69
|
-
afterEachTest
|
|
70
|
-
};
|
|
71
|
-
await addExports(describeParcel, describeExports); // capture the console.log output if we can
|
|
72
|
-
|
|
73
|
-
let originalConsoleLog, replacementConsoleLog;
|
|
74
|
-
|
|
75
|
-
if (await shouldCaptureConsoleLog(config, 'describe')) {
|
|
76
|
-
({
|
|
77
|
-
originalConsoleLog,
|
|
78
|
-
replacementConsoleLog
|
|
79
|
-
} = await overrideConsoleLog());
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
try {
|
|
83
|
-
await describe.tests(describeParcel);
|
|
84
|
-
} catch (e) {
|
|
85
|
-
const describeErrorResult = {
|
|
86
|
-
counter: describe.counter,
|
|
87
|
-
thing: describe.thing,
|
|
88
|
-
error: e.message,
|
|
89
|
-
success: false
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
if (await shouldCaptureConsoleLog(config, 'describe')) {
|
|
93
|
-
console.log = originalConsoleLog; // eslint-disable-line no-console
|
|
94
|
-
|
|
95
|
-
describeErrorResult.consoleLogs = replacementConsoleLog.logs;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return describeErrorResult;
|
|
99
|
-
} //!!!!! should this be here, or at the end after its?
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
let describeConsoleLogs;
|
|
103
|
-
|
|
104
|
-
if (await shouldCaptureConsoleLog(config, 'describe')) {
|
|
105
|
-
console.log = originalConsoleLog; // eslint-disable-line no-console
|
|
106
|
-
|
|
107
|
-
describeConsoleLogs = replacementConsoleLog.logs; //!!!!!! This needs to be applied
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const itResults = [];
|
|
111
|
-
|
|
112
|
-
for (const it of its) {
|
|
113
|
-
await itResults.push(await runIt(config, it, beforeEachTestFunc, afterEachTestFunc));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const itResultsSummary = {
|
|
117
|
-
total: 0,
|
|
118
|
-
passes: 0
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
for (const itResult of itResults) {
|
|
122
|
-
itResultsSummary.total += +(itResult.success !== null);
|
|
123
|
-
itResultsSummary.passes += +itResult.success;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
await debug('itResultsSummary', itResultsSummary);
|
|
127
|
-
const describeResult = {
|
|
128
|
-
counter: describe.counter,
|
|
129
|
-
thing: describe.thing,
|
|
130
|
-
error: false,
|
|
131
|
-
success: itResultsSummary.total > 0 ? itResultsSummary.passes === itResultsSummary.total : null,
|
|
132
|
-
itResults,
|
|
133
|
-
itResultsSummary,
|
|
134
|
-
consoleLogs: describeConsoleLogs
|
|
135
|
-
}; // run after
|
|
136
|
-
|
|
137
|
-
if (typeof afterDescribeFunc === 'function') await afterDescribeFunc();
|
|
138
|
-
await configAfterEachDescribe(config, describeExports);
|
|
139
|
-
return describeResult;
|
|
140
|
-
});
|
|
141
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { applyConfigDefaults } from './applyConfigDefaults.js';
|
|
2
|
-
import { loadTestFile } from './loadTestFile.js';
|
|
3
|
-
import { runDescribe } from './runDescribe.js';
|
|
4
|
-
const defaultConfig = await applyConfigDefaults({});
|
|
5
|
-
await mochaDescribe('runDescribe() function', async function () {
|
|
6
|
-
await mochaIt('...', async function () {});
|
|
7
|
-
});
|
package/dist/cli/lib/runIt.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// to be populated with the func from runTestFile.js
|
|
2
|
-
import { createTimeProfiler } from 'sxy-dev-tools';
|
|
3
|
-
import { showTimeProfiling } from '../../config.js';
|
|
4
|
-
import { out, log, debug } from '../../output.js';
|
|
5
|
-
import { shouldCaptureConsoleLog } from './shouldCaptureConsoleLog.js';
|
|
6
|
-
import { overrideConsoleLog } from './overrideConsoleLog.js';
|
|
7
|
-
import { addExports } from './addExports.js';
|
|
8
|
-
import { configBeforeEachTest, configAfterEachTest } from './configBeforeAfterFuncs.js';
|
|
9
|
-
const {
|
|
10
|
-
timeProfileAsync
|
|
11
|
-
} = await createTimeProfiler(showTimeProfiling);
|
|
12
|
-
export async function runIt(config, it, beforeEachTestFunc, afterEachTestFunc) {
|
|
13
|
-
return await timeProfileAsync(`run it ${it.should}`, async () => {
|
|
14
|
-
// run before test/it
|
|
15
|
-
const testExports = {};
|
|
16
|
-
await configBeforeEachTest(config, testExports);
|
|
17
|
-
|
|
18
|
-
if (typeof beforeEachTestFunc === 'function') {
|
|
19
|
-
const funcExports = await beforeEachTestFunc();
|
|
20
|
-
await addExports(testExports, funcExports);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const testParcel = {};
|
|
24
|
-
await addExports(testParcel, testExports); //const thisItCounter = itCounter++ // assign THEN increment
|
|
25
|
-
// capture the console.log output if we can
|
|
26
|
-
|
|
27
|
-
let originalConsoleLog, replacementConsoleLog;
|
|
28
|
-
|
|
29
|
-
if (await shouldCaptureConsoleLog(config, 'test')) {
|
|
30
|
-
({
|
|
31
|
-
originalConsoleLog,
|
|
32
|
-
replacementConsoleLog
|
|
33
|
-
} = await overrideConsoleLog());
|
|
34
|
-
} //// run the it
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
let success = null;
|
|
38
|
-
let error;
|
|
39
|
-
const startTime = await new Date().getTime();
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
await it.test(testParcel);
|
|
43
|
-
success = true;
|
|
44
|
-
} catch (e) {
|
|
45
|
-
success = false;
|
|
46
|
-
error = e;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const time = (await new Date().getTime()) - startTime;
|
|
50
|
-
const itResult = {
|
|
51
|
-
//counter: thisItCounter,
|
|
52
|
-
counter: it.counter,
|
|
53
|
-
should: it.should,
|
|
54
|
-
success,
|
|
55
|
-
time,
|
|
56
|
-
error
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
if (await shouldCaptureConsoleLog(config, 'test')) {
|
|
60
|
-
console.log = originalConsoleLog; // eslint-disable-line no-console
|
|
61
|
-
|
|
62
|
-
itResult.consoleLogs = replacementConsoleLog.logs;
|
|
63
|
-
} // run after test/it
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (typeof afterEachTestFunc === 'function') await afterEachTestFunc();
|
|
67
|
-
await configAfterEachTest(config, testExports);
|
|
68
|
-
return itResult;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { applyConfigDefaults } from './applyConfigDefaults.js';
|
|
2
|
-
import { loadTestFile } from './loadTestFile.js';
|
|
3
|
-
import { runIt } from './runIt.js';
|
|
4
|
-
const defaultConfig = await applyConfigDefaults({});
|
|
5
|
-
await mochaDescribe('runIt() function', async function () {
|
|
6
|
-
await mochaIt('...', async function () {});
|
|
7
|
-
});
|
package/dist/cli/lib/runTasks.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import { out, log, debug } from '../../output.js';
|
|
3
|
-
import { addExports } from './addExports.js';
|
|
4
|
-
export async function runTasks(tasks, parcel = undefined) {
|
|
5
|
-
if (tasks) {
|
|
6
|
-
if (!(await Array.isArray(tasks))) tasks = [tasks];
|
|
7
|
-
const exports = {};
|
|
8
|
-
|
|
9
|
-
for (const task of tasks) {
|
|
10
|
-
await debug('task', typeof task, task);
|
|
11
|
-
|
|
12
|
-
switch (typeof task) {
|
|
13
|
-
case 'function':
|
|
14
|
-
{
|
|
15
|
-
const result = parcel !== undefined // redundent currently
|
|
16
|
-
? await task(parcel) : await task();
|
|
17
|
-
await addExports(exports, result);
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
case 'string':
|
|
22
|
-
{
|
|
23
|
-
const result = await import(`file://${await join(await process.cwd(), task)}`); //console.log
|
|
24
|
-
|
|
25
|
-
await addExports(exports, result);
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
default:
|
|
30
|
-
{
|
|
31
|
-
await out(`Error: task entry has an invalid type, expected 'function' or 'string' of an file to import.`);
|
|
32
|
-
await out(`Received '${typeof task}'.`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return exports;
|
|
38
|
-
} else {
|
|
39
|
-
await debug('no tasks');
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { runTasks } from './runTasks.js';
|
|
2
|
-
import { defaultConfig } from './defaultConfig.js'; // runTasks(config, tasks)
|
|
3
|
-
// config:
|
|
4
|
-
// tasks: function, file location, or array of those
|
|
5
|
-
|
|
6
|
-
await mochaDescribe('runTasks() function', async function () {
|
|
7
|
-
await mochaIt('runs tasks (functions and/or files) passed to it', async function () {
|
|
8
|
-
let functionHasRun = false;
|
|
9
|
-
global.taskFileHasRun = false;
|
|
10
|
-
const tasks = [async function () {
|
|
11
|
-
functionHasRun = true;
|
|
12
|
-
}, 'unitTesting/runTasks/task.js'];
|
|
13
|
-
await runTasks(tasks);
|
|
14
|
-
await functionHasRun.should.equal(true);
|
|
15
|
-
await global.taskFileHasRun.should.equal(true);
|
|
16
|
-
});
|
|
17
|
-
await mochaIt('passes back the properties returned from tasks', async function () {
|
|
18
|
-
const tasks = [async function () {
|
|
19
|
-
return {
|
|
20
|
-
a: 1
|
|
21
|
-
};
|
|
22
|
-
}, async function () {
|
|
23
|
-
return {
|
|
24
|
-
b: 2
|
|
25
|
-
};
|
|
26
|
-
}, 'unitTesting/runTasks/export.js'];
|
|
27
|
-
const exports = await runTasks(tasks);
|
|
28
|
-
await exports.should.have.keys(['a', 'b', 'c']);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
import { createTimeProfiler } from 'sxy-dev-tools'
|
|
3
|
-
import chalk from 'chalk-extensions'
|
|
4
|
-
import { out, log, debug } from '../../output.js'
|
|
5
|
-
import { showTimeProfiling } from '../../config.js'
|
|
6
|
-
|
|
7
|
-
import { runTasks } from './runTasks.js'
|
|
8
|
-
|
|
9
|
-
const { timeProfileAsync } = createTimeProfiler(showTimeProfiling)
|
|
10
|
-
|
|
11
|
-
export function runTest(config, test, customOut = undefined) {
|
|
12
|
-
|
|
13
|
-
return timeProfileAsync(`run test ${test.file}`, () => {
|
|
14
|
-
|
|
15
|
-
// run before test
|
|
16
|
-
if (config.beforeEachFile) runTasks(config, config.beforeEachFile)
|
|
17
|
-
|
|
18
|
-
// const beforeEachFileExports = (config.beforeEachFile)
|
|
19
|
-
// ? runTasks(config, config.beforeEachFile)
|
|
20
|
-
// : {}
|
|
21
|
-
|
|
22
|
-
let describeCounter = 1
|
|
23
|
-
const describeRunPromises = []
|
|
24
|
-
|
|
25
|
-
for (const describe of test.describes) {
|
|
26
|
-
|
|
27
|
-
describeRunPromises.push(
|
|
28
|
-
promise( runDescribe(config, describe) )
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const describeResults = Promise.all(describeRunPromises)
|
|
34
|
-
|
|
35
|
-
const describeResultsSummary = {
|
|
36
|
-
total: 0,
|
|
37
|
-
passes: 0,
|
|
38
|
-
itsTotal: 0,
|
|
39
|
-
itsPasses: 0,
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
for ( const describeResult of describeResults ) {
|
|
44
|
-
describeResultsSummary.total += +(describeResult.success !== null)
|
|
45
|
-
describeResultsSummary.passes += +describeResult.success
|
|
46
|
-
describeResultsSummary.itsTotal += describeResult.itResultsSummary.total
|
|
47
|
-
describeResultsSummary.itsPasses += describeResult.itResultsSummary.passes
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const testResults = {
|
|
51
|
-
file: test.file,
|
|
52
|
-
success: (describeResultsSummary.total > 0)
|
|
53
|
-
? describeResultsSummary.total === describeResultsSummary.passes
|
|
54
|
-
: null,
|
|
55
|
-
describeResults,
|
|
56
|
-
describeResultsSummary,
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// run after test
|
|
60
|
-
if (config.afterEachFile) runTasks(config, config.afterEachFile)
|
|
61
|
-
|
|
62
|
-
return testResults
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
function runDescribe(config, describe) {
|
|
66
|
-
|
|
67
|
-
return timeProfileAsync(`run describe ${describe.thing}`, () => {
|
|
68
|
-
|
|
69
|
-
// run before describe
|
|
70
|
-
if (config.beforeEachDescribe) runTasks(config, config.beforeEachDescribe)
|
|
71
|
-
|
|
72
|
-
// const beforeEachDescribeExports = (config.beforeEachDescribe)
|
|
73
|
-
// ? runTasks(config, config.beforeEachDescribe)
|
|
74
|
-
// : {}
|
|
75
|
-
|
|
76
|
-
const thisDescribeCounter = describeCounter++ // assign THEN increment
|
|
77
|
-
let itCounter = 1
|
|
78
|
-
const itResults = []
|
|
79
|
-
|
|
80
|
-
for ( const it of describe.its ) {
|
|
81
|
-
itResults.push( runIt(config, it) )
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const itResultsSummary = {
|
|
85
|
-
total: 0,
|
|
86
|
-
passes: 0,
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
for ( const itResult of itResults ) {
|
|
90
|
-
itResultsSummary.total += +(itResult.success !== null)
|
|
91
|
-
itResultsSummary.passes += +itResult.success
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const describeResult = {
|
|
95
|
-
counter: thisDescribeCounter,
|
|
96
|
-
thing: describe.thing,
|
|
97
|
-
success: (itResultsSummary.total > 0)
|
|
98
|
-
? itResultsSummary.passes === itResultsSummary.total
|
|
99
|
-
: null,
|
|
100
|
-
itResults,
|
|
101
|
-
itResultsSummary
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// run after describe
|
|
105
|
-
if (config.afterEachDescribe) runTasks(config, config.afterEachDescribe)
|
|
106
|
-
|
|
107
|
-
return describeResult
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
function runIt(config, it, exports) {
|
|
111
|
-
|
|
112
|
-
return timeProfileAsync(`run it ${it.should}`, () => {
|
|
113
|
-
|
|
114
|
-
// run before test/it
|
|
115
|
-
if (config.beforeEachTest) runTasks(config, config.beforeEachTest)
|
|
116
|
-
|
|
117
|
-
const thisItCounter = itCounter++ // assign THEN increment
|
|
118
|
-
|
|
119
|
-
//// run the it
|
|
120
|
-
let success = null
|
|
121
|
-
let error
|
|
122
|
-
const startTime = (new Date).getTime()
|
|
123
|
-
try {
|
|
124
|
-
it.test()
|
|
125
|
-
success = true
|
|
126
|
-
} catch (e) {
|
|
127
|
-
success = false
|
|
128
|
-
error = e
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const time = (new Date).getTime() - startTime
|
|
132
|
-
|
|
133
|
-
const itResult = {
|
|
134
|
-
counter: thisItCounter,
|
|
135
|
-
should: it.should,
|
|
136
|
-
success,
|
|
137
|
-
time,
|
|
138
|
-
error
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// run after test/it
|
|
142
|
-
if (config.afterEachTest) runTasks(config, config.afterEachTest)
|
|
143
|
-
|
|
144
|
-
return itResult
|
|
145
|
-
//testResults.push(testResult)
|
|
146
|
-
//testsState.testResults.push(testResult)
|
|
147
|
-
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
*/
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
import { applyConfigDefaults } from './applyConfigDefaults.js'
|
|
3
|
-
import { loadTestFile } from './loadTestFile.js'
|
|
4
|
-
import { runTest } from './runTest.js'
|
|
5
|
-
|
|
6
|
-
// loadTestFile(config, testFile) ???
|
|
7
|
-
|
|
8
|
-
const defaultConfig = applyConfigDefaults({})
|
|
9
|
-
|
|
10
|
-
const beforeAfterTestFile = 'unitTesting/runTest/beforeAfter.test.js'
|
|
11
|
-
const beforeAfterTest = loadTestFile(defaultConfig, beforeAfterTestFile)
|
|
12
|
-
|
|
13
|
-
mochaDescribe('runTest() function', function() {
|
|
14
|
-
|
|
15
|
-
mochaIt('should run a test that was previously loaded from a test file', function() {
|
|
16
|
-
|
|
17
|
-
//const config = applyConfigDefaults({})
|
|
18
|
-
|
|
19
|
-
const sampleTestFile = 'unitTesting/runTest/1.test.js'
|
|
20
|
-
const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
|
|
21
|
-
|
|
22
|
-
const testResult = runTest(defaultConfig, sampleTest)
|
|
23
|
-
|
|
24
|
-
//console.log(testResult)
|
|
25
|
-
//console.log(testResult.describeResults[0].itResults)
|
|
26
|
-
//console.log(testResult.describeResults[0].itResultsSummary)
|
|
27
|
-
|
|
28
|
-
testResult.should.include.keys([
|
|
29
|
-
'file',
|
|
30
|
-
'success',
|
|
31
|
-
'describeResults',
|
|
32
|
-
'describeResultsSummary'
|
|
33
|
-
])
|
|
34
|
-
|
|
35
|
-
testResult.success.should.equal(true)
|
|
36
|
-
|
|
37
|
-
testResult.describeResultsSummary.total.should.equal(1)
|
|
38
|
-
testResult.describeResultsSummary.passes.should.equal(1)
|
|
39
|
-
testResult.describeResultsSummary.itsTotal.should.equal(1)
|
|
40
|
-
testResult.describeResultsSummary.itsPasses.should.equal(1)
|
|
41
|
-
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
mochaIt("should run beforeEachFile tasks (before - can't test)", function() {
|
|
45
|
-
|
|
46
|
-
let functionHasRun = false
|
|
47
|
-
global.beforeEachFileFileHasRun = false
|
|
48
|
-
|
|
49
|
-
const ourConfig = {
|
|
50
|
-
beforeEachFile: [
|
|
51
|
-
function() {
|
|
52
|
-
functionHasRun = true
|
|
53
|
-
},
|
|
54
|
-
'unitTesting/runTest/beforeEachFile.js'
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const config = applyConfigDefaults(ourConfig)
|
|
59
|
-
|
|
60
|
-
runTest(config, beforeAfterTest)
|
|
61
|
-
|
|
62
|
-
functionHasRun.should.equal(true)
|
|
63
|
-
global.beforeEachFileFileHasRun.should.equal(true)
|
|
64
|
-
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
mochaIt("should run afterEachFile tasks (after - can't test)", function() {
|
|
68
|
-
|
|
69
|
-
let functionHasRun = false
|
|
70
|
-
global.afterEachFileFileHasRun = false
|
|
71
|
-
|
|
72
|
-
const ourConfig = {
|
|
73
|
-
afterEachFile: [
|
|
74
|
-
function() {
|
|
75
|
-
functionHasRun = true
|
|
76
|
-
},
|
|
77
|
-
'unitTesting/runTest/afterEachFile.js'
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const config = applyConfigDefaults(ourConfig)
|
|
82
|
-
|
|
83
|
-
runTest(config, beforeAfterTest)
|
|
84
|
-
|
|
85
|
-
functionHasRun.should.equal(true)
|
|
86
|
-
global.afterEachFileFileHasRun.should.equal(true)
|
|
87
|
-
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
mochaIt("should run beforeEachDescribe tasks (before - can't test) each describe block", function() {
|
|
91
|
-
|
|
92
|
-
let functionHasRunTimes = 0
|
|
93
|
-
global.beforeEachDescribeFileHasRun = false
|
|
94
|
-
|
|
95
|
-
const ourConfig = {
|
|
96
|
-
beforeEachDescribe: [
|
|
97
|
-
function() {
|
|
98
|
-
functionHasRunTimes++
|
|
99
|
-
},
|
|
100
|
-
'unitTesting/runTest/beforeEachDescribe.js'
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const config = applyConfigDefaults(ourConfig)
|
|
105
|
-
|
|
106
|
-
runTest(config, beforeAfterTest)
|
|
107
|
-
|
|
108
|
-
functionHasRunTimes.should.equal(2)
|
|
109
|
-
global.beforeEachDescribeFileHasRun.should.equal(true)
|
|
110
|
-
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
mochaIt("should run afterEachDescribe tasks (after - can't test) each describe block", function() {
|
|
114
|
-
|
|
115
|
-
let functionHasRunTimes = 0
|
|
116
|
-
global.afterEachDescribeFileHasRun = false
|
|
117
|
-
|
|
118
|
-
const ourConfig = {
|
|
119
|
-
afterEachDescribe: [
|
|
120
|
-
function() {
|
|
121
|
-
functionHasRunTimes++
|
|
122
|
-
},
|
|
123
|
-
'unitTesting/runTest/afterEachDescribe.js'
|
|
124
|
-
]
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const config = applyConfigDefaults(ourConfig)
|
|
128
|
-
|
|
129
|
-
runTest(config, beforeAfterTest)
|
|
130
|
-
|
|
131
|
-
functionHasRunTimes.should.equal(2)
|
|
132
|
-
global.afterEachDescribeFileHasRun.should.equal(true)
|
|
133
|
-
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
mochaIt("should run beforeEachTest tasks (before - can't test) each test/it block", function() {
|
|
137
|
-
|
|
138
|
-
let functionHasRunTimes = 0
|
|
139
|
-
global.beforeEachTestbeforeEachFileFileHasRun = false
|
|
140
|
-
|
|
141
|
-
const ourConfig = {
|
|
142
|
-
beforeEachTest: [
|
|
143
|
-
function() {
|
|
144
|
-
functionHasRunTimes++
|
|
145
|
-
},
|
|
146
|
-
'unitTesting/runTest/beforeEachTest.js'
|
|
147
|
-
]
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const config = applyConfigDefaults(ourConfig)
|
|
151
|
-
|
|
152
|
-
runTest(config, beforeAfterTest)
|
|
153
|
-
|
|
154
|
-
functionHasRunTimes.should.equal(3)
|
|
155
|
-
global.beforeEachTestFileHasRun.should.equal(true)
|
|
156
|
-
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
mochaIt("should run afterEachTest tasks (after - can't test) each test/it block", function() {
|
|
160
|
-
|
|
161
|
-
let functionHasRunTimes = 0
|
|
162
|
-
global.afterEachTestFileFileHasRun = false
|
|
163
|
-
|
|
164
|
-
const ourConfig = {
|
|
165
|
-
afterEachTest: [
|
|
166
|
-
function() {
|
|
167
|
-
functionHasRunTimes++
|
|
168
|
-
},
|
|
169
|
-
'unitTesting/runTest/afterEachTest.js'
|
|
170
|
-
]
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const config = applyConfigDefaults(ourConfig)
|
|
174
|
-
|
|
175
|
-
runTest(config, beforeAfterTest)
|
|
176
|
-
|
|
177
|
-
functionHasRunTimes.should.equal(3)
|
|
178
|
-
global.afterEachTestFileHasRun.should.equal(true)
|
|
179
|
-
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
})
|
|
183
|
-
*/
|