@neurodevs/node-tdd 1.0.6 → 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/package.json +1 -1
- package/.nvmrc +0 -1
- package/.vscode/launch.json +0 -53
- package/.vscode/settings.json +0 -62
- package/.vscode/tasks.json +0 -99
- package/build/__tests__/MockFetch.d.ts +0 -18
- package/build/__tests__/MockFetch.js +0 -55
- package/build/__tests__/MockFetch.js.map +0 -1
- package/build/__tests__/behavioral/AbstractModuleTest.test.d.ts +0 -5
- package/build/__tests__/behavioral/AbstractModuleTest.test.js +0 -22
- package/build/__tests__/behavioral/AbstractModuleTest.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.d.ts +0 -5
- package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.js +0 -34
- package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/Assert.test.d.ts +0 -45
- package/build/__tests__/behavioral/utilities/Assert.test.js +0 -645
- package/build/__tests__/behavioral/utilities/Assert.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.d.ts +0 -4
- package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.js +0 -23
- package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/MockFetch.test.d.ts +0 -28
- package/build/__tests__/behavioral/utilities/MockFetch.test.js +0 -211
- package/build/__tests__/behavioral/utilities/MockFetch.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/StackCleaner.test.d.ts +0 -4
- package/build/__tests__/behavioral/utilities/StackCleaner.test.js +0 -46
- package/build/__tests__/behavioral/utilities/StackCleaner.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.d.ts +0 -7
- package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.js +0 -32
- package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.d.ts +0 -4
- package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.js +0 -19
- package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/Stringify.test.d.ts +0 -5
- package/build/__tests__/behavioral/utilities/Stringify.test.js +0 -127
- package/build/__tests__/behavioral/utilities/Stringify.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.d.ts +0 -7
- package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.js +0 -38
- package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/TestOnBasic.test.d.ts +0 -12
- package/build/__tests__/behavioral/utilities/TestOnBasic.test.js +0 -68
- package/build/__tests__/behavioral/utilities/TestOnBasic.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/TestOnInstance.test.d.ts +0 -28
- package/build/__tests__/behavioral/utilities/TestOnInstance.test.js +0 -289
- package/build/__tests__/behavioral/utilities/TestOnInstance.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.d.ts +0 -9
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.js +0 -118
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.d.ts +0 -5
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.js +0 -78
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.d.ts +0 -4
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.js +0 -23
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.d.ts +0 -4
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.js +0 -24
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/TestResolver.test.d.ts +0 -7
- package/build/__tests__/behavioral/utilities/TestResolver.test.js +0 -38
- package/build/__tests__/behavioral/utilities/TestResolver.test.js.map +0 -1
- package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.d.ts +0 -4
- package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.js +0 -20
- package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.js.map +0 -1
- package/build/__tests__/behavioral/workspace/JestJsonParser.test.d.ts +0 -18
- package/build/__tests__/behavioral/workspace/JestJsonParser.test.js +0 -267
- package/build/__tests__/behavioral/workspace/JestJsonParser.test.js.map +0 -1
- package/build/__tests__/behavioral/workspace/TestReporter.test.d.ts +0 -27
- package/build/__tests__/behavioral/workspace/TestReporter.test.js +0 -508
- package/build/__tests__/behavioral/workspace/TestReporter.test.js.map +0 -1
- package/build/__tests__/behavioral/workspace/TestRunner.test.d.ts +0 -15
- package/build/__tests__/behavioral/workspace/TestRunner.test.js +0 -99
- package/build/__tests__/behavioral/workspace/TestRunner.test.js.map +0 -1
- package/build/__tests__/behavioral/workspace/Widgets.test.d.ts +0 -16
- package/build/__tests__/behavioral/workspace/Widgets.test.js +0 -134
- package/build/__tests__/behavioral/workspace/Widgets.test.js.map +0 -1
- package/build/__tests__/mock-terminal-kit.d.ts +0 -79
- package/build/__tests__/mock-terminal-kit.js +0 -103
- package/build/__tests__/mock-terminal-kit.js.map +0 -1
- package/build/__tests__/support/AbstractForInstanceTest.d.ts +0 -4
- package/build/__tests__/support/AbstractForInstanceTest.js +0 -9
- package/build/__tests__/support/AbstractForInstanceTest.js.map +0 -1
- package/build/__tests__/support/AbstractLevelOneTest.d.ts +0 -3
- package/build/__tests__/support/AbstractLevelOneTest.js +0 -4
- package/build/__tests__/support/AbstractLevelOneTest.js.map +0 -1
- package/build/__tests__/support/AbstractLevelTwoTest.d.ts +0 -7
- package/build/__tests__/support/AbstractLevelTwoTest.js +0 -14
- package/build/__tests__/support/AbstractLevelTwoTest.js.map +0 -1
- package/build/__tests__/support/AbstractStaticTest.d.ts +0 -7
- package/build/__tests__/support/AbstractStaticTest.js +0 -14
- package/build/__tests__/support/AbstractStaticTest.js.map +0 -1
- package/build/__tests__/support/AbstractTestOnInstanceTest.d.ts +0 -22
- package/build/__tests__/support/AbstractTestOnInstanceTest.js +0 -23
- package/build/__tests__/support/AbstractTestOnInstanceTest.js.map +0 -1
- package/build/__tests__/support/AbstractTestOnInstanceWithHooks.d.ts +0 -26
- package/build/__tests__/support/AbstractTestOnInstanceWithHooks.js +0 -59
- package/build/__tests__/support/AbstractTestOnInstanceWithHooks.js.map +0 -1
- package/build/__tests__/support/jest.setup.d.ts +0 -1
- package/build/__tests__/support/jest.setup.js +0 -4
- package/build/__tests__/support/jest.setup.js.map +0 -1
- package/build/__tests__/support/onTestFileResult.d.ts +0 -244
- package/build/__tests__/support/onTestFileResult.js +0 -980
- package/build/__tests__/support/onTestFileResult.js.map +0 -1
- package/eslint.config.js +0 -3
- package/prettier.config.js +0 -3
- package/src/.spruce/settings.json +0 -4
- package/src/__tests__/MockFetch.ts +0 -100
- package/src/__tests__/behavioral/AbstractModuleTest.test.ts +0 -15
- package/src/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.ts +0 -31
- package/src/__tests__/behavioral/utilities/Assert.test.ts +0 -826
- package/src/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.ts +0 -14
- package/src/__tests__/behavioral/utilities/MockFetch.test.ts +0 -240
- package/src/__tests__/behavioral/utilities/StackCleaner.test.ts +0 -46
- package/src/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.ts +0 -34
- package/src/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.ts +0 -11
- package/src/__tests__/behavioral/utilities/Stringify.test.ts +0 -169
- package/src/__tests__/behavioral/utilities/TestDecoratorResolver.test.ts +0 -51
- package/src/__tests__/behavioral/utilities/TestOnBasic.test.ts +0 -62
- package/src/__tests__/behavioral/utilities/TestOnInstance.test.ts +0 -439
- package/src/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.ts +0 -237
- package/src/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.ts +0 -85
- package/src/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.ts +0 -14
- package/src/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.ts +0 -16
- package/src/__tests__/behavioral/utilities/TestResolver.test.ts +0 -48
- package/src/__tests__/behavioral/utilities/TestResolverOnStatic.test.ts +0 -12
- package/src/__tests__/behavioral/workspace/JestJsonParser.test.ts +0 -357
- package/src/__tests__/behavioral/workspace/TestReporter.test.ts +0 -584
- package/src/__tests__/behavioral/workspace/TestRunner.test.ts +0 -87
- package/src/__tests__/behavioral/workspace/Widgets.test.ts +0 -131
- package/src/__tests__/mock-terminal-kit.ts +0 -115
- package/src/__tests__/support/AbstractForInstanceTest.ts +0 -12
- package/src/__tests__/support/AbstractLevelOneTest.ts +0 -3
- package/src/__tests__/support/AbstractLevelTwoTest.ts +0 -16
- package/src/__tests__/support/AbstractStaticTest.ts +0 -16
- package/src/__tests__/support/AbstractTestOnInstanceTest.ts +0 -30
- package/src/__tests__/support/AbstractTestOnInstanceWithHooks.ts +0 -138
- package/src/__tests__/support/jest.setup.ts +0 -2
- package/src/__tests__/support/onTestFileResult.ts +0 -1008
- package/src/impl/AbstractModuleTest.ts +0 -67
- package/src/index.ts +0 -12
- package/src/utilities/AssertionError.ts +0 -14
- package/src/utilities/StackCleaner.ts +0 -14
- package/src/utilities/TestDecoratorResolver.ts +0 -118
- package/src/utilities/assert.ts +0 -583
- package/src/utilities/assert.utility.ts +0 -295
- package/src/utilities/decorators.ts +0 -167
- package/src/workspace/CommandService.ts +0 -256
- package/src/workspace/JestJsonParser.ts +0 -255
- package/src/workspace/TKButtonWidget.ts +0 -54
- package/src/workspace/TestLogItemGenerator.ts +0 -184
- package/src/workspace/TestReporter.ts +0 -880
- package/src/workspace/TestRunner.ts +0 -128
- package/src/workspace/TkBaseWidget.ts +0 -249
- package/src/workspace/TkInputWidget.ts +0 -83
- package/src/workspace/TkLayoutCellWidget.ts +0 -46
- package/src/workspace/TkLayoutWidget.ts +0 -181
- package/src/workspace/TkMenuBarWidget.ts +0 -95
- package/src/workspace/TkPopupWidget.ts +0 -47
- package/src/workspace/TkProgressBarWidget.ts +0 -54
- package/src/workspace/TkTextWidget.ts +0 -167
- package/src/workspace/TkWindowWidget.ts +0 -122
- package/src/workspace/WidgetFactory.ts +0 -33
- package/src/workspace/button.types.ts +0 -19
- package/src/workspace/duration.utility.ts +0 -34
- package/src/workspace/factory.types.ts +0 -101
- package/src/workspace/input.types.ts +0 -22
- package/src/workspace/keySelectChoices.ts +0 -134
- package/src/workspace/layout.types.ts +0 -40
- package/src/workspace/menuBar.types.ts +0 -24
- package/src/workspace/popup.types.ts +0 -17
- package/src/workspace/progressBar.types.ts +0 -13
- package/src/workspace/table.types.ts +0 -9
- package/src/workspace/termKit.utility.ts +0 -130
- package/src/workspace/terminal-kit.d.ts +0 -28
- package/src/workspace/test.types.ts +0 -34
- package/src/workspace/testRunner.cli.ts +0 -166
- package/src/workspace/text.types.ts +0 -27
- package/src/workspace/widget.utilities.ts +0 -35
- package/src/workspace/widgets.types.ts +0 -102
- package/src/workspace/window.types.ts +0 -22
- package/tsconfig.json +0 -24
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AssertionResult,
|
|
3
|
-
END_DIVIDER,
|
|
4
|
-
START_DIVIDER,
|
|
5
|
-
retrocycle,
|
|
6
|
-
} from '@sprucelabs/jest-json-reporter'
|
|
7
|
-
import { escapeRegExp } from 'lodash-es'
|
|
8
|
-
import { SpruceTestFile, TestResultStatus, TestResults } from './test.types.js'
|
|
9
|
-
|
|
10
|
-
interface AggregatedResult {
|
|
11
|
-
numTotalTestSuites: number
|
|
12
|
-
numFailedTestSuites: number
|
|
13
|
-
numPassedTestSuites: number
|
|
14
|
-
numFailedTests: number
|
|
15
|
-
numPassedTests: number
|
|
16
|
-
numTotalTests: number
|
|
17
|
-
numPendingTests: number
|
|
18
|
-
numTodoTests: number
|
|
19
|
-
testResults: TestResult[]
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface TestResult {
|
|
23
|
-
testFilePath: string
|
|
24
|
-
failureMessage?: string | null
|
|
25
|
-
numFailingTests: number
|
|
26
|
-
testResults: AssertionResult[]
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface TestInfo {
|
|
30
|
-
path: string
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type JsonParserResult =
|
|
34
|
-
| {
|
|
35
|
-
status: 'onRunStart'
|
|
36
|
-
results: AggregatedResult
|
|
37
|
-
}
|
|
38
|
-
| {
|
|
39
|
-
status: 'onTestCaseResult'
|
|
40
|
-
test: TestInfo
|
|
41
|
-
testCaseResult: AssertionResult
|
|
42
|
-
}
|
|
43
|
-
| {
|
|
44
|
-
status: 'onTestFileStart'
|
|
45
|
-
test: TestInfo
|
|
46
|
-
}
|
|
47
|
-
| {
|
|
48
|
-
status: 'onTestFileResult'
|
|
49
|
-
test: TestInfo
|
|
50
|
-
testResult: TestResult
|
|
51
|
-
aggregatedResult: AggregatedResult
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export default class JestJsonParser {
|
|
55
|
-
private testResults: TestResults = { totalTestFiles: 0 }
|
|
56
|
-
private buffer = ''
|
|
57
|
-
|
|
58
|
-
public write(data: string) {
|
|
59
|
-
let dataToProcess = this.buffer + data
|
|
60
|
-
let endDividerStartIdx = -1
|
|
61
|
-
|
|
62
|
-
do {
|
|
63
|
-
endDividerStartIdx = dataToProcess.search(escapeRegExp(END_DIVIDER))
|
|
64
|
-
if (endDividerStartIdx > -1) {
|
|
65
|
-
let startDividerIdx = Math.max(
|
|
66
|
-
0,
|
|
67
|
-
dataToProcess.search(escapeRegExp(START_DIVIDER))
|
|
68
|
-
)
|
|
69
|
-
const endDividerEndIdx = endDividerStartIdx + END_DIVIDER.length
|
|
70
|
-
if (startDividerIdx > endDividerStartIdx) {
|
|
71
|
-
startDividerIdx = -1
|
|
72
|
-
}
|
|
73
|
-
const firstSegment = dataToProcess.substr(
|
|
74
|
-
startDividerIdx,
|
|
75
|
-
endDividerEndIdx - startDividerIdx
|
|
76
|
-
)
|
|
77
|
-
const cleanedSegment = firstSegment
|
|
78
|
-
.replace(START_DIVIDER, '')
|
|
79
|
-
.replace(END_DIVIDER, '')
|
|
80
|
-
.trim()
|
|
81
|
-
|
|
82
|
-
const result = retrocycle(
|
|
83
|
-
JSON.parse(cleanedSegment)
|
|
84
|
-
) as JsonParserResult
|
|
85
|
-
|
|
86
|
-
this.ingestJestResult(result)
|
|
87
|
-
|
|
88
|
-
dataToProcess = dataToProcess.substr(endDividerEndIdx)
|
|
89
|
-
}
|
|
90
|
-
} while (endDividerStartIdx > -1)
|
|
91
|
-
|
|
92
|
-
this.buffer = dataToProcess
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
private ingestJestResult(result: JsonParserResult) {
|
|
96
|
-
const testFiles = this.testResults.testFiles ?? []
|
|
97
|
-
switch (result.status) {
|
|
98
|
-
case 'onRunStart':
|
|
99
|
-
this.testResults = {
|
|
100
|
-
totalTestFiles: result.results.numTotalTestSuites,
|
|
101
|
-
}
|
|
102
|
-
break
|
|
103
|
-
|
|
104
|
-
case 'onTestCaseResult': {
|
|
105
|
-
const relativePath = this.mapAbsoluteJsToRelativeTsPath(
|
|
106
|
-
result.test.path
|
|
107
|
-
)
|
|
108
|
-
const idx = testFiles.findIndex(
|
|
109
|
-
(file) => file.path === relativePath
|
|
110
|
-
)
|
|
111
|
-
const test = this.testCaseResultToTest(result.testCaseResult)
|
|
112
|
-
|
|
113
|
-
if (idx === -1) {
|
|
114
|
-
break
|
|
115
|
-
}
|
|
116
|
-
if (!testFiles[idx].tests) {
|
|
117
|
-
testFiles[idx].tests = []
|
|
118
|
-
}
|
|
119
|
-
testFiles[idx].tests?.push(test)
|
|
120
|
-
break
|
|
121
|
-
}
|
|
122
|
-
case 'onTestFileStart':
|
|
123
|
-
testFiles.push({
|
|
124
|
-
path: this.pullPathFromTestResponse(result),
|
|
125
|
-
status: this.pullTestFileStatusFromTestResponse(result),
|
|
126
|
-
})
|
|
127
|
-
break
|
|
128
|
-
|
|
129
|
-
case 'onTestFileResult': {
|
|
130
|
-
this.testResults.totalTestFilesComplete =
|
|
131
|
-
this.pullTestFilesCompleteFromAggregatedResults(
|
|
132
|
-
result.aggregatedResult
|
|
133
|
-
)
|
|
134
|
-
this.testResults.totalTestFiles =
|
|
135
|
-
result.aggregatedResult.numTotalTestSuites
|
|
136
|
-
this.testResults.totalFailed =
|
|
137
|
-
result.aggregatedResult.numFailedTests
|
|
138
|
-
this.testResults.totalPassed =
|
|
139
|
-
result.aggregatedResult.numPassedTests
|
|
140
|
-
this.testResults.totalTests =
|
|
141
|
-
result.aggregatedResult.numTotalTests
|
|
142
|
-
this.testResults.totalSkipped =
|
|
143
|
-
result.aggregatedResult.numPendingTests
|
|
144
|
-
this.testResults.totalTodo =
|
|
145
|
-
result.aggregatedResult.numTodoTests
|
|
146
|
-
|
|
147
|
-
for (const testResult of result.aggregatedResult.testResults) {
|
|
148
|
-
const relativePath = this.mapAbsoluteJsToRelativeTsPath(
|
|
149
|
-
testResult.testFilePath
|
|
150
|
-
)
|
|
151
|
-
const idx = testFiles.findIndex(
|
|
152
|
-
(file) => file.path === relativePath
|
|
153
|
-
)
|
|
154
|
-
const file = {
|
|
155
|
-
...(testFiles[idx] ?? {}),
|
|
156
|
-
path: relativePath,
|
|
157
|
-
status: this.pullTestFileResultStatus(testResult),
|
|
158
|
-
tests: this.pullTestsFromTestFileResult(testResult),
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (testResult.failureMessage) {
|
|
162
|
-
file.errorMessage = testResult.failureMessage
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (idx === -1) {
|
|
166
|
-
testFiles.push(file)
|
|
167
|
-
} else {
|
|
168
|
-
testFiles[idx] = file
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
break
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (testFiles.length > 0) {
|
|
176
|
-
this.testResults.testFiles = testFiles
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
private pullTestFilesCompleteFromAggregatedResults(
|
|
181
|
-
aggregatedResult: AggregatedResult
|
|
182
|
-
) {
|
|
183
|
-
const total =
|
|
184
|
-
aggregatedResult.numFailedTestSuites +
|
|
185
|
-
aggregatedResult.numPassedTestSuites
|
|
186
|
-
|
|
187
|
-
return total
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
private pullPathFromTestResponse(result: JsonParserResult) {
|
|
191
|
-
let path = ''
|
|
192
|
-
|
|
193
|
-
switch (result.status) {
|
|
194
|
-
case 'onTestFileResult':
|
|
195
|
-
case 'onTestFileStart':
|
|
196
|
-
path = result.test.path
|
|
197
|
-
break
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const tsFile = this.mapAbsoluteJsToRelativeTsPath(path)
|
|
201
|
-
return tsFile
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
private mapAbsoluteJsToRelativeTsPath(path: string) {
|
|
205
|
-
const partialPath = path.split('__tests__').pop()
|
|
206
|
-
if (!partialPath) {
|
|
207
|
-
throw new Error('INVALID TEST FILE')
|
|
208
|
-
}
|
|
209
|
-
const tsFile = partialPath.substr(1, partialPath.length - 3) + 'ts'
|
|
210
|
-
return tsFile
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
private pullTestFileStatusFromTestResponse(
|
|
214
|
-
result: JsonParserResult
|
|
215
|
-
): SpruceTestFile['status'] {
|
|
216
|
-
switch (result.status) {
|
|
217
|
-
case 'onTestFileResult':
|
|
218
|
-
return this.pullTestFileResultStatus(result.testResult)
|
|
219
|
-
default:
|
|
220
|
-
return 'running'
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
private pullTestFileResultStatus(testResult: TestResult): TestResultStatus {
|
|
225
|
-
return testResult.failureMessage || testResult.numFailingTests > 0
|
|
226
|
-
? 'failed'
|
|
227
|
-
: 'passed'
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
private pullTestsFromTestFileResult(
|
|
231
|
-
testResult: TestResult
|
|
232
|
-
): SpruceTestFile['tests'] {
|
|
233
|
-
return testResult.testResults.map((test: AssertionResult) =>
|
|
234
|
-
this.testCaseResultToTest(test)
|
|
235
|
-
)
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
private testCaseResultToTest(test: AssertionResult): {
|
|
239
|
-
name: string
|
|
240
|
-
status: AssertionResult['status']
|
|
241
|
-
errorMessages: string[]
|
|
242
|
-
duration: number
|
|
243
|
-
} {
|
|
244
|
-
return {
|
|
245
|
-
name: test.title,
|
|
246
|
-
status: test.status,
|
|
247
|
-
errorMessages: test.failureMessages,
|
|
248
|
-
duration: test.duration ?? 0,
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
public getResults(): TestResults {
|
|
253
|
-
return this.testResults
|
|
254
|
-
}
|
|
255
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import terminal_kit from 'terminal-kit'
|
|
2
|
-
import { ButtonWidget, ButtonWidgetOptions } from './button.types.js'
|
|
3
|
-
import termKitUtil from './termKit.utility.js'
|
|
4
|
-
import TkBaseWidget, { TkWidgetOptions } from './TkBaseWidget.js'
|
|
5
|
-
const termKit = terminal_kit as any
|
|
6
|
-
|
|
7
|
-
export default class TKButtonWidget
|
|
8
|
-
extends TkBaseWidget
|
|
9
|
-
implements ButtonWidget
|
|
10
|
-
{
|
|
11
|
-
private button: any
|
|
12
|
-
|
|
13
|
-
public readonly type = 'button'
|
|
14
|
-
|
|
15
|
-
public constructor(
|
|
16
|
-
options: TkWidgetOptions & ButtonWidgetOptions & { termKitElement: any }
|
|
17
|
-
) {
|
|
18
|
-
super({
|
|
19
|
-
...options,
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
const { parent, text, ...rest } = options
|
|
23
|
-
|
|
24
|
-
const frame = termKitUtil.buildFrame(options, parent)
|
|
25
|
-
|
|
26
|
-
this.button = new termKit.Button({
|
|
27
|
-
parent: parent ? parent.getTermKitElement() : undefined,
|
|
28
|
-
content: text,
|
|
29
|
-
...rest,
|
|
30
|
-
...frame,
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
this.button.on('submit', this.handleClick.bind(this))
|
|
34
|
-
this.button.__widget = this
|
|
35
|
-
|
|
36
|
-
this.calculateSizeLockDeltas()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
private handleClick() {
|
|
40
|
-
void (this as ButtonWidget).emit('click')
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public getText(): string {
|
|
44
|
-
throw new Error('Method not implemented.')
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public setText(text: string): void {
|
|
48
|
-
this.button.setContent(text)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public getTermKitElement() {
|
|
52
|
-
return this.button
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import StackCleaner from '../utilities/StackCleaner.js'
|
|
3
|
-
import durationUtil from './duration.utility.js'
|
|
4
|
-
import { SpruceTestFile, TestFileTest, TestRunnerStatus } from './test.types.js'
|
|
5
|
-
|
|
6
|
-
export default class TestLogItemGenerator {
|
|
7
|
-
private startTimes: Record<string, number> = {}
|
|
8
|
-
private testRunnerStatus!: TestRunnerStatus
|
|
9
|
-
|
|
10
|
-
public generateLogItemForFile(
|
|
11
|
-
file: SpruceTestFile,
|
|
12
|
-
status: TestRunnerStatus
|
|
13
|
-
): string {
|
|
14
|
-
this.testRunnerStatus = status
|
|
15
|
-
|
|
16
|
-
let logContent = ''
|
|
17
|
-
const duration = this.calculateDurationInMsForFile(file)
|
|
18
|
-
|
|
19
|
-
logContent += `${this.generateStatusBlock(file.status)} ${file.path}${
|
|
20
|
-
duration ? ` ${this.generateDuration(file.status, duration)}` : ''
|
|
21
|
-
}\n`
|
|
22
|
-
|
|
23
|
-
if (file.tests) {
|
|
24
|
-
file.tests.forEach((test) => {
|
|
25
|
-
const bullet = this.bulletBasedOnStatus(test.status)
|
|
26
|
-
logContent += ` ${bullet} ^-${
|
|
27
|
-
test.name
|
|
28
|
-
}^ ${this.generateDuration(test.status, test.duration)}\n`
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (file.status === 'running') {
|
|
33
|
-
const pendingKey = `${file.path}-pending-${file.tests?.length ?? 0}`
|
|
34
|
-
logContent += ` ^-${'Running next test... ⚡️⚡️⚡️'}^ ${this.generateDuration(
|
|
35
|
-
'running',
|
|
36
|
-
this.calculateDurationInMs(pendingKey)
|
|
37
|
-
)}\n`
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return logContent
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private generateDuration(status: any, duration: number) {
|
|
44
|
-
if (duration === 0) {
|
|
45
|
-
return ''
|
|
46
|
-
}
|
|
47
|
-
const durationColor = this.colorBasedOnStatus(status)
|
|
48
|
-
return `^${durationColor}(${durationUtil.msToFriendly(duration)})^`
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private bulletBasedOnStatus(status: TestFileTest['status'] | 'running') {
|
|
52
|
-
let bullet = 'y'
|
|
53
|
-
|
|
54
|
-
switch (status) {
|
|
55
|
-
case 'running':
|
|
56
|
-
bullet = '^g(running)^'
|
|
57
|
-
break
|
|
58
|
-
case 'passed':
|
|
59
|
-
bullet = '^g√^'
|
|
60
|
-
break
|
|
61
|
-
case 'failed':
|
|
62
|
-
bullet = '^rx^'
|
|
63
|
-
break
|
|
64
|
-
case 'pending':
|
|
65
|
-
case 'skipped':
|
|
66
|
-
bullet = '^y(skipped)^'
|
|
67
|
-
break
|
|
68
|
-
case 'todo':
|
|
69
|
-
bullet = '^y(todo)^'
|
|
70
|
-
break
|
|
71
|
-
default:
|
|
72
|
-
bullet = '??'
|
|
73
|
-
break
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return bullet
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private calculateDurationInMsForFile(file: SpruceTestFile): number {
|
|
80
|
-
if (file.status !== 'running' && file.tests) {
|
|
81
|
-
return file.tests.reduce((time, test) => {
|
|
82
|
-
time += test.duration
|
|
83
|
-
return time
|
|
84
|
-
}, 0)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const key = file.path
|
|
88
|
-
return this.calculateDurationInMs(key)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
private calculateDurationInMs(key: string) {
|
|
92
|
-
if (!this.startTimes[key]) {
|
|
93
|
-
this.startTimes[key] = new Date().getTime()
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const delta = new Date().getTime() - this.startTimes[key]
|
|
97
|
-
return delta
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public generateErrorLogItemForFile(file: SpruceTestFile): string {
|
|
101
|
-
let errorContent = ''
|
|
102
|
-
|
|
103
|
-
file.tests?.forEach((test) => {
|
|
104
|
-
test.errorMessages?.forEach((message) => {
|
|
105
|
-
const cleaned = StackCleaner.clean(message ?? '')
|
|
106
|
-
errorContent += ` ${chalk.red(file.path)}\n`
|
|
107
|
-
errorContent += ` - ${chalk.red(test.name)}\n\n`
|
|
108
|
-
errorContent +=
|
|
109
|
-
cleaned.replace(/\n+ {4}at/i, '\n\n\n at') + '\n\n\n'
|
|
110
|
-
})
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
if (!errorContent && file.errorMessage) {
|
|
114
|
-
errorContent += `${chalk.red(file.path)}\n`
|
|
115
|
-
errorContent += file.errorMessage + '\n\n\n'
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return errorContent
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public resetStartTimes() {
|
|
122
|
-
this.startTimes = {}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private generateStatusBlock(status: SpruceTestFile['status']) {
|
|
126
|
-
const bgColor = this.colorBasedOnStatus(status)
|
|
127
|
-
|
|
128
|
-
let statusLabel = status as string
|
|
129
|
-
let color = 'k'
|
|
130
|
-
let padding = 10
|
|
131
|
-
switch (status) {
|
|
132
|
-
case 'passed':
|
|
133
|
-
padding = 11
|
|
134
|
-
color = 'w'
|
|
135
|
-
break
|
|
136
|
-
case 'failed':
|
|
137
|
-
padding = 11
|
|
138
|
-
color = 'w'
|
|
139
|
-
break
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (status === 'running' && this.testRunnerStatus === 'stopped') {
|
|
143
|
-
statusLabel = 'stopped'
|
|
144
|
-
color = 'w'
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return `^b^#^${bgColor}^${color}^+${this.centerStringWithSpaces(
|
|
148
|
-
statusLabel,
|
|
149
|
-
padding
|
|
150
|
-
)}^`
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
private colorBasedOnStatus(status: SpruceTestFile['status']) {
|
|
154
|
-
let color = 'y'
|
|
155
|
-
|
|
156
|
-
switch (status) {
|
|
157
|
-
case 'passed':
|
|
158
|
-
color = 'g'
|
|
159
|
-
break
|
|
160
|
-
case 'failed':
|
|
161
|
-
color = 'r'
|
|
162
|
-
break
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (status === 'running' && this.testRunnerStatus === 'stopped') {
|
|
166
|
-
color = 'b'
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return color
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
private centerStringWithSpaces(text: string, numberOfSpaces: number) {
|
|
173
|
-
text = text.trim()
|
|
174
|
-
let l = text.length
|
|
175
|
-
let w2 = Math.floor(numberOfSpaces / 2)
|
|
176
|
-
let l2 = Math.floor(l / 2)
|
|
177
|
-
let s = new Array(w2 - l2 + 1).join(' ')
|
|
178
|
-
text = s + text + s
|
|
179
|
-
if (text.length < numberOfSpaces) {
|
|
180
|
-
text += new Array(numberOfSpaces - text.length + 1).join(' ')
|
|
181
|
-
}
|
|
182
|
-
return text
|
|
183
|
-
}
|
|
184
|
-
}
|