sxy-test-runner 1.0.4 → 1.0.7
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/init.js +170 -0
- package/dist/cli/init.unitTest.js +0 -0
- package/dist/cli/lib/addBasePath.js +15 -0
- package/dist/cli/lib/addBasePath.unitTest.js +31 -0
- package/dist/cli/lib/addExports.js +12 -0
- package/dist/cli/lib/addExports.unitTest.js +29 -0
- package/dist/cli/lib/applyConfigDefaults.js +41 -0
- package/dist/cli/lib/applyConfigDefaults.unitTest.js +25 -0
- package/dist/cli/lib/buildDependencyTree.js +32 -0
- package/dist/cli/lib/buildDependencyTree.unitTest.js +15 -0
- package/dist/cli/lib/buildDependencyTrees.js +34 -0
- package/dist/cli/lib/buildDependencyTrees.unitTest.js +17 -0
- package/dist/cli/lib/configBeforeAfterFuncs.js +35 -0
- package/dist/cli/lib/configBeforeAfterFuncs.unitTest.js +0 -0
- package/dist/cli/lib/defaultConfig.js +22 -0
- package/dist/cli/lib/defaultConfig.test.js +7 -0
- package/dist/cli/lib/doUserSetup.js +30 -0
- package/dist/cli/lib/doUserSetup.unitTest.js +39 -0
- package/dist/cli/lib/doUserTeardown.js +30 -0
- package/dist/cli/lib/doUserTeardown.unitTest.js +39 -0
- package/dist/cli/lib/findTestFiles.js +24 -0
- package/dist/cli/lib/findTestFiles.unitTest.js +22 -0
- package/dist/cli/lib/getAllowedFlags.js +11 -0
- package/dist/cli/lib/getAllowedFlags.unitTest.js +20 -0
- package/dist/cli/lib/globArgCombine.js +1 -0
- package/dist/cli/lib/globArgCombine.unitTest.js +18 -0
- package/dist/cli/lib/injectProperties.js +11 -0
- package/dist/cli/lib/injectProperties.unitTest.js +75 -0
- package/dist/cli/lib/load.js +3 -0
- package/dist/cli/lib/load.unitTest.js +7 -0
- package/dist/cli/lib/loadConfig.js +21 -0
- package/dist/cli/lib/loadConfig.unitTest.js +15 -0
- package/dist/cli/lib/loadTestFile.js +75 -0
- package/dist/cli/lib/loadTestFile.unitTest.js +45 -0
- package/dist/cli/lib/loadTestFileStatic.js +40 -0
- package/dist/cli/lib/loadTestFileStatic.unitTest.js +29 -0
- package/dist/cli/lib/overrideConsoleLog.js +20 -0
- package/dist/cli/lib/overrideConsoleLog.unitTest.js +0 -0
- package/dist/cli/lib/parseCommandLineArguments.js +57 -0
- package/dist/cli/lib/parseCommandLineArguments.unitTest.js +21 -0
- package/dist/cli/lib/parseDescribe.js +88 -0
- package/dist/cli/lib/parseDescribe.unitTest.js +17 -0
- package/dist/cli/lib/processWatchEvent.js +0 -0
- package/dist/cli/lib/processWatchEvent.unitTest.js +7 -0
- package/dist/cli/lib/reservedExportKeys.js +1 -0
- package/dist/cli/lib/reservedExportKeys.unitTest.js +7 -0
- package/dist/cli/lib/runDescribe.js +29 -0
- package/dist/cli/lib/runDescribe.old.js +115 -0
- package/dist/cli/lib/runDescribe.old.unitTest.js +440 -0
- package/dist/cli/lib/runDescribe.unitTest.js +287 -0
- package/dist/cli/lib/runDescribeRun.js +59 -0
- package/dist/cli/lib/runDescribeRun.unitTest.js +293 -0
- package/dist/cli/lib/runIt.js +79 -0
- package/dist/cli/lib/runIt.unitTest.js +294 -0
- package/dist/cli/lib/runTasks.js +42 -0
- package/dist/cli/lib/runTasks.unitTest.js +30 -0
- package/dist/cli/lib/runTest-old.js +159 -0
- package/dist/cli/lib/runTest-old.unitTest.js +183 -0
- package/dist/cli/lib/runTest.js +71 -0
- package/dist/cli/lib/runTest.unitTest.js +269 -0
- package/dist/cli/lib/runTestFile copy.js +292 -0
- package/dist/cli/lib/runTestFile-old.js +348 -0
- package/dist/cli/lib/runTestFile.js +105 -0
- package/dist/cli/lib/runTestFile.unitTest.js +264 -0
- package/dist/cli/lib/runTestFiles.js +141 -0
- package/dist/cli/lib/runTestFiles.unitTest.js +147 -0
- package/dist/cli/lib/runTests.js +137 -0
- package/dist/cli/lib/runTests.unitTest.js +59 -0
- package/dist/cli/lib/shouldCaptureConsoleLog.js +24 -0
- package/dist/cli/lib/shouldCaptureConsoleLog.unitTest.js +31 -0
- package/dist/cli/lib/showTestLoadingError.js +22 -0
- package/dist/cli/lib/showTestLoadingError.unitTest.js +25 -0
- package/dist/cli/lib/showTestResult.js +87 -0
- package/dist/cli/lib/showTestResult.unitTest.js +180 -0
- package/dist/cli/lib/timeProfier.js +7 -0
- package/dist/cli/lib/validateConfig.js +29 -0
- package/dist/cli/lib/validateConfig.unitTest.js +22 -0
- package/dist/cli/lib/watchFiles.js +1 -0
- package/dist/cli/lib/watchFiles.unitTest.js +48 -0
- package/dist/cli/lib/watchFilesAndRunTests.js +2 -0
- package/dist/cli/lib/watchFilesAndRunTests.unitTest.js +129 -0
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.js +142 -0
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js +133 -0
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js +162 -0
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js +131 -0
- package/dist/cli/lib/watchFilesChokidar.js +56 -0
- package/dist/cli/lib/watchFilesChokidar.unitTest.js +85 -0
- package/dist/cli/lib/watchFilesNodeWatch.js +42 -0
- package/dist/cli/lib/watchFilesNodeWatch.unitTest.js +48 -0
- package/dist/cli/once.js +47 -0
- package/dist/cli/once.unitTest.js +39 -0
- package/dist/cli/watch.js +100 -0
- package/dist/cli/watch.unitTest.js +117 -0
- package/dist/config.js +7 -0
- package/dist/describe-old.js +257 -0
- package/dist/describe-old.unitTest.js +21 -0
- package/dist/describe.js +24 -0
- package/dist/describe.unitTest.js +27 -0
- package/dist/exported.eslintrc.cjs +7 -0
- package/dist/exported.eslintrc.js +7 -0
- package/dist/index.js +1 -0
- package/dist/indexNumberToLetters.js +13 -0
- package/dist/load.js +3 -0
- package/dist/output.js +17 -0
- package/dist/testsState.js +4 -0
- package/dist/timeProfiling.js +9 -0
- package/package.json +3 -2
- package/sxy-loader.config.js +10 -0
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { timeProfileAsync } from './timeProfier.js';
|
|
2
|
+
import { parseDescribe } from './parseDescribe.js';
|
|
3
|
+
import { runDescribeRun } from './runDescribeRun.js';
|
|
4
|
+
export async function runDescribe(config, describe) {
|
|
5
|
+
return await timeProfileAsync(`run describe ${describe.thing}`, async () => {
|
|
6
|
+
const capturingConsoleLog = config.execution.describes === 'sequential'; //// capture console.log output
|
|
7
|
+
|
|
8
|
+
let previousConsoleLog;
|
|
9
|
+
const logs = [];
|
|
10
|
+
|
|
11
|
+
if (capturingConsoleLog) {
|
|
12
|
+
previousConsoleLog = console.log; // eslint-disable-line no-console
|
|
13
|
+
|
|
14
|
+
console.log = async (...texts) => await logs.push(texts); // eslint-disable-line no-console
|
|
15
|
+
|
|
16
|
+
} ////
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const parsedDescribe = await parseDescribe(config, describe);
|
|
20
|
+
const describeResult = await runDescribeRun(config, describe, parsedDescribe);
|
|
21
|
+
describeResult.logs = logs;
|
|
22
|
+
|
|
23
|
+
if (capturingConsoleLog) {
|
|
24
|
+
console.log = previousConsoleLog; // eslint-disable-line no-console
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return describeResult;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { timeProfileAsync } from './timeProfier.js';
|
|
2
|
+
import { runTasks } from './runTasks.js';
|
|
3
|
+
import { addExports } from './addExports.js';
|
|
4
|
+
import { debug } from '../../output.js';
|
|
5
|
+
import { runIt } from './runIt.js';
|
|
6
|
+
export async function runDescribeOld(config, describe) {
|
|
7
|
+
return await timeProfileAsync(`run describe ${describe.thing}`, async () => {
|
|
8
|
+
let itCounter = 1;
|
|
9
|
+
const its = []; // create functions to pass back
|
|
10
|
+
// afterDescribe
|
|
11
|
+
|
|
12
|
+
let afterDescribeFunc;
|
|
13
|
+
|
|
14
|
+
async function afterDescribe(func) {
|
|
15
|
+
if (typeof func !== 'function') {
|
|
16
|
+
throw new Error(`afterDescribe() error, argument passed to afterDescribe() must be a function,` + ` received ${typeof func}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
afterDescribeFunc = func;
|
|
20
|
+
} // beforeEachTest
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
let beforeEachTestFunc;
|
|
24
|
+
|
|
25
|
+
async function beforeEachTest(func) {
|
|
26
|
+
if (typeof func !== 'function') {
|
|
27
|
+
throw new Error(`afterDescribe() error, argument passed to afterDescribe() must be a function,` + ` received ${typeof func}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
beforeEachTestFunc = func;
|
|
31
|
+
} // afterEachTest
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
let afterEachTestFunc;
|
|
35
|
+
|
|
36
|
+
async function afterEachTest(func) {
|
|
37
|
+
if (typeof func !== 'function') {
|
|
38
|
+
throw new Error(`afterDescribe() error, argument passed to afterDescribe() must be a function,` + ` received ${typeof func}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
afterEachTestFunc = func;
|
|
42
|
+
} // it
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
async function it(should, test) {
|
|
46
|
+
const thisItCounter = itCounter++;
|
|
47
|
+
await its.push({
|
|
48
|
+
counter: thisItCounter,
|
|
49
|
+
should,
|
|
50
|
+
test //beforeEachTestExports
|
|
51
|
+
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const test = it;
|
|
56
|
+
const describeExports = {};
|
|
57
|
+
await configBeforeEachDescribe(config, describeExports);
|
|
58
|
+
const describeParcel = {
|
|
59
|
+
it,
|
|
60
|
+
test,
|
|
61
|
+
afterDescribe,
|
|
62
|
+
beforeEachTest,
|
|
63
|
+
afterEachTest
|
|
64
|
+
};
|
|
65
|
+
await addExports(describeParcel, describeExports);
|
|
66
|
+
await describe.tests(describeParcel); //console.log('its', its)
|
|
67
|
+
// const beforeEachDescribeExports = (config.beforeEachDescribe)
|
|
68
|
+
// ? runTasks(config, config.beforeEachDescribe)
|
|
69
|
+
// : {}
|
|
70
|
+
//const thisDescribeCounter = describeCounter++ // assign THEN increment
|
|
71
|
+
//let itCounter = 1
|
|
72
|
+
|
|
73
|
+
const itResults = [];
|
|
74
|
+
|
|
75
|
+
for (const it of its) {
|
|
76
|
+
await itResults.push(await runIt(config, it, beforeEachTestFunc, afterEachTestFunc));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const itResultsSummary = {
|
|
80
|
+
total: 0,
|
|
81
|
+
passes: 0
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
for (const itResult of itResults) {
|
|
85
|
+
itResultsSummary.total += +(itResult.success !== null);
|
|
86
|
+
itResultsSummary.passes += +itResult.success;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
await debug('itResultsSummary', itResultsSummary);
|
|
90
|
+
const describeResult = {
|
|
91
|
+
counter: describe.counter,
|
|
92
|
+
thing: describe.thing,
|
|
93
|
+
success: itResultsSummary.total > 0 ? itResultsSummary.passes === itResultsSummary.total : null,
|
|
94
|
+
itResults,
|
|
95
|
+
itResultsSummary
|
|
96
|
+
}; // run after
|
|
97
|
+
|
|
98
|
+
if (typeof afterDescribeFunc === 'function') await afterDescribeFunc();
|
|
99
|
+
await configAfterEachDescribe(config, describeExports);
|
|
100
|
+
return describeResult;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function configBeforeEachDescribe(config, exports) {
|
|
105
|
+
if (config.beforeEachDescribe) {
|
|
106
|
+
const theExports = await runTasks(config.beforeEachDescribe, undefined);
|
|
107
|
+
await addExports(exports, theExports);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function configAfterEachDescribe(config, exports) {
|
|
112
|
+
if (config.afterEachDescribe) {
|
|
113
|
+
await runTasks(config.afterEachDescribe, exports);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
/*
|
|
2
|
+
import { applyConfigDefaults } from './applyConfigDefaults.js'
|
|
3
|
+
import { loadTestFile } from './loadTestFile.js'
|
|
4
|
+
import { runTest } from './runTest.js'
|
|
5
|
+
import { runDescribe } from './runDescribe.old.js'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const defaultConfig = applyConfigDefaults({})
|
|
9
|
+
|
|
10
|
+
const beforeAfterTestFile = 'unitTesting/runTest/beforeAfter.test.js'
|
|
11
|
+
const beforeAfterTest = loadTestFile(defaultConfig, beforeAfterTestFile)
|
|
12
|
+
|
|
13
|
+
mochaDescribe('runDescribeOld() function', function() {
|
|
14
|
+
|
|
15
|
+
mochaIt('should run an it block that was 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
|
+
const sampleDescribe = sampleTest.describes[0]
|
|
22
|
+
//console.log('sample describe', sampleDescribe)
|
|
23
|
+
const describeResult = runDescribe(config, sampleDescribe)
|
|
24
|
+
//console.log('describe result', describeResult)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
//console.log(testResult.describeResults[0].itResults)
|
|
28
|
+
//console.log(testResult.describeResults[0].itResultsSummary)
|
|
29
|
+
|
|
30
|
+
describeResult.should.include.keys([
|
|
31
|
+
'counter',
|
|
32
|
+
'thing',
|
|
33
|
+
'success',
|
|
34
|
+
'itResults',
|
|
35
|
+
'itResultsSummary',
|
|
36
|
+
])
|
|
37
|
+
|
|
38
|
+
describeResult.success.should.equal(true)
|
|
39
|
+
|
|
40
|
+
describeResult.itResultsSummary.total.should.equal(1)
|
|
41
|
+
describeResult.itResultsSummary.passes.should.equal(1)
|
|
42
|
+
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// mochaIt('should return sensible results from a test file without any describes', function() {
|
|
47
|
+
|
|
48
|
+
// //const config = applyConfigDefaults({})
|
|
49
|
+
|
|
50
|
+
// const sampleTestFile = 'unitTesting/sampletests/blank.test.js'
|
|
51
|
+
// const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
|
|
52
|
+
|
|
53
|
+
// const testResult = runTest(defaultConfig, sampleTest)
|
|
54
|
+
|
|
55
|
+
// //console.log(testResult)
|
|
56
|
+
// //console.log(testResult.describeResults[0].itResults)
|
|
57
|
+
// //console.log(testResult.describeResults[0].itResultsSummary)
|
|
58
|
+
|
|
59
|
+
// testResult.should.include.keys([
|
|
60
|
+
// 'file',
|
|
61
|
+
// 'success',
|
|
62
|
+
// 'describeResults',
|
|
63
|
+
// 'describeResultsSummary'
|
|
64
|
+
// ])
|
|
65
|
+
|
|
66
|
+
// chaiExpect(testResult.success).to.be.null
|
|
67
|
+
|
|
68
|
+
// //testResult.describeResultsSummary.total.should.equal(1)
|
|
69
|
+
// //testResult.describeResultsSummary.passes.should.equal(1)
|
|
70
|
+
// //testResult.describeResultsSummary.itsTotal.should.equal(1)
|
|
71
|
+
// //testResult.describeResultsSummary.itsPasses.should.equal(1)
|
|
72
|
+
|
|
73
|
+
// })
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// mochaIt('should return sensible results from a test file with describes without any its/tests', function() {
|
|
77
|
+
|
|
78
|
+
// //const config = applyConfigDefaults({})
|
|
79
|
+
|
|
80
|
+
// const sampleTestFile = 'unitTesting/sampletests/describesWithoutTests.test.js'
|
|
81
|
+
// const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
|
|
82
|
+
|
|
83
|
+
// const testResult = runTest(defaultConfig, sampleTest)
|
|
84
|
+
|
|
85
|
+
// //console.log(testResult)
|
|
86
|
+
// //console.log(testResult.describeResults[0].itResults)
|
|
87
|
+
// //console.log(testResult.describeResults[0].itResultsSummary)
|
|
88
|
+
|
|
89
|
+
// testResult.should.include.keys([
|
|
90
|
+
// 'file',
|
|
91
|
+
// 'success',
|
|
92
|
+
// 'describeResults',
|
|
93
|
+
// 'describeResultsSummary'
|
|
94
|
+
// ])
|
|
95
|
+
|
|
96
|
+
// chaiExpect(testResult.success).to.be.null
|
|
97
|
+
|
|
98
|
+
// testResult.describeResultsSummary.total.should.equal(0)
|
|
99
|
+
// testResult.describeResultsSummary.passes.should.equal(0)
|
|
100
|
+
// testResult.describeResultsSummary.invalid.should.equal(2)
|
|
101
|
+
// testResult.describeResultsSummary.itsTotal.should.equal(0)
|
|
102
|
+
// testResult.describeResultsSummary.itsPasses.should.equal(0)
|
|
103
|
+
|
|
104
|
+
// })
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
// mochaIt("should run beforeEachFile tasks (before - can't test)", function() {
|
|
109
|
+
|
|
110
|
+
// let functionHasRun = false
|
|
111
|
+
// global.beforeEachFileFileHasRun = false
|
|
112
|
+
|
|
113
|
+
// const ourConfig = {
|
|
114
|
+
// beforeEachFile: [
|
|
115
|
+
// function() {
|
|
116
|
+
// functionHasRun = true
|
|
117
|
+
// },
|
|
118
|
+
// 'unitTesting/runTest/beforeEachFile.js'
|
|
119
|
+
// ]
|
|
120
|
+
// }
|
|
121
|
+
|
|
122
|
+
// const config = applyConfigDefaults(ourConfig)
|
|
123
|
+
|
|
124
|
+
// runTest(config, beforeAfterTest)
|
|
125
|
+
|
|
126
|
+
// functionHasRun.should.equal(true)
|
|
127
|
+
// global.beforeEachFileFileHasRun.should.equal(true)
|
|
128
|
+
|
|
129
|
+
// })
|
|
130
|
+
|
|
131
|
+
// mochaIt("should run afterEachFile tasks (after - can't test)", function() {
|
|
132
|
+
|
|
133
|
+
// let functionHasRun = false
|
|
134
|
+
// global.afterEachFileFileHasRun = false
|
|
135
|
+
|
|
136
|
+
// const ourConfig = {
|
|
137
|
+
// afterEachFile: [
|
|
138
|
+
// function() {
|
|
139
|
+
// functionHasRun = true
|
|
140
|
+
// },
|
|
141
|
+
// 'unitTesting/runTest/afterEachFile.js'
|
|
142
|
+
// ]
|
|
143
|
+
// }
|
|
144
|
+
|
|
145
|
+
// const config = applyConfigDefaults(ourConfig)
|
|
146
|
+
|
|
147
|
+
// runTest(config, beforeAfterTest)
|
|
148
|
+
|
|
149
|
+
// functionHasRun.should.equal(true)
|
|
150
|
+
// global.afterEachFileFileHasRun.should.equal(true)
|
|
151
|
+
|
|
152
|
+
// })
|
|
153
|
+
|
|
154
|
+
// mochaIt("should run beforeEachDescribe tasks (before - can't test) each describe block", function() {
|
|
155
|
+
|
|
156
|
+
// let functionHasRunTimes = 0
|
|
157
|
+
// global.beforeEachDescribeFileHasRun = false
|
|
158
|
+
|
|
159
|
+
// const ourConfig = {
|
|
160
|
+
// beforeEachDescribe: [
|
|
161
|
+
// function() {
|
|
162
|
+
// functionHasRunTimes++
|
|
163
|
+
// },
|
|
164
|
+
// 'unitTesting/runTest/beforeEachDescribe.js'
|
|
165
|
+
// ]
|
|
166
|
+
// }
|
|
167
|
+
|
|
168
|
+
// const config = applyConfigDefaults(ourConfig)
|
|
169
|
+
|
|
170
|
+
// runTest(config, beforeAfterTest)
|
|
171
|
+
|
|
172
|
+
// functionHasRunTimes.should.equal(2)
|
|
173
|
+
// global.beforeEachDescribeFileHasRun.should.equal(true)
|
|
174
|
+
|
|
175
|
+
// })
|
|
176
|
+
|
|
177
|
+
// mochaIt("should run afterEachDescribe tasks (after - can't test) each describe block", function() {
|
|
178
|
+
|
|
179
|
+
// let functionHasRunTimes = 0
|
|
180
|
+
// global.afterEachDescribeFileHasRun = false
|
|
181
|
+
|
|
182
|
+
// const ourConfig = {
|
|
183
|
+
// afterEachDescribe: [
|
|
184
|
+
// function() {
|
|
185
|
+
// functionHasRunTimes++
|
|
186
|
+
// },
|
|
187
|
+
// 'unitTesting/runTest/afterEachDescribe.js'
|
|
188
|
+
// ]
|
|
189
|
+
// }
|
|
190
|
+
|
|
191
|
+
// const config = applyConfigDefaults(ourConfig)
|
|
192
|
+
|
|
193
|
+
// runTest(config, beforeAfterTest)
|
|
194
|
+
|
|
195
|
+
// functionHasRunTimes.should.equal(2)
|
|
196
|
+
// global.afterEachDescribeFileHasRun.should.equal(true)
|
|
197
|
+
|
|
198
|
+
// })
|
|
199
|
+
|
|
200
|
+
// mochaIt("should run beforeEachTest tasks (before - can't test) each test/it block", function() {
|
|
201
|
+
|
|
202
|
+
// let functionHasRunTimes = 0
|
|
203
|
+
// global.beforeEachTestbeforeEachFileFileHasRun = false
|
|
204
|
+
|
|
205
|
+
// const ourConfig = {
|
|
206
|
+
// beforeEachTest: [
|
|
207
|
+
// function() {
|
|
208
|
+
// functionHasRunTimes++
|
|
209
|
+
// },
|
|
210
|
+
// 'unitTesting/runTest/beforeEachTest.js'
|
|
211
|
+
// ]
|
|
212
|
+
// }
|
|
213
|
+
|
|
214
|
+
// const config = applyConfigDefaults(ourConfig)
|
|
215
|
+
|
|
216
|
+
// runTest(config, beforeAfterTest)
|
|
217
|
+
|
|
218
|
+
// functionHasRunTimes.should.equal(3)
|
|
219
|
+
// global.beforeEachTestFileHasRun.should.equal(true)
|
|
220
|
+
|
|
221
|
+
// })
|
|
222
|
+
|
|
223
|
+
// mochaIt("should run afterEachTest tasks (after - can't test) each test/it block", function() {
|
|
224
|
+
|
|
225
|
+
// let functionHasRunTimes = 0
|
|
226
|
+
// global.afterEachTestFileFileHasRun = false
|
|
227
|
+
|
|
228
|
+
// const ourConfig = {
|
|
229
|
+
// afterEachTest: [
|
|
230
|
+
// function() {
|
|
231
|
+
// functionHasRunTimes++
|
|
232
|
+
// },
|
|
233
|
+
// 'unitTesting/runTest/afterEachTest.js'
|
|
234
|
+
// ]
|
|
235
|
+
// }
|
|
236
|
+
|
|
237
|
+
// const config = applyConfigDefaults(ourConfig)
|
|
238
|
+
|
|
239
|
+
// runTest(config, beforeAfterTest)
|
|
240
|
+
|
|
241
|
+
// functionHasRunTimes.should.equal(3)
|
|
242
|
+
// global.afterEachTestFileHasRun.should.equal(true)
|
|
243
|
+
|
|
244
|
+
// })
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
// // exports provision to test file
|
|
248
|
+
|
|
249
|
+
// // current beforeEachFile exports aren't provided
|
|
250
|
+
// // perhaps extend sxy-loader to allow this
|
|
251
|
+
|
|
252
|
+
// mochaIt("should pass exported/returned data from beforeEachDescribe tasks", function() {
|
|
253
|
+
|
|
254
|
+
// const testFile = 'unitTesting/runTest/beforeEachDescribe.test.js'
|
|
255
|
+
// const test = loadTestFile(defaultConfig, testFile)
|
|
256
|
+
|
|
257
|
+
// const ourConfig = {
|
|
258
|
+
// beforeEachDescribe: [
|
|
259
|
+
// function() {
|
|
260
|
+
// return { functionThing : 'foo' }
|
|
261
|
+
// },
|
|
262
|
+
// 'unitTesting/runTest/beforeEachDescribeExport.js'
|
|
263
|
+
// ]
|
|
264
|
+
// }
|
|
265
|
+
|
|
266
|
+
// const config = applyConfigDefaults(ourConfig)
|
|
267
|
+
|
|
268
|
+
// runTest(config, test)
|
|
269
|
+
|
|
270
|
+
// global.functionThing.should.equal('foo')
|
|
271
|
+
// global.fileThing.should.equal('bar')
|
|
272
|
+
|
|
273
|
+
// })
|
|
274
|
+
|
|
275
|
+
// mochaIt("should pass exported/returned data from beforeEachTest tasks", function() {
|
|
276
|
+
|
|
277
|
+
// const testFile = 'unitTesting/runTest/beforeEachTest.test.js'
|
|
278
|
+
// const test = loadTestFile(defaultConfig, testFile)
|
|
279
|
+
|
|
280
|
+
// const ourConfig = {
|
|
281
|
+
// beforeEachTest: [
|
|
282
|
+
// function() {
|
|
283
|
+
// return { functionThing : 'foo' }
|
|
284
|
+
// },
|
|
285
|
+
// 'unitTesting/runTest/beforeEachTestExport.js'
|
|
286
|
+
// ]
|
|
287
|
+
// }
|
|
288
|
+
|
|
289
|
+
// const config = applyConfigDefaults(ourConfig)
|
|
290
|
+
|
|
291
|
+
// runTest(config, test)
|
|
292
|
+
|
|
293
|
+
// global.functionThing.should.equal('foo')
|
|
294
|
+
// global.fileThing.should.equal('bar')
|
|
295
|
+
|
|
296
|
+
// })
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
// // exports pass through
|
|
301
|
+
|
|
302
|
+
// mochaIt("beforeEachFile exports are passed through to afterEachFile", function() {
|
|
303
|
+
|
|
304
|
+
// // don't try to reload test, fails due to module caching
|
|
305
|
+
// //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
|
|
306
|
+
// //const test = loadTestFile(defaultConfig, testFile)
|
|
307
|
+
|
|
308
|
+
// let exports
|
|
309
|
+
|
|
310
|
+
// const ourConfig = {
|
|
311
|
+
// beforeEachFile: [
|
|
312
|
+
// function() {
|
|
313
|
+
// return { functionThing : 'foo' }
|
|
314
|
+
// },
|
|
315
|
+
// 'unitTesting/runTest/beforeEachExport.js'
|
|
316
|
+
// ],
|
|
317
|
+
// afterEachFile: [
|
|
318
|
+
// function(theExports) {
|
|
319
|
+
// theExports.should.have.keys(['functionThing', 'fileThing'])
|
|
320
|
+
// exports = theExports
|
|
321
|
+
// },
|
|
322
|
+
// ]
|
|
323
|
+
// }
|
|
324
|
+
|
|
325
|
+
// const config = applyConfigDefaults(ourConfig)
|
|
326
|
+
|
|
327
|
+
// runTest(config, beforeAfterTest)
|
|
328
|
+
|
|
329
|
+
// exports.functionThing.should.equal('foo')
|
|
330
|
+
// exports.fileThing.should.equal('bar')
|
|
331
|
+
|
|
332
|
+
// })
|
|
333
|
+
|
|
334
|
+
// mochaIt("beforeEachDescribe exports are passed through to afterEachDescribe", function() {
|
|
335
|
+
|
|
336
|
+
// // don't try to reload test, fails due to module caching
|
|
337
|
+
// //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
|
|
338
|
+
// //const test = loadTestFile(defaultConfig, testFile)
|
|
339
|
+
|
|
340
|
+
// let exports
|
|
341
|
+
|
|
342
|
+
// const ourConfig = {
|
|
343
|
+
// beforeEachDescribe: [
|
|
344
|
+
// function() {
|
|
345
|
+
// return { functionThing : 'foo' }
|
|
346
|
+
// },
|
|
347
|
+
// 'unitTesting/runTest/beforeEachExport.js'
|
|
348
|
+
// ],
|
|
349
|
+
// afterEachDescribe: [
|
|
350
|
+
// function(theExports) {
|
|
351
|
+
// exports = theExports
|
|
352
|
+
// },
|
|
353
|
+
// ]
|
|
354
|
+
// }
|
|
355
|
+
|
|
356
|
+
// const config = applyConfigDefaults(ourConfig)
|
|
357
|
+
|
|
358
|
+
// runTest(config, beforeAfterTest)
|
|
359
|
+
|
|
360
|
+
// //console.log('exports', exports)
|
|
361
|
+
|
|
362
|
+
// exports.functionThing.should.equal('foo')
|
|
363
|
+
// exports.fileThing.should.equal('bar')
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
// })
|
|
367
|
+
|
|
368
|
+
// mochaIt("beforeEachTest exports are passed through to afterEachTest", function() {
|
|
369
|
+
|
|
370
|
+
// // don't try to reload test, fails due to module caching
|
|
371
|
+
// //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
|
|
372
|
+
// //const test = loadTestFile(defaultConfig, testFile)
|
|
373
|
+
|
|
374
|
+
// let exports
|
|
375
|
+
|
|
376
|
+
// const ourConfig = {
|
|
377
|
+
// beforeEachTest: [
|
|
378
|
+
// function() {
|
|
379
|
+
// return { functionThing : 'foo' }
|
|
380
|
+
// },
|
|
381
|
+
// 'unitTesting/runTest/beforeEachExport.js'
|
|
382
|
+
// ],
|
|
383
|
+
// afterEachTest: [
|
|
384
|
+
// function(theExports) {
|
|
385
|
+
// exports = theExports
|
|
386
|
+
// },
|
|
387
|
+
// ]
|
|
388
|
+
// }
|
|
389
|
+
|
|
390
|
+
// const config = applyConfigDefaults(ourConfig)
|
|
391
|
+
|
|
392
|
+
// runTest(config, beforeAfterTest)
|
|
393
|
+
|
|
394
|
+
// //console.log('exports', exports)
|
|
395
|
+
|
|
396
|
+
// exports.functionThing.should.equal('foo')
|
|
397
|
+
// exports.fileThing.should.equal('bar')
|
|
398
|
+
|
|
399
|
+
// })
|
|
400
|
+
|
|
401
|
+
// mochaIt("we can run code beforeEachTest and afterEachTest from within the test file", function() {
|
|
402
|
+
|
|
403
|
+
// // don't try to reload test, fails due to module caching
|
|
404
|
+
// const testFile = 'unitTesting/runTest/internalBeforeAfterEachTest.test.js'
|
|
405
|
+
// const test = loadTestFile(defaultConfig, testFile)
|
|
406
|
+
|
|
407
|
+
// const config = applyConfigDefaults({})
|
|
408
|
+
|
|
409
|
+
// global.internalBeforeEachTestRanNTimes = 0
|
|
410
|
+
// global.internalAfterEachTestRanNTimes = 0
|
|
411
|
+
// runTest(config, test)
|
|
412
|
+
|
|
413
|
+
// global.internalBeforeAfterEachTest_test1Valid.should.equal(true)
|
|
414
|
+
// global.internalBeforeAfterEachTest_test2Valid.should.equal(true)
|
|
415
|
+
// global.internalBeforeAfterEachTest_test3Valid.should.equal(true)
|
|
416
|
+
// global.internalBeforeEachTestRanNTimes.should.equal(3)
|
|
417
|
+
// global.internalAfterEachTestRanNTimes.should.equal(3)
|
|
418
|
+
|
|
419
|
+
// })
|
|
420
|
+
|
|
421
|
+
// mochaIt("we can run code afterDescribe from within descibe in the test file", function() {
|
|
422
|
+
|
|
423
|
+
// // don't try to reload test, fails due to module caching
|
|
424
|
+
// const testFile = 'unitTesting/runTest/internalAfterDescribeTest.test.js'
|
|
425
|
+
// const test = loadTestFile(defaultConfig, testFile)
|
|
426
|
+
|
|
427
|
+
// const config = applyConfigDefaults({})
|
|
428
|
+
|
|
429
|
+
// global.internalAfterDescribeRanNTimes = 0
|
|
430
|
+
// runTest(config, test)
|
|
431
|
+
|
|
432
|
+
// //global.internalAfterDescribe_test1Valid.should.equal(true)
|
|
433
|
+
// //global.internalAfterDescribe_test2Valid.should.equal(true)
|
|
434
|
+
// global.internalAfterDescribeRanNTimes.should.equal(2)
|
|
435
|
+
|
|
436
|
+
// })
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
})
|
|
440
|
+
*/
|