sxy-test-runner 1.0.0
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 +33 -0
- 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/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/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/parseItsFromDescribe.js +115 -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 copy.js +115 -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/runDescribeParseIts.js +87 -0
- package/dist/cli/lib/runDescribeParseIts.unitTest.js +0 -0
- package/dist/cli/lib/runDescribeRun.js +59 -0
- package/dist/cli/lib/runDescribeRun.unitTest.js +293 -0
- package/dist/cli/lib/runDescribeRunIts.js +56 -0
- package/dist/cli/lib/runDescribeRunIts.unitTest.js +0 -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/runTests.js +137 -0
- package/dist/cli/lib/runTests.unitTest.js +59 -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.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/testing/example.test.js +26 -0
- package/dist/testing/example2.test.js +19 -0
- package/dist/testing/example3.test.js +16 -0
- package/dist/testing/importTimeTarget.js +9 -0
- package/dist/testing/importTimeTarget2.js +11 -0
- package/dist/testing/importTimeTest.js +8 -0
- package/dist/testsState.js +4 -0
- package/dist/timeProfiling.js +9 -0
- package/package.json +68 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import chalk from 'chalk-extensions';
|
|
2
|
+
import { out, log, debug } from './output.js';
|
|
3
|
+
import { showTimeProfiling } from './config.js';
|
|
4
|
+
import { createTimeProfiler } from 'sxy-dev-tools'; //console.log('sxyDevTools', sxyDevTools)
|
|
5
|
+
//console.log('createTimeProfiler', createTimeProfiler)
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
timeProfile,
|
|
9
|
+
timeProfileAsync
|
|
10
|
+
} = await createTimeProfiler(showTimeProfiling); //console.log('chalk', chalk)
|
|
11
|
+
|
|
12
|
+
import { runTasks } from './cli/lib/runTasks.js';
|
|
13
|
+
export async function describe(theThing, tests) {
|
|
14
|
+
const config = global.__sxy_test_runner__.config; // if config.beforeEachDescribe
|
|
15
|
+
// const beforeEachDescribeExports = runTasks(config, config.beforeEachDescribe)
|
|
16
|
+
|
|
17
|
+
const thisDescribeCounter = global.testState.describeCounter++; // ++: assign the value, THEN increment
|
|
18
|
+
|
|
19
|
+
let itCounter = 1;
|
|
20
|
+
const its = []; // create functions to pass back
|
|
21
|
+
// it
|
|
22
|
+
|
|
23
|
+
async function it(should, test) {
|
|
24
|
+
// if config.beforeEachTest
|
|
25
|
+
// const beforeEachTestExports = runTasks(config, config.beforeEachTest)
|
|
26
|
+
const thisItCounter = itCounter++;
|
|
27
|
+
await its.push({
|
|
28
|
+
counter: thisItCounter,
|
|
29
|
+
should,
|
|
30
|
+
test //beforeEachTestExports
|
|
31
|
+
|
|
32
|
+
}); // if config.afterEachTest
|
|
33
|
+
// runTasks(config, config.afterEachTest)
|
|
34
|
+
} // before
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
let beforeFunc;
|
|
38
|
+
|
|
39
|
+
async function before(func) {
|
|
40
|
+
beforeFunc = func;
|
|
41
|
+
} // after
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
let afterFunc;
|
|
45
|
+
|
|
46
|
+
async function after(func) {
|
|
47
|
+
afterFunc = func;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const provides = {
|
|
51
|
+
it,
|
|
52
|
+
before,
|
|
53
|
+
after
|
|
54
|
+
}; // addExports(provides, beforeEachDescribeExports)
|
|
55
|
+
// run the callback, to set the its
|
|
56
|
+
|
|
57
|
+
await tests({
|
|
58
|
+
it,
|
|
59
|
+
before,
|
|
60
|
+
after
|
|
61
|
+
}); //tests(provides)
|
|
62
|
+
|
|
63
|
+
const describe = {
|
|
64
|
+
counter: thisDescribeCounter,
|
|
65
|
+
thing: theThing,
|
|
66
|
+
its //beforeEachDescribeExports
|
|
67
|
+
|
|
68
|
+
};
|
|
69
|
+
await global.testState.describes.push(describe); // if config.afterEachDescribe
|
|
70
|
+
// runTasks(config, config.afterEachDescribe)
|
|
71
|
+
|
|
72
|
+
await debug(chalk.lightgrey`${thisDescribeCounter})` + chalk.lightgrey` Done with ` + chalk.brightblue`${theThing}\n`);
|
|
73
|
+
}
|
|
74
|
+
/*
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
export async function describe(theThing, tests, testFilename) {
|
|
78
|
+
|
|
79
|
+
const timeProfiling = {}
|
|
80
|
+
timeProfiling.beforeDescribe = (new Date).getTime()
|
|
81
|
+
|
|
82
|
+
//log('tests state 1', testsState)
|
|
83
|
+
|
|
84
|
+
const thisDescribeCounter = testsState.describeCounter++ // ++: assign the value, THEN increment
|
|
85
|
+
|
|
86
|
+
//log('tests state 1.5', testsState)
|
|
87
|
+
|
|
88
|
+
let testCounter = 1
|
|
89
|
+
let testResults = []
|
|
90
|
+
|
|
91
|
+
const its = []
|
|
92
|
+
async function it(should, test) {
|
|
93
|
+
its.push([should, test])
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
// async function it(should, test) {
|
|
98
|
+
|
|
99
|
+
// const timeProfiling = {}
|
|
100
|
+
// timeProfiling.beforeIt = (new Date).getTime()
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
// const thisTestCounter = testCounter++ // ++: assign the value, THEN increment
|
|
104
|
+
// let success = null
|
|
105
|
+
// let error
|
|
106
|
+
// try {
|
|
107
|
+
// await test()
|
|
108
|
+
// if (success === null) success = true
|
|
109
|
+
// } catch (e) {
|
|
110
|
+
// success = false
|
|
111
|
+
// //console.log(e)
|
|
112
|
+
// error = e
|
|
113
|
+
// }
|
|
114
|
+
|
|
115
|
+
// const testResult = {
|
|
116
|
+
// counter: thisTestCounter,
|
|
117
|
+
// should,
|
|
118
|
+
// success,
|
|
119
|
+
// error
|
|
120
|
+
// }
|
|
121
|
+
|
|
122
|
+
// testResults.push(testResult)
|
|
123
|
+
// testsState.testResults.push(testResult)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
// timeProfiling.afterIt = (new Date).getTime()
|
|
127
|
+
// timeProfilingOut(`it ${should}`, timeProfiling.beforeIt, timeProfiling.afterIt)
|
|
128
|
+
|
|
129
|
+
// }
|
|
130
|
+
|
|
131
|
+
let beforeFunc
|
|
132
|
+
async function before(func) {
|
|
133
|
+
beforeFunc = func
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let afterFunc
|
|
137
|
+
async function after(func) {
|
|
138
|
+
afterFunc = func
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
tests({it, before, after})
|
|
142
|
+
|
|
143
|
+
//log('tests state2', testsState)
|
|
144
|
+
|
|
145
|
+
testsState.theseDescribes.push({theThing, its, counter: thisDescribeCounter})
|
|
146
|
+
|
|
147
|
+
await run('do the tests', async () => {
|
|
148
|
+
for (const it of its) {
|
|
149
|
+
await testIt(...it)
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
async function testIt(should, test) {
|
|
154
|
+
|
|
155
|
+
await timeProfileAsync(`it ${should}`, async () => {
|
|
156
|
+
|
|
157
|
+
const timeStart = (new Date).getTime()
|
|
158
|
+
|
|
159
|
+
const thisTestCounter = testCounter++ // ++: assign the value, THEN increment
|
|
160
|
+
let success = null
|
|
161
|
+
let error
|
|
162
|
+
try {
|
|
163
|
+
await test()
|
|
164
|
+
if (success === null) success = true
|
|
165
|
+
} catch (e) {
|
|
166
|
+
success = false
|
|
167
|
+
error = e
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const timeEnd = (new Date).getTime()
|
|
171
|
+
const time = timeEnd - timeStart
|
|
172
|
+
|
|
173
|
+
const testResult = {
|
|
174
|
+
counter: thisTestCounter,
|
|
175
|
+
should,
|
|
176
|
+
success,
|
|
177
|
+
time,
|
|
178
|
+
error
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
testResults.push(testResult)
|
|
182
|
+
testsState.testResults.push(testResult)
|
|
183
|
+
|
|
184
|
+
// out(`${time.localeString()}ms`)
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
//console.log('testResults A', testResults)
|
|
190
|
+
testResults = testResults.sort( (a, b) => a.counter - b.counter )
|
|
191
|
+
//console.log('testResults B', testResults)
|
|
192
|
+
|
|
193
|
+
out(
|
|
194
|
+
chalk.lightgrey`${thisDescribeCounter})`
|
|
195
|
+
+ chalk.lightgrey` Describing` + chalk.brightblue` ${theThing}\n`
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
let describeSuccess = null
|
|
199
|
+
const describeErrors = []
|
|
200
|
+
|
|
201
|
+
for (const testResult of testResults) {
|
|
202
|
+
const indexLetters = indexNumberToLetters(testResult.counter)
|
|
203
|
+
if (testResult.success) {
|
|
204
|
+
if (describeSuccess === null) describeSuccess = true
|
|
205
|
+
out(
|
|
206
|
+
chalk.lightgrey` ${indexLetters})`
|
|
207
|
+
+ chalk.mediumgreen(` ${figures.tick} ${testResult.should}`)
|
|
208
|
+
)
|
|
209
|
+
} else {
|
|
210
|
+
describeSuccess = false
|
|
211
|
+
describeErrors.push(testResult.error)
|
|
212
|
+
out(
|
|
213
|
+
chalk.lightgrey` ${indexLetters})`
|
|
214
|
+
+ chalk.mediumred` ${figures.cross} ${testResult.should}\n`
|
|
215
|
+
+ chalk.mediumred` ${testResult.error}`
|
|
216
|
+
)
|
|
217
|
+
// out(
|
|
218
|
+
// chalk.lightgrey` ${indexLetters})`
|
|
219
|
+
// + chalk.brightred` ${figures.cross} ${testResult.should}\n`
|
|
220
|
+
// + chalk.brightred` ${testResult.errors}`
|
|
221
|
+
// )
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const describeResult = {
|
|
226
|
+
counter: thisDescribeCounter,
|
|
227
|
+
theThing,
|
|
228
|
+
success: describeSuccess,
|
|
229
|
+
errors: describeErrors
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
testsState.describeResults.push(describeResult)
|
|
233
|
+
|
|
234
|
+
out(``)
|
|
235
|
+
|
|
236
|
+
timeProfiling.afterDescribe = (new Date).getTime()
|
|
237
|
+
timeProfilingOut(`describe ${theThing}`, timeProfiling.beforeDescribe, timeProfiling.afterDescribe)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
global.endTest[testFilename] = (new Date).getTime()
|
|
241
|
+
timeProfilingOutSpecial(`full test ${testFilename}`, global.startTest[testFilename], global.endTest[testFilename])
|
|
242
|
+
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// export async function it(should, test) {
|
|
246
|
+
// out(chalk`theThing`)
|
|
247
|
+
// await test()
|
|
248
|
+
// }
|
|
249
|
+
|
|
250
|
+
//export const test = it
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
function run(name, func) {
|
|
254
|
+
return func()
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
*/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe } from './describe-old.js';
|
|
2
|
+
await mochaDescribe('watch command', async function () {// mochaIt('should run tests and output results', async function() {
|
|
3
|
+
// this.timeout(6000)
|
|
4
|
+
// const originalConsoleLog = console.log
|
|
5
|
+
// let consoleLogBuffer = ''
|
|
6
|
+
// console.log = sync(function testLog(...texts) {
|
|
7
|
+
// consoleLogBuffer += texts.join(' ') + '\n'
|
|
8
|
+
// })
|
|
9
|
+
// global.commandLineArguments = []
|
|
10
|
+
// promise( watch() )
|
|
11
|
+
// await new Promise( (resolve, reject) => { setTimeout(resolve, 3000) } )
|
|
12
|
+
// console.log = originalConsoleLog
|
|
13
|
+
// const testFileName = `dist/testing/example.test.js`
|
|
14
|
+
// const thing = 'The example'
|
|
15
|
+
// const should = '1 should equal 1'
|
|
16
|
+
// consoleLogBuffer.should.include( testFileName )
|
|
17
|
+
// consoleLogBuffer.should.include( thing )
|
|
18
|
+
// consoleLogBuffer.should.include( should )
|
|
19
|
+
// consoleLogBuffer.should.include( figures.tick )
|
|
20
|
+
// })
|
|
21
|
+
});
|
package/dist/describe.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import chalk from 'chalk-extensions';
|
|
2
|
+
import { out, log, debug } from './output.js';
|
|
3
|
+
import { showTimeProfiling } from './config.js';
|
|
4
|
+
import { createTimeProfiler } from 'sxy-dev-tools'; //console.log('sxyDevTools', sxyDevTools)
|
|
5
|
+
//console.log('createTimeProfiler', createTimeProfiler)
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
timeProfile,
|
|
9
|
+
timeProfileAsync
|
|
10
|
+
} = await createTimeProfiler(showTimeProfiling); //console.log('chalk', chalk)
|
|
11
|
+
|
|
12
|
+
export async function describe(theThing, tests) {
|
|
13
|
+
//const thisDescribeCounter = global.testState.describeCounter++ // ++: assign the value, THEN increment
|
|
14
|
+
const thisDescribeCounter = global.__sxy_test_runner__.describeCounter;
|
|
15
|
+
global.__sxy_test_runner__.describeCounter++;
|
|
16
|
+
const describe = {
|
|
17
|
+
counter: thisDescribeCounter,
|
|
18
|
+
thing: theThing,
|
|
19
|
+
tests
|
|
20
|
+
}; //global.testState.describes.push( describe )
|
|
21
|
+
|
|
22
|
+
await global.__sxy_test_runner__.describes.push(describe);
|
|
23
|
+
await debug(chalk.lightgrey`${thisDescribeCounter})` + chalk.lightgrey` Done with ` + chalk.brightblue`${theThing}\n`);
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { describe } from './describe.js'; //import { createLoad } from 'sxy-loader'
|
|
3
|
+
//const load = createLoad(import.meta.url)
|
|
4
|
+
|
|
5
|
+
await mochaDescribe('new describe() function', async function () {
|
|
6
|
+
await mochaIt('should run tests and output results', async function () {
|
|
7
|
+
await this.timeout(6000); // eslint-disable-next-line camelcase
|
|
8
|
+
|
|
9
|
+
global.__sxy_test_runner__ = {
|
|
10
|
+
describes: [],
|
|
11
|
+
describeCounter: 1
|
|
12
|
+
};
|
|
13
|
+
await describe('a thing', async ({
|
|
14
|
+
it
|
|
15
|
+
}) => {
|
|
16
|
+
await it('should be great', async () => {
|
|
17
|
+
(await expect('it')).to.be.great;
|
|
18
|
+
});
|
|
19
|
+
await it('should be awesome', async () => {
|
|
20
|
+
(await expect('it')).to.be.awesome;
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
await global.__sxy_test_runner__.describes.length.should.equal(1);
|
|
24
|
+
await global.__sxy_test_runner__.describes[0].thing.should.equal('a thing');
|
|
25
|
+
await global.__sxy_test_runner__.describes[0].tests.should.be.a('function');
|
|
26
|
+
});
|
|
27
|
+
});
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { describe } from './describe.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const indexNumberToLetters = function indexNumberToLetters(number, uppercase = false) {
|
|
2
|
+
const charCodeStart = uppercase ? 65 : 97;
|
|
3
|
+
var text = '',
|
|
4
|
+
letterIndex;
|
|
5
|
+
|
|
6
|
+
while (number > 0) {
|
|
7
|
+
letterIndex = (number - 1) % 26;
|
|
8
|
+
text = String.fromCharCode(charCodeStart + letterIndex) + text;
|
|
9
|
+
number = (number - letterIndex) / 26 | 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return text || undefined;
|
|
13
|
+
};
|
package/dist/load.js
ADDED
package/dist/output.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { debugging } from './config.js';
|
|
3
|
+
export async function out(...texts) {
|
|
4
|
+
await console.log(...texts);
|
|
5
|
+
}
|
|
6
|
+
export async function warn(...texts) {
|
|
7
|
+
await console.log(...texts);
|
|
8
|
+
}
|
|
9
|
+
export async function error(...texts) {
|
|
10
|
+
await console.log(...texts);
|
|
11
|
+
}
|
|
12
|
+
export async function log(...texts) {
|
|
13
|
+
await console.log(...texts);
|
|
14
|
+
}
|
|
15
|
+
export const debug = debugging ? async function debug(...texts) {
|
|
16
|
+
await console.log(...texts);
|
|
17
|
+
} : async function () {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe } from '../index.js';
|
|
2
|
+
import { expect, should } from 'chai'; //console.log('chai', chai)
|
|
3
|
+
//console.log('expect', expect)
|
|
4
|
+
//console.log('should', should)
|
|
5
|
+
|
|
6
|
+
await should();
|
|
7
|
+
await describe('The example', async ({
|
|
8
|
+
it
|
|
9
|
+
}) => {
|
|
10
|
+
await it('1 should equal 1', async () => {
|
|
11
|
+
await (await expect(1)).to.equal(1);
|
|
12
|
+
});
|
|
13
|
+
await it('2 should equal 2', async () => {
|
|
14
|
+
await (await expect(2)).to.equal(2);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
await describe('The example 2nd thing', async ({
|
|
18
|
+
it
|
|
19
|
+
}) => {
|
|
20
|
+
await it('1 should equal 1', async () => {
|
|
21
|
+
await (await expect(1)).to.equal(1);
|
|
22
|
+
});
|
|
23
|
+
await it('2 should equal 2', async () => {
|
|
24
|
+
await (await expect(2)).to.equal(2);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe } from '../index.js';
|
|
2
|
+
import { expect, should } from 'chai';
|
|
3
|
+
await should();
|
|
4
|
+
await describe('Example 2', async ({
|
|
5
|
+
it
|
|
6
|
+
}) => {
|
|
7
|
+
await it('3 should equal 3', async () => {
|
|
8
|
+
await (await expect(3)).to.equal(3);
|
|
9
|
+
});
|
|
10
|
+
await it('4 should equal 4', async () => {
|
|
11
|
+
await (await expect(4)).to.equal(4);
|
|
12
|
+
});
|
|
13
|
+
await it('5 should equal 5', async () => {
|
|
14
|
+
await (await expect(5)).to.equal(5);
|
|
15
|
+
});
|
|
16
|
+
await it('6 should equal 6', async () => {
|
|
17
|
+
await (await expect(5)).to.equal(5);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { describe } from '../index.js';
|
|
2
|
+
import { expect, should } from 'chai';
|
|
3
|
+
await should();
|
|
4
|
+
await describe('Example 2', async ({
|
|
5
|
+
it
|
|
6
|
+
}) => {
|
|
7
|
+
await it('3 should equal 3', async () => {
|
|
8
|
+
await (await expect(3)).to.equal(3);
|
|
9
|
+
});
|
|
10
|
+
await it('4 should equal 4', async () => {
|
|
11
|
+
await (await expect(4)).to.equal(4);
|
|
12
|
+
});
|
|
13
|
+
await it('6 should equal 6', async () => {
|
|
14
|
+
await (await expect(6)).to.equal(6);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { describe } from '../index.js';
|
|
2
|
+
import { expect, should } from 'chai';
|
|
3
|
+
import { timeProfilingOut } from '../timeProfiling.js'; // function timeProfilingOut(name, start, finish) {
|
|
4
|
+
// //out(chalk.yellow(`[${packageName}] {${name}} time ${finish-start}ms`))
|
|
5
|
+
// console.log((`[import time test] time ${finish-start}ms`))
|
|
6
|
+
// }
|
|
7
|
+
//globalTimeProfiling.end = (new Date).getTime()
|
|
8
|
+
|
|
9
|
+
await console.log('loaded');
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe } from './index.js';
|
|
2
|
+
import { expect, should } from 'chai';
|
|
3
|
+
import { timeProfilingOut } from './timeProfiling.js'; // function timeProfilingOut(name, start, finish) {
|
|
4
|
+
// //out(chalk.yellow(`[${packageName}] {${name}} time ${finish-start}ms`))
|
|
5
|
+
// console.log((`[import time test] time ${finish-start}ms`))
|
|
6
|
+
// }
|
|
7
|
+
//globalTimeProfiling.end = (new Date).getTime()
|
|
8
|
+
|
|
9
|
+
const timeProfilingEnd = await new Date().getTime(); //timeProfilingOut('', timeStart, timeEnd)
|
|
10
|
+
|
|
11
|
+
await console.log(timeProfilingEnd - timeProfilingStart + 'ms');
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { timeProfilingOut } from './timeProfiling.js'; //const globalTimeProfiling = {}
|
|
2
|
+
//globalTimeProfiling.start = (new Date).getTime()
|
|
3
|
+
|
|
4
|
+
await console.log('-----');
|
|
5
|
+
global.timeProfilingStart = await new Date().getTime();
|
|
6
|
+
await import('./importTimeTarget.js');
|
|
7
|
+
global.timeProfilingStart = await new Date().getTime();
|
|
8
|
+
await import('./importTimeTarget2.js');
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import chalk from 'chalk-extensions';
|
|
2
|
+
import { packageName, cliName, showTimeProfiling } from './config.js';
|
|
3
|
+
import { out } from './output.js';
|
|
4
|
+
export const timeProfilingOut = showTimeProfiling ? async function timeProfilingOut(name, start, finish) {
|
|
5
|
+
await out(await chalk.yellow(`[${packageName}] {${name}} time ${finish - start}ms`));
|
|
6
|
+
} : async function () {};
|
|
7
|
+
export const timeProfilingOutSpecial = showTimeProfiling ? async function timeProfilingOutSpecial(name, start, finish) {
|
|
8
|
+
await out(await chalk.orange(`[${packageName}] {${name}} time ${finish - start}ms`));
|
|
9
|
+
} : async function () {};
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sxy-test-runner",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"sxy-test": "./dist/cli/index.js",
|
|
10
|
+
"sxy-test-runner": "./dist/cli/index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"./dist"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "babel --watch --out-dir dist src",
|
|
17
|
+
"dev": "cross-env NODE_OPTIONS=\"--experimental-specifier-resolution=node\" nodemon --experimental-specifier-resolution=node --watch dist/cli --watch dist/cli/lib --watch sxy-test-runner.config.js --watch sxy-loader.config.js dist/cli/index.js",
|
|
18
|
+
"dev-once": "nodemon --experimental-specifier-resolution=node --watch dist/cli --watch sxy-test-runner.config.js --watch sxy-loader.config.js dist/cli/index.js once",
|
|
19
|
+
"dev-init": "node --experimental-specifier-resolution=node dist/cli/index.js init",
|
|
20
|
+
"unit-test": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/*.unitTest.js",
|
|
21
|
+
"unit-test-show-test-result": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/showTestResult.unitTest.js",
|
|
22
|
+
"unit-test-load-config": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/loadConfig.unitTest.js",
|
|
23
|
+
"unit-test-watch-files": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/watchFiles.unitTest.js",
|
|
24
|
+
"unit-test-watch-files-chokidar": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/watchFilesChokidar.unitTest.js",
|
|
25
|
+
"unit-test-watch-files-and-run-tests": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/watchFilesAndRunTests.unitTest.js",
|
|
26
|
+
"unit-test-watch-files-and-run-tests-chokidar": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/watchFilesAndRunTestsChokidar.unitTest.js",
|
|
27
|
+
"unit-test-watch": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/watch.unitTest.js",
|
|
28
|
+
"unit-test-inject-properties": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/injectProperties.unitTest.js",
|
|
29
|
+
"unit-test-run-it": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/runIt.unitTest.js",
|
|
30
|
+
"unit-test-run-describe": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/runDescribe.unitTest.js",
|
|
31
|
+
"unit-test-parse-describe": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/parseDescribe.unitTest.js",
|
|
32
|
+
"unit-test-run-describe-run": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/runDescribeRun.unitTest.js",
|
|
33
|
+
"unit-test-run-test": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/runTest.unitTest.js",
|
|
34
|
+
"unit-test-load-test-file": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/loadTestFile.unitTest.js",
|
|
35
|
+
"unit-test-add-exports": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/addExports.unitTest.js",
|
|
36
|
+
"unit-test-describe": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/describe.unitTest.js",
|
|
37
|
+
"unit-test-run-tests": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/runTests.unitTest.js",
|
|
38
|
+
"mocha-trial": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/runTest.unitTest.js"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@babel/core": "^7.16.5",
|
|
42
|
+
"chalk-extensions": "^1.0.0",
|
|
43
|
+
"cross-env": "^7.0.3",
|
|
44
|
+
"dependency-tree": "^8.1.2",
|
|
45
|
+
"figures": "^4.0.0",
|
|
46
|
+
"glob": "^7.2.0",
|
|
47
|
+
"globby": "^12.0.2",
|
|
48
|
+
"node-watch": "^0.7.2",
|
|
49
|
+
"sinon-chai": "^3.7.0",
|
|
50
|
+
"slash": "^4.0.0",
|
|
51
|
+
"sxy-dev-tools": "file:../sxy-dev-tools",
|
|
52
|
+
"sxy-loader": "^1.0.0",
|
|
53
|
+
"sxy-standard": "^1.0.0",
|
|
54
|
+
"sxy-standard-object-copy": "^1.0.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@babel/cli": "^7.16.0",
|
|
58
|
+
"babel-plugin-transform-awaitful": "^1.0.0",
|
|
59
|
+
"chai": "^4.3.4",
|
|
60
|
+
"chai-as-promised": "^7.1.1",
|
|
61
|
+
"eslint": "^7.32.0",
|
|
62
|
+
"eslint-config-sandi": "^1.0.5",
|
|
63
|
+
"mocha": "^9.1.3",
|
|
64
|
+
"mocha-steps": "^1.3.0",
|
|
65
|
+
"nodemon": "^2.0.15",
|
|
66
|
+
"sinon": "^12.0.1"
|
|
67
|
+
}
|
|
68
|
+
}
|