sxy-test-runner 1.4.3 → 1.4.5
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 +0 -2
- package/dist/cli/lib/applyConfigDefaults.js +1 -1
- package/dist/cli/lib/buildDependencyTree.js +0 -1
- package/dist/cli/lib/loadTestFile.unitTest.js +30 -30
- package/dist/cli/lib/loadTestFileStatic.js +39 -39
- package/dist/cli/lib/loadTestFileStatic.unitTest.js +28 -28
- package/dist/cli/lib/parseDescribe.js +8 -2
- package/dist/cli/lib/runDescribe.js +20 -2
- package/dist/cli/lib/runDescribe.old.unitTest.js +439 -439
- package/dist/cli/lib/runTest-old.js +158 -158
- package/dist/cli/lib/runTest-old.unitTest.js +182 -182
- package/dist/cli/lib/runTests.js +9 -6
- package/dist/cli/lib/showTestLoadingError.js +1 -1
- package/dist/cli/lib/showTestResult.js +13 -1
- package/dist/cli/lib/watchFilesAndRunTests.unitTest.js +1 -1
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js +1 -1
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js +1 -1
- package/dist/cli/once.unitTest.js +38 -38
- package/dist/describe-old.js +183 -183
- package/package.json +6 -3
- package/dist/cli/lib/esmReload.unitTest.js +0 -8
- package/dist/cli/lib/load.js +0 -3
- package/dist/cli/lib/load.unitTest copy.js +0 -7
- package/dist/cli/lib/load.unitTest.js +0 -7
- package/dist/index.d.ts +0 -7
- package/dist/load.js +0 -3
|
@@ -1,160 +1,160 @@
|
|
|
1
1
|
|
|
2
|
-
/*
|
|
3
|
-
import { createTimeProfiler } from 'sxy-dev-tools'
|
|
4
|
-
import chalk from 'chalk-extensions'
|
|
5
|
-
import { out, log, debug } from '../../output.js'
|
|
6
|
-
import { showTimeProfiling } from '../../config.js'
|
|
7
|
-
|
|
8
|
-
import { runTasks } from './runTasks.js'
|
|
9
|
-
|
|
10
|
-
const { timeProfileAsync } = createTimeProfiler(showTimeProfiling)
|
|
11
|
-
|
|
12
|
-
export function runTest(config, test, customOut = undefined) {
|
|
13
|
-
|
|
14
|
-
return timeProfileAsync(`run test ${test.file}`, () => {
|
|
15
|
-
|
|
16
|
-
// run before test
|
|
17
|
-
if (config.beforeEachFile) runTasks(config, config.beforeEachFile)
|
|
18
|
-
|
|
19
|
-
// const beforeEachFileExports = (config.beforeEachFile)
|
|
20
|
-
// ? runTasks(config, config.beforeEachFile)
|
|
21
|
-
// : {}
|
|
22
|
-
|
|
23
|
-
let describeCounter = 1
|
|
24
|
-
const describeRunPromises = []
|
|
25
|
-
|
|
26
|
-
for (const describe of test.describes) {
|
|
27
|
-
|
|
28
|
-
describeRunPromises.push(
|
|
29
|
-
promise( runDescribe(config, describe) )
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const describeResults = Promise.all(describeRunPromises)
|
|
35
|
-
|
|
36
|
-
const describeResultsSummary = {
|
|
37
|
-
total: 0,
|
|
38
|
-
passes: 0,
|
|
39
|
-
itsTotal: 0,
|
|
40
|
-
itsPasses: 0,
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
for ( const describeResult of describeResults ) {
|
|
45
|
-
describeResultsSummary.total += +(describeResult.success !== null)
|
|
46
|
-
describeResultsSummary.passes += +describeResult.success
|
|
47
|
-
describeResultsSummary.itsTotal += describeResult.itResultsSummary.total
|
|
48
|
-
describeResultsSummary.itsPasses += describeResult.itResultsSummary.passes
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const testResults = {
|
|
52
|
-
file: test.file,
|
|
53
|
-
success: (describeResultsSummary.total > 0)
|
|
54
|
-
? describeResultsSummary.total === describeResultsSummary.passes
|
|
55
|
-
: null,
|
|
56
|
-
describeResults,
|
|
57
|
-
describeResultsSummary,
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// run after test
|
|
61
|
-
if (config.afterEachFile) runTasks(config, config.afterEachFile)
|
|
62
|
-
|
|
63
|
-
return testResults
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
function runDescribe(config, describe) {
|
|
67
|
-
|
|
68
|
-
return timeProfileAsync(`run describe ${describe.thing}`, () => {
|
|
69
|
-
|
|
70
|
-
// run before describe
|
|
71
|
-
if (config.beforeEachDescribe) runTasks(config, config.beforeEachDescribe)
|
|
72
|
-
|
|
73
|
-
// const beforeEachDescribeExports = (config.beforeEachDescribe)
|
|
74
|
-
// ? runTasks(config, config.beforeEachDescribe)
|
|
75
|
-
// : {}
|
|
76
|
-
|
|
77
|
-
const thisDescribeCounter = describeCounter++ // assign THEN increment
|
|
78
|
-
let itCounter = 1
|
|
79
|
-
const itResults = []
|
|
80
|
-
|
|
81
|
-
for ( const it of describe.its ) {
|
|
82
|
-
itResults.push( runIt(config, it) )
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const itResultsSummary = {
|
|
86
|
-
total: 0,
|
|
87
|
-
passes: 0,
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
for ( const itResult of itResults ) {
|
|
91
|
-
itResultsSummary.total += +(itResult.success !== null)
|
|
92
|
-
itResultsSummary.passes += +itResult.success
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const describeResult = {
|
|
96
|
-
counter: thisDescribeCounter,
|
|
97
|
-
thing: describe.thing,
|
|
98
|
-
success: (itResultsSummary.total > 0)
|
|
99
|
-
? itResultsSummary.passes === itResultsSummary.total
|
|
100
|
-
: null,
|
|
101
|
-
itResults,
|
|
102
|
-
itResultsSummary
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// run after describe
|
|
106
|
-
if (config.afterEachDescribe) runTasks(config, config.afterEachDescribe)
|
|
107
|
-
|
|
108
|
-
return describeResult
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
function runIt(config, it, exports) {
|
|
112
|
-
|
|
113
|
-
return timeProfileAsync(`run it ${it.should}`, () => {
|
|
114
|
-
|
|
115
|
-
// run before test/it
|
|
116
|
-
if (config.beforeEachTest) runTasks(config, config.beforeEachTest)
|
|
117
|
-
|
|
118
|
-
const thisItCounter = itCounter++ // assign THEN increment
|
|
119
|
-
|
|
120
|
-
//// run the it
|
|
121
|
-
let success = null
|
|
122
|
-
let error
|
|
123
|
-
const startTime = (new Date).getTime()
|
|
124
|
-
try {
|
|
125
|
-
it.test()
|
|
126
|
-
success = true
|
|
127
|
-
} catch (e) {
|
|
128
|
-
success = false
|
|
129
|
-
error = e
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const time = (new Date).getTime() - startTime
|
|
133
|
-
|
|
134
|
-
const itResult = {
|
|
135
|
-
counter: thisItCounter,
|
|
136
|
-
should: it.should,
|
|
137
|
-
success,
|
|
138
|
-
time,
|
|
139
|
-
error
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// run after test/it
|
|
143
|
-
if (config.afterEachTest) runTasks(config, config.afterEachTest)
|
|
144
|
-
|
|
145
|
-
return itResult
|
|
146
|
-
//testResults.push(testResult)
|
|
147
|
-
//testsState.testResults.push(testResult)
|
|
148
|
-
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
}
|
|
2
|
+
/*
|
|
3
|
+
import { createTimeProfiler } from 'sxy-dev-tools'
|
|
4
|
+
import chalk from 'chalk-extensions'
|
|
5
|
+
import { out, log, debug } from '../../output.js'
|
|
6
|
+
import { showTimeProfiling } from '../../config.js'
|
|
7
|
+
|
|
8
|
+
import { runTasks } from './runTasks.js'
|
|
9
|
+
|
|
10
|
+
const { timeProfileAsync } = createTimeProfiler(showTimeProfiling)
|
|
11
|
+
|
|
12
|
+
export function runTest(config, test, customOut = undefined) {
|
|
13
|
+
|
|
14
|
+
return timeProfileAsync(`run test ${test.file}`, () => {
|
|
15
|
+
|
|
16
|
+
// run before test
|
|
17
|
+
if (config.beforeEachFile) runTasks(config, config.beforeEachFile)
|
|
18
|
+
|
|
19
|
+
// const beforeEachFileExports = (config.beforeEachFile)
|
|
20
|
+
// ? runTasks(config, config.beforeEachFile)
|
|
21
|
+
// : {}
|
|
22
|
+
|
|
23
|
+
let describeCounter = 1
|
|
24
|
+
const describeRunPromises = []
|
|
25
|
+
|
|
26
|
+
for (const describe of test.describes) {
|
|
27
|
+
|
|
28
|
+
describeRunPromises.push(
|
|
29
|
+
promise( runDescribe(config, describe) )
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const describeResults = Promise.all(describeRunPromises)
|
|
35
|
+
|
|
36
|
+
const describeResultsSummary = {
|
|
37
|
+
total: 0,
|
|
38
|
+
passes: 0,
|
|
39
|
+
itsTotal: 0,
|
|
40
|
+
itsPasses: 0,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
for ( const describeResult of describeResults ) {
|
|
45
|
+
describeResultsSummary.total += +(describeResult.success !== null)
|
|
46
|
+
describeResultsSummary.passes += +describeResult.success
|
|
47
|
+
describeResultsSummary.itsTotal += describeResult.itResultsSummary.total
|
|
48
|
+
describeResultsSummary.itsPasses += describeResult.itResultsSummary.passes
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const testResults = {
|
|
52
|
+
file: test.file,
|
|
53
|
+
success: (describeResultsSummary.total > 0)
|
|
54
|
+
? describeResultsSummary.total === describeResultsSummary.passes
|
|
55
|
+
: null,
|
|
56
|
+
describeResults,
|
|
57
|
+
describeResultsSummary,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// run after test
|
|
61
|
+
if (config.afterEachFile) runTasks(config, config.afterEachFile)
|
|
62
|
+
|
|
63
|
+
return testResults
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
function runDescribe(config, describe) {
|
|
67
|
+
|
|
68
|
+
return timeProfileAsync(`run describe ${describe.thing}`, () => {
|
|
69
|
+
|
|
70
|
+
// run before describe
|
|
71
|
+
if (config.beforeEachDescribe) runTasks(config, config.beforeEachDescribe)
|
|
72
|
+
|
|
73
|
+
// const beforeEachDescribeExports = (config.beforeEachDescribe)
|
|
74
|
+
// ? runTasks(config, config.beforeEachDescribe)
|
|
75
|
+
// : {}
|
|
76
|
+
|
|
77
|
+
const thisDescribeCounter = describeCounter++ // assign THEN increment
|
|
78
|
+
let itCounter = 1
|
|
79
|
+
const itResults = []
|
|
80
|
+
|
|
81
|
+
for ( const it of describe.its ) {
|
|
82
|
+
itResults.push( runIt(config, it) )
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const itResultsSummary = {
|
|
86
|
+
total: 0,
|
|
87
|
+
passes: 0,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
for ( const itResult of itResults ) {
|
|
91
|
+
itResultsSummary.total += +(itResult.success !== null)
|
|
92
|
+
itResultsSummary.passes += +itResult.success
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const describeResult = {
|
|
96
|
+
counter: thisDescribeCounter,
|
|
97
|
+
thing: describe.thing,
|
|
98
|
+
success: (itResultsSummary.total > 0)
|
|
99
|
+
? itResultsSummary.passes === itResultsSummary.total
|
|
100
|
+
: null,
|
|
101
|
+
itResults,
|
|
102
|
+
itResultsSummary
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// run after describe
|
|
106
|
+
if (config.afterEachDescribe) runTasks(config, config.afterEachDescribe)
|
|
107
|
+
|
|
108
|
+
return describeResult
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
function runIt(config, it, exports) {
|
|
112
|
+
|
|
113
|
+
return timeProfileAsync(`run it ${it.should}`, () => {
|
|
114
|
+
|
|
115
|
+
// run before test/it
|
|
116
|
+
if (config.beforeEachTest) runTasks(config, config.beforeEachTest)
|
|
117
|
+
|
|
118
|
+
const thisItCounter = itCounter++ // assign THEN increment
|
|
119
|
+
|
|
120
|
+
//// run the it
|
|
121
|
+
let success = null
|
|
122
|
+
let error
|
|
123
|
+
const startTime = (new Date).getTime()
|
|
124
|
+
try {
|
|
125
|
+
it.test()
|
|
126
|
+
success = true
|
|
127
|
+
} catch (e) {
|
|
128
|
+
success = false
|
|
129
|
+
error = e
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const time = (new Date).getTime() - startTime
|
|
133
|
+
|
|
134
|
+
const itResult = {
|
|
135
|
+
counter: thisItCounter,
|
|
136
|
+
should: it.should,
|
|
137
|
+
success,
|
|
138
|
+
time,
|
|
139
|
+
error
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// run after test/it
|
|
143
|
+
if (config.afterEachTest) runTasks(config, config.afterEachTest)
|
|
144
|
+
|
|
145
|
+
return itResult
|
|
146
|
+
//testResults.push(testResult)
|
|
147
|
+
//testsState.testResults.push(testResult)
|
|
148
|
+
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
}
|
|
160
160
|
*/
|