sxy-test-runner 1.0.1 → 1.0.3

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 (40) hide show
  1. package/dist/cli/lib/configBeforeAfterFuncs.js +35 -0
  2. package/dist/cli/lib/{runDescribeParseIts.unitTest.js → configBeforeAfterFuncs.unitTest.js} +0 -0
  3. package/dist/cli/lib/loadTestFile.unitTest.js +39 -33
  4. package/dist/cli/lib/overrideConsoleLog.js +20 -0
  5. package/dist/cli/lib/{runDescribeRunIts.unitTest.js → overrideConsoleLog.unitTest.js} +0 -0
  6. package/dist/cli/lib/runDescribe.js +127 -15
  7. package/dist/cli/lib/runDescribe.unitTest.js +2 -282
  8. package/dist/cli/lib/runIt.js +30 -39
  9. package/dist/cli/lib/runIt.unitTest.js +2 -289
  10. package/dist/cli/lib/runTestFile copy.js +292 -0
  11. package/dist/cli/lib/runTestFile-old.js +348 -0
  12. package/dist/cli/lib/runTestFile.js +105 -0
  13. package/dist/cli/lib/{runTest.unitTest.js → runTestFile.unitTest.js} +30 -35
  14. package/dist/cli/lib/{runTests.js → runTestFiles.js} +25 -21
  15. package/dist/cli/lib/runTestFiles.unitTest.js +147 -0
  16. package/dist/cli/lib/shouldCaptureConsoleLog.js +24 -0
  17. package/dist/cli/lib/shouldCaptureConsoleLog.unitTest.js +31 -0
  18. package/dist/cli/once.js +3 -3
  19. package/dist/cli/watch.js +67 -67
  20. package/dist/{exported.eslintrc.js → exported.eslintrc.cjs} +0 -0
  21. package/package.json +3 -3
  22. package/dist/cli/lib/parseDescribe.js +0 -88
  23. package/dist/cli/lib/parseDescribe.unitTest.js +0 -17
  24. package/dist/cli/lib/parseItsFromDescribe.js +0 -115
  25. package/dist/cli/lib/runDescribe.old copy.js +0 -115
  26. package/dist/cli/lib/runDescribe.old.js +0 -115
  27. package/dist/cli/lib/runDescribe.old.unitTest.js +0 -440
  28. package/dist/cli/lib/runDescribeParseIts.js +0 -87
  29. package/dist/cli/lib/runDescribeRun.js +0 -59
  30. package/dist/cli/lib/runDescribeRun.unitTest.js +0 -293
  31. package/dist/cli/lib/runDescribeRunIts.js +0 -56
  32. package/dist/cli/lib/runTest.js +0 -71
  33. package/dist/cli/lib/runTests.unitTest.js +0 -59
  34. package/dist/cli/lib/timeProfier.js +0 -7
  35. package/dist/testing/example.test.js +0 -26
  36. package/dist/testing/example2.test.js +0 -19
  37. package/dist/testing/example3.test.js +0 -16
  38. package/dist/testing/importTimeTarget.js +0 -9
  39. package/dist/testing/importTimeTarget2.js +0 -11
  40. package/dist/testing/importTimeTest.js +0 -8
@@ -0,0 +1,35 @@
1
+ import { runTasks } from './runTasks.js';
2
+ import { addExports } from './addExports.js';
3
+ export async function configBeforeEachFile(config, exports) {
4
+ if (config.beforeEachFile) {
5
+ const theExports = await runTasks(config.beforeEachFile, undefined);
6
+ await addExports(exports, theExports);
7
+ }
8
+ }
9
+ export async function configAfterEachFile(config, exports) {
10
+ if (config.afterEachFile) {
11
+ await runTasks(config.afterEachFile, exports);
12
+ }
13
+ }
14
+ export async function configBeforeEachDescribe(config, exports) {
15
+ if (config.beforeEachDescribe) {
16
+ const theExports = await runTasks(config.beforeEachDescribe, undefined);
17
+ await addExports(exports, theExports);
18
+ }
19
+ }
20
+ export async function configAfterEachDescribe(config, exports) {
21
+ if (config.afterEachDescribe) {
22
+ await runTasks(config.afterEachDescribe, exports);
23
+ }
24
+ }
25
+ export async function configBeforeEachTest(config, exports) {
26
+ if (config.beforeEachTest) {
27
+ const theExports = await runTasks(config.beforeEachTest, undefined);
28
+ await addExports(exports, theExports);
29
+ }
30
+ }
31
+ export async function configAfterEachTest(config, exports) {
32
+ if (config.afterEachTest) {
33
+ await runTasks(config.afterEachTest, exports);
34
+ }
35
+ }
@@ -1,38 +1,24 @@
1
- import { loadTestFile } from "./loadTestFile.js";
2
- import { defaultConfig } from './defaultConfig.js'; // loadTestFile(config, testFile) ???
1
+ import { defaultConfig } from './defaultConfig.js';
2
+ import { applyConfigDefaults } from './applyConfigDefaults.js';
3
+ import { loadTestFile } from './loadTestFile.js'; // loadTestFile(config, testFile) ???
3
4
 
4
5
  await mochaDescribe('loadTestFile() function', async function () {
5
- /*
6
- mochaIt('should load a test file, retreiving describes', function() {
7
-
8
- const config = defaultConfig
9
-
10
- const sampleTestFile = 'unitTesting/sampleTests/1.test.js'
11
-
12
- const test = loadTestFile(config, sampleTestFile)
13
-
14
- test.describes.length.should.equal(1)
15
- test.describes.at(-1).counter.should.equal(1)
16
- test.describes[0].tests.should.be.a('function')
17
- //test.describes.at(-1).its.at(-1).counter.should.equal(1)
18
-
19
- })
20
-
21
- mochaIt('should correctly load a second test file', function() {
22
-
23
- const config = defaultConfig
24
-
25
- const sampleTestFile = 'unitTesting/sampleTests/2.test.js'
26
-
27
- const test = loadTestFile(config, sampleTestFile)
28
-
29
- test.describes.length.should.equal(1)
30
- test.describes.at(-1).counter.should.equal(1)
31
- test.describes[0].tests.should.be.a('function')
32
- //test.describes.at(-1).its.at(-1).counter.should.equal(2)
33
-
34
- })
35
- */
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
+ });
36
22
  await mochaIt('should correctly load a file with describes without any its/tests', async function () {
37
23
  const config = defaultConfig;
38
24
  const sampleTestFile = 'unitTesting/sampleTests/describesWithoutTests.test.js';
@@ -42,4 +28,24 @@ await mochaDescribe('loadTestFile() function', async function () {
42
28
  await (await test.describes.at(-1)).counter.should.equal(2);
43
29
  await test.describes[0].tests.should.be.a('function'); //test.describes.at(-1).its.at(-1).counter.should.equal(2)
44
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
45
51
  });
@@ -0,0 +1,20 @@
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
+ }
@@ -1,29 +1,141 @@
1
- import { timeProfileAsync } from './timeProfier.js';
2
- import { parseDescribe } from './parseDescribe.js';
3
- import { runDescribeRun } from './runDescribeRun.js';
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);
4
13
  export async function runDescribe(config, describe) {
5
14
  return await timeProfileAsync(`run describe ${describe.thing}`, async () => {
6
- const capturingConsoleLog = config.execution.describes === 'sequential'; //// capture console.log output
15
+ // afterDescribe
16
+ let afterDescribeFunc;
7
17
 
8
- let previousConsoleLog;
9
- const logs = [];
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
+ }
10
22
 
11
- if (capturingConsoleLog) {
12
- previousConsoleLog = console.log; // eslint-disable-line no-console
23
+ afterDescribeFunc = func;
24
+ } // beforeEachTest
13
25
 
14
- console.log = async (...texts) => await logs.push(texts); // eslint-disable-line no-console
15
26
 
16
- } ////
27
+ let beforeEachTestFunc;
17
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
+ }
18
33
 
19
- const parsedDescribe = await parseDescribe(config, describe);
20
- const describeResult = await runDescribeRun(config, describe, parsedDescribe);
21
- describeResult.logs = logs;
34
+ beforeEachTestFunc = func;
35
+ } // afterEachTest
22
36
 
23
- if (capturingConsoleLog) {
24
- console.log = previousConsoleLog; // eslint-disable-line no-console
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
25
108
  }
26
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);
27
139
  return describeResult;
28
140
  });
29
141
  }
@@ -1,287 +1,7 @@
1
1
  import { applyConfigDefaults } from './applyConfigDefaults.js';
2
2
  import { loadTestFile } from './loadTestFile.js';
3
3
  import { runDescribe } from './runDescribe.js';
4
- const defaultConfig = await applyConfigDefaults({}); // const beforeAfterTestFile = 'unitTesting/runTest/beforeAfter.test.js'
5
- // const beforeAfterTest = loadTestFile(defaultConfig, beforeAfterTestFile)
6
-
4
+ const defaultConfig = await applyConfigDefaults({});
7
5
  await mochaDescribe('runDescribe() function', async function () {
8
- await mochaIt('should run an it block that was loaded from a test file', async function () {
9
- const sampleTestFile = 'unitTesting/runTest/1.test.js';
10
- const sampleTest = await loadTestFile(defaultConfig, sampleTestFile);
11
- const sampleDescribe = sampleTest.describes[0];
12
- const describeResult = await runDescribe(defaultConfig, sampleDescribe);
13
- await describeResult.should.include.keys(['counter', 'thing', 'success', 'itResults', 'itResultsSummary']);
14
- await describeResult.success.should.equal(true);
15
- await describeResult.itResultsSummary.total.should.equal(1);
16
- await describeResult.itResultsSummary.passes.should.equal(1);
17
- }); // mochaIt('should return sensible results from a test file without any describes', function() {
18
- // //const config = applyConfigDefaults({})
19
- // const sampleTestFile = 'unitTesting/sampletests/blank.test.js'
20
- // const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
21
- // const testResult = runTest(defaultConfig, sampleTest)
22
- // //console.log(testResult)
23
- // //console.log(testResult.describeResults[0].itResults)
24
- // //console.log(testResult.describeResults[0].itResultsSummary)
25
- // testResult.should.include.keys([
26
- // 'file',
27
- // 'success',
28
- // 'describeResults',
29
- // 'describeResultsSummary'
30
- // ])
31
- // chaiExpect(testResult.success).to.be.null
32
- // //testResult.describeResultsSummary.total.should.equal(1)
33
- // //testResult.describeResultsSummary.passes.should.equal(1)
34
- // //testResult.describeResultsSummary.itsTotal.should.equal(1)
35
- // //testResult.describeResultsSummary.itsPasses.should.equal(1)
36
- // })
37
- // mochaIt('should return sensible results from a test file with describes without any its/tests', function() {
38
- // //const config = applyConfigDefaults({})
39
- // const sampleTestFile = 'unitTesting/sampletests/describesWithoutTests.test.js'
40
- // const sampleTest = loadTestFile(defaultConfig, sampleTestFile)
41
- // const testResult = runTest(defaultConfig, sampleTest)
42
- // //console.log(testResult)
43
- // //console.log(testResult.describeResults[0].itResults)
44
- // //console.log(testResult.describeResults[0].itResultsSummary)
45
- // testResult.should.include.keys([
46
- // 'file',
47
- // 'success',
48
- // 'describeResults',
49
- // 'describeResultsSummary'
50
- // ])
51
- // chaiExpect(testResult.success).to.be.null
52
- // testResult.describeResultsSummary.total.should.equal(0)
53
- // testResult.describeResultsSummary.passes.should.equal(0)
54
- // testResult.describeResultsSummary.invalid.should.equal(2)
55
- // testResult.describeResultsSummary.itsTotal.should.equal(0)
56
- // testResult.describeResultsSummary.itsPasses.should.equal(0)
57
- // })
58
- // mochaIt("should run beforeEachFile tasks (before - can't test)", function() {
59
- // let functionHasRun = false
60
- // global.beforeEachFileFileHasRun = false
61
- // const ourConfig = {
62
- // beforeEachFile: [
63
- // function() {
64
- // functionHasRun = true
65
- // },
66
- // 'unitTesting/runTest/beforeEachFile.js'
67
- // ]
68
- // }
69
- // const config = applyConfigDefaults(ourConfig)
70
- // runTest(config, beforeAfterTest)
71
- // functionHasRun.should.equal(true)
72
- // global.beforeEachFileFileHasRun.should.equal(true)
73
- // })
74
- // mochaIt("should run afterEachFile tasks (after - can't test)", function() {
75
- // let functionHasRun = false
76
- // global.afterEachFileFileHasRun = false
77
- // const ourConfig = {
78
- // afterEachFile: [
79
- // function() {
80
- // functionHasRun = true
81
- // },
82
- // 'unitTesting/runTest/afterEachFile.js'
83
- // ]
84
- // }
85
- // const config = applyConfigDefaults(ourConfig)
86
- // runTest(config, beforeAfterTest)
87
- // functionHasRun.should.equal(true)
88
- // global.afterEachFileFileHasRun.should.equal(true)
89
- // })
90
- // mochaIt("should run beforeEachDescribe tasks (before - can't test) each describe block", function() {
91
- // let functionHasRunTimes = 0
92
- // global.beforeEachDescribeFileHasRun = false
93
- // const ourConfig = {
94
- // beforeEachDescribe: [
95
- // function() {
96
- // functionHasRunTimes++
97
- // },
98
- // 'unitTesting/runTest/beforeEachDescribe.js'
99
- // ]
100
- // }
101
- // const config = applyConfigDefaults(ourConfig)
102
- // runTest(config, beforeAfterTest)
103
- // functionHasRunTimes.should.equal(2)
104
- // global.beforeEachDescribeFileHasRun.should.equal(true)
105
- // })
106
- // mochaIt("should run afterEachDescribe tasks (after - can't test) each describe block", function() {
107
- // let functionHasRunTimes = 0
108
- // global.afterEachDescribeFileHasRun = false
109
- // const ourConfig = {
110
- // afterEachDescribe: [
111
- // function() {
112
- // functionHasRunTimes++
113
- // },
114
- // 'unitTesting/runTest/afterEachDescribe.js'
115
- // ]
116
- // }
117
- // const config = applyConfigDefaults(ourConfig)
118
- // runTest(config, beforeAfterTest)
119
- // functionHasRunTimes.should.equal(2)
120
- // global.afterEachDescribeFileHasRun.should.equal(true)
121
- // })
122
- // mochaIt("should run beforeEachTest tasks (before - can't test) each test/it block", function() {
123
- // let functionHasRunTimes = 0
124
- // global.beforeEachTestbeforeEachFileFileHasRun = false
125
- // const ourConfig = {
126
- // beforeEachTest: [
127
- // function() {
128
- // functionHasRunTimes++
129
- // },
130
- // 'unitTesting/runTest/beforeEachTest.js'
131
- // ]
132
- // }
133
- // const config = applyConfigDefaults(ourConfig)
134
- // runTest(config, beforeAfterTest)
135
- // functionHasRunTimes.should.equal(3)
136
- // global.beforeEachTestFileHasRun.should.equal(true)
137
- // })
138
- // mochaIt("should run afterEachTest tasks (after - can't test) each test/it block", function() {
139
- // let functionHasRunTimes = 0
140
- // global.afterEachTestFileFileHasRun = false
141
- // const ourConfig = {
142
- // afterEachTest: [
143
- // function() {
144
- // functionHasRunTimes++
145
- // },
146
- // 'unitTesting/runTest/afterEachTest.js'
147
- // ]
148
- // }
149
- // const config = applyConfigDefaults(ourConfig)
150
- // runTest(config, beforeAfterTest)
151
- // functionHasRunTimes.should.equal(3)
152
- // global.afterEachTestFileHasRun.should.equal(true)
153
- // })
154
- // // exports provision to test file
155
- // // current beforeEachFile exports aren't provided
156
- // // perhaps extend sxy-loader to allow this
157
- // mochaIt("should pass exported/returned data from beforeEachDescribe tasks", function() {
158
- // const testFile = 'unitTesting/runTest/beforeEachDescribe.test.js'
159
- // const test = loadTestFile(defaultConfig, testFile)
160
- // const ourConfig = {
161
- // beforeEachDescribe: [
162
- // function() {
163
- // return { functionThing : 'foo' }
164
- // },
165
- // 'unitTesting/runTest/beforeEachDescribeExport.js'
166
- // ]
167
- // }
168
- // const config = applyConfigDefaults(ourConfig)
169
- // runTest(config, test)
170
- // global.functionThing.should.equal('foo')
171
- // global.fileThing.should.equal('bar')
172
- // })
173
- // mochaIt("should pass exported/returned data from beforeEachTest tasks", function() {
174
- // const testFile = 'unitTesting/runTest/beforeEachTest.test.js'
175
- // const test = loadTestFile(defaultConfig, testFile)
176
- // const ourConfig = {
177
- // beforeEachTest: [
178
- // function() {
179
- // return { functionThing : 'foo' }
180
- // },
181
- // 'unitTesting/runTest/beforeEachTestExport.js'
182
- // ]
183
- // }
184
- // const config = applyConfigDefaults(ourConfig)
185
- // runTest(config, test)
186
- // global.functionThing.should.equal('foo')
187
- // global.fileThing.should.equal('bar')
188
- // })
189
- // // exports pass through
190
- // mochaIt("beforeEachFile exports are passed through to afterEachFile", function() {
191
- // // don't try to reload test, fails due to module caching
192
- // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
193
- // //const test = loadTestFile(defaultConfig, testFile)
194
- // let exports
195
- // const ourConfig = {
196
- // beforeEachFile: [
197
- // function() {
198
- // return { functionThing : 'foo' }
199
- // },
200
- // 'unitTesting/runTest/beforeEachExport.js'
201
- // ],
202
- // afterEachFile: [
203
- // function(theExports) {
204
- // theExports.should.have.keys(['functionThing', 'fileThing'])
205
- // exports = theExports
206
- // },
207
- // ]
208
- // }
209
- // const config = applyConfigDefaults(ourConfig)
210
- // runTest(config, beforeAfterTest)
211
- // exports.functionThing.should.equal('foo')
212
- // exports.fileThing.should.equal('bar')
213
- // })
214
- // mochaIt("beforeEachDescribe exports are passed through to afterEachDescribe", function() {
215
- // // don't try to reload test, fails due to module caching
216
- // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
217
- // //const test = loadTestFile(defaultConfig, testFile)
218
- // let exports
219
- // const ourConfig = {
220
- // beforeEachDescribe: [
221
- // function() {
222
- // return { functionThing : 'foo' }
223
- // },
224
- // 'unitTesting/runTest/beforeEachExport.js'
225
- // ],
226
- // afterEachDescribe: [
227
- // function(theExports) {
228
- // exports = theExports
229
- // },
230
- // ]
231
- // }
232
- // const config = applyConfigDefaults(ourConfig)
233
- // runTest(config, beforeAfterTest)
234
- // //console.log('exports', exports)
235
- // exports.functionThing.should.equal('foo')
236
- // exports.fileThing.should.equal('bar')
237
- // })
238
- // mochaIt("beforeEachTest exports are passed through to afterEachTest", function() {
239
- // // don't try to reload test, fails due to module caching
240
- // //const testFile = 'unitTesting/runTest/beforeAfter.test.js'
241
- // //const test = loadTestFile(defaultConfig, testFile)
242
- // let exports
243
- // const ourConfig = {
244
- // beforeEachTest: [
245
- // function() {
246
- // return { functionThing : 'foo' }
247
- // },
248
- // 'unitTesting/runTest/beforeEachExport.js'
249
- // ],
250
- // afterEachTest: [
251
- // function(theExports) {
252
- // exports = theExports
253
- // },
254
- // ]
255
- // }
256
- // const config = applyConfigDefaults(ourConfig)
257
- // runTest(config, beforeAfterTest)
258
- // //console.log('exports', exports)
259
- // exports.functionThing.should.equal('foo')
260
- // exports.fileThing.should.equal('bar')
261
- // })
262
- // mochaIt("we can run code beforeEachTest and afterEachTest from within the test file", function() {
263
- // // don't try to reload test, fails due to module caching
264
- // const testFile = 'unitTesting/runTest/internalBeforeAfterEachTest.test.js'
265
- // const test = loadTestFile(defaultConfig, testFile)
266
- // const config = applyConfigDefaults({})
267
- // global.internalBeforeEachTestRanNTimes = 0
268
- // global.internalAfterEachTestRanNTimes = 0
269
- // runTest(config, test)
270
- // global.internalBeforeAfterEachTest_test1Valid.should.equal(true)
271
- // global.internalBeforeAfterEachTest_test2Valid.should.equal(true)
272
- // global.internalBeforeAfterEachTest_test3Valid.should.equal(true)
273
- // global.internalBeforeEachTestRanNTimes.should.equal(3)
274
- // global.internalAfterEachTestRanNTimes.should.equal(3)
275
- // })
276
- // mochaIt("we can run code afterDescribe from within descibe in the test file", function() {
277
- // // don't try to reload test, fails due to module caching
278
- // const testFile = 'unitTesting/runTest/internalAfterDescribeTest.test.js'
279
- // const test = loadTestFile(defaultConfig, testFile)
280
- // const config = applyConfigDefaults({})
281
- // global.internalAfterDescribeRanNTimes = 0
282
- // runTest(config, test)
283
- // //global.internalAfterDescribe_test1Valid.should.equal(true)
284
- // //global.internalAfterDescribe_test2Valid.should.equal(true)
285
- // global.internalAfterDescribeRanNTimes.should.equal(2)
286
- // })
6
+ await mochaIt('...', async function () {});
287
7
  });