@neurodevs/node-tdd 0.2.5 → 1.0.1
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/.vscode/launch.json +52 -57
- package/.vscode/settings.json +61 -66
- package/.vscode/tasks.json +98 -129
- package/README.md +1 -0
- package/build/.spruce/settings.json +3 -10
- package/build/__tests__/MockFetch.d.ts +18 -0
- package/build/__tests__/MockFetch.js +55 -0
- package/build/__tests__/MockFetch.js.map +1 -0
- package/build/__tests__/{impl → behavioral}/AbstractModuleTest.test.d.ts +2 -3
- package/build/__tests__/{impl → behavioral}/AbstractModuleTest.test.js +3 -12
- package/build/__tests__/behavioral/AbstractModuleTest.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.d.ts +5 -0
- package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.js +34 -0
- package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/Assert.test.d.ts +45 -0
- package/build/__tests__/behavioral/utilities/Assert.test.js +645 -0
- package/build/__tests__/behavioral/utilities/Assert.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.js +23 -0
- package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/MockFetch.test.d.ts +28 -0
- package/build/__tests__/behavioral/utilities/MockFetch.test.js +211 -0
- package/build/__tests__/behavioral/utilities/MockFetch.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/StackCleaner.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/StackCleaner.test.js +46 -0
- package/build/__tests__/behavioral/utilities/StackCleaner.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.d.ts +7 -0
- package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.js +32 -0
- package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.js +19 -0
- package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/Stringify.test.d.ts +5 -0
- package/build/__tests__/behavioral/utilities/Stringify.test.js +127 -0
- package/build/__tests__/behavioral/utilities/Stringify.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.d.ts +7 -0
- package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.js +38 -0
- package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnBasic.test.d.ts +12 -0
- package/build/__tests__/behavioral/utilities/TestOnBasic.test.js +68 -0
- package/build/__tests__/behavioral/utilities/TestOnBasic.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstance.test.d.ts +28 -0
- package/build/__tests__/behavioral/utilities/TestOnInstance.test.js +289 -0
- package/build/__tests__/behavioral/utilities/TestOnInstance.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.d.ts +9 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.js +118 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.d.ts +5 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.js +78 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.js +23 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.js +24 -0
- package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestResolver.test.d.ts +7 -0
- package/build/__tests__/behavioral/utilities/TestResolver.test.js +38 -0
- package/build/__tests__/behavioral/utilities/TestResolver.test.js.map +1 -0
- package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.d.ts +4 -0
- package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.js +20 -0
- package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.js.map +1 -0
- package/build/__tests__/behavioral/workspace/JestJsonParser.test.d.ts +18 -0
- package/build/__tests__/behavioral/workspace/JestJsonParser.test.js +267 -0
- package/build/__tests__/behavioral/workspace/JestJsonParser.test.js.map +1 -0
- package/build/__tests__/behavioral/workspace/TestReporter.test.d.ts +16 -0
- package/build/__tests__/behavioral/workspace/TestReporter.test.js +227 -0
- package/build/__tests__/behavioral/workspace/TestReporter.test.js.map +1 -0
- package/build/__tests__/behavioral/workspace/TestRunner.test.d.ts +15 -0
- package/build/__tests__/behavioral/workspace/TestRunner.test.js +99 -0
- package/build/__tests__/behavioral/workspace/TestRunner.test.js.map +1 -0
- package/build/__tests__/behavioral/workspace/Widgets.test.d.ts +13 -0
- package/build/__tests__/behavioral/workspace/Widgets.test.js +99 -0
- package/build/__tests__/behavioral/workspace/Widgets.test.js.map +1 -0
- package/build/__tests__/mock-terminal-kit.d.ts +79 -0
- package/build/__tests__/mock-terminal-kit.js +103 -0
- package/build/__tests__/mock-terminal-kit.js.map +1 -0
- package/build/__tests__/support/AbstractForInstanceTest.d.ts +4 -0
- package/build/__tests__/support/AbstractForInstanceTest.js +9 -0
- package/build/__tests__/support/AbstractForInstanceTest.js.map +1 -0
- package/build/__tests__/support/AbstractLevelOneTest.d.ts +3 -0
- package/build/__tests__/support/AbstractLevelOneTest.js +4 -0
- package/build/__tests__/support/AbstractLevelOneTest.js.map +1 -0
- package/build/__tests__/support/AbstractLevelTwoTest.d.ts +7 -0
- package/build/__tests__/support/AbstractLevelTwoTest.js +14 -0
- package/build/__tests__/support/AbstractLevelTwoTest.js.map +1 -0
- package/build/__tests__/support/AbstractStaticTest.d.ts +7 -0
- package/build/__tests__/support/AbstractStaticTest.js +14 -0
- package/build/__tests__/support/AbstractStaticTest.js.map +1 -0
- package/build/__tests__/support/AbstractTestOnInstanceTest.d.ts +22 -0
- package/build/__tests__/support/AbstractTestOnInstanceTest.js +23 -0
- package/build/__tests__/support/AbstractTestOnInstanceTest.js.map +1 -0
- package/build/__tests__/support/AbstractTestOnInstanceWithHooks.d.ts +26 -0
- package/build/__tests__/support/AbstractTestOnInstanceWithHooks.js +59 -0
- package/build/__tests__/support/AbstractTestOnInstanceWithHooks.js.map +1 -0
- package/build/__tests__/support/jest.setup.d.ts +1 -0
- package/build/__tests__/support/jest.setup.js +4 -0
- package/build/__tests__/support/jest.setup.js.map +1 -0
- package/build/__tests__/support/onTestFileResult.d.ts +244 -0
- package/build/__tests__/support/onTestFileResult.js +980 -0
- package/build/__tests__/support/onTestFileResult.js.map +1 -0
- package/build/impl/AbstractModuleTest.d.ts +18 -4
- package/build/impl/AbstractModuleTest.js +47 -9
- package/build/impl/AbstractModuleTest.js.map +1 -1
- package/build/index.d.ts +4 -4
- package/build/index.js +4 -4
- package/build/index.js.map +1 -1
- package/build/utilities/AssertionError.d.ts +3 -0
- package/build/utilities/AssertionError.js +12 -0
- package/build/utilities/AssertionError.js.map +1 -0
- package/build/utilities/StackCleaner.d.ts +4 -0
- package/build/utilities/StackCleaner.js +10 -0
- package/build/utilities/StackCleaner.js.map +1 -0
- package/build/utilities/TestDecoratorResolver.d.ts +35 -0
- package/build/utilities/TestDecoratorResolver.js +93 -0
- package/build/utilities/TestDecoratorResolver.js.map +1 -0
- package/build/utilities/assert.d.ts +49 -0
- package/build/utilities/assert.js +255 -0
- package/build/utilities/assert.js.map +1 -0
- package/build/utilities/assert.utility.d.ts +28 -0
- package/build/utilities/assert.utility.js +185 -0
- package/build/utilities/assert.utility.js.map +1 -0
- package/build/utilities/decorators.d.ts +9 -0
- package/build/utilities/decorators.js +133 -0
- package/build/utilities/decorators.js.map +1 -0
- package/build/workspace/CommandService.d.ts +49 -0
- package/build/workspace/CommandService.js +179 -0
- package/build/workspace/CommandService.js.map +1 -0
- package/build/workspace/JestJsonParser.d.ts +15 -0
- package/build/workspace/JestJsonParser.js +149 -0
- package/build/workspace/JestJsonParser.js.map +1 -0
- package/build/workspace/TKButtonWidget.d.ts +13 -0
- package/build/workspace/TKButtonWidget.js +37 -0
- package/build/workspace/TKButtonWidget.js.map +1 -0
- package/build/workspace/TestLogItemGenerator.d.ts +15 -0
- package/build/workspace/TestLogItemGenerator.js +142 -0
- package/build/workspace/TestLogItemGenerator.js.map +1 -0
- package/build/workspace/TestReporter.d.ts +103 -0
- package/build/workspace/TestReporter.js +677 -0
- package/build/workspace/TestReporter.js.map +1 -0
- package/build/workspace/TestRunner.d.ts +24 -0
- package/build/workspace/TestRunner.js +95 -0
- package/build/workspace/TestRunner.js.map +1 -0
- package/build/workspace/TkBaseWidget.d.ts +37 -0
- package/build/workspace/TkBaseWidget.js +185 -0
- package/build/workspace/TkBaseWidget.js.map +1 -0
- package/build/workspace/TkInputWidget.d.ts +16 -0
- package/build/workspace/TkInputWidget.js +64 -0
- package/build/workspace/TkInputWidget.js.map +1 -0
- package/build/workspace/TkLayoutCellWidget.d.ts +18 -0
- package/build/workspace/TkLayoutCellWidget.js +32 -0
- package/build/workspace/TkLayoutCellWidget.js.map +1 -0
- package/build/workspace/TkLayoutWidget.d.ts +34 -0
- package/build/workspace/TkLayoutWidget.js +130 -0
- package/build/workspace/TkLayoutWidget.js.map +1 -0
- package/build/workspace/TkMenuBarWidget.d.ts +13 -0
- package/build/workspace/TkMenuBarWidget.js +71 -0
- package/build/workspace/TkMenuBarWidget.js.map +1 -0
- package/build/workspace/TkPopupWidget.d.ts +16 -0
- package/build/workspace/TkPopupWidget.js +36 -0
- package/build/workspace/TkPopupWidget.js.map +1 -0
- package/build/workspace/TkProgressBarWidget.d.ts +10 -0
- package/build/workspace/TkProgressBarWidget.js +39 -0
- package/build/workspace/TkProgressBarWidget.js.map +1 -0
- package/build/workspace/TkTextWidget.d.ts +20 -0
- package/build/workspace/TkTextWidget.js +115 -0
- package/build/workspace/TkTextWidget.js.map +1 -0
- package/build/workspace/TkWindowWidget.d.ts +22 -0
- package/build/workspace/TkWindowWidget.js +88 -0
- package/build/workspace/TkWindowWidget.js.map +1 -0
- package/build/workspace/WidgetFactory.d.ts +6 -0
- package/build/workspace/WidgetFactory.js +21 -0
- package/build/workspace/WidgetFactory.js.map +1 -0
- package/build/workspace/button.types.d.ts +15 -0
- package/build/workspace/button.types.js +6 -0
- package/build/workspace/button.types.js.map +1 -0
- package/build/workspace/duration.utility.d.ts +4 -0
- package/build/workspace/duration.utility.js +26 -0
- package/build/workspace/duration.utility.js.map +1 -0
- package/build/workspace/factory.types.d.ts +89 -0
- package/build/workspace/factory.types.js +37 -0
- package/build/workspace/factory.types.js.map +1 -0
- package/build/workspace/input.types.d.ts +18 -0
- package/build/workspace/input.types.js +7 -0
- package/build/workspace/input.types.js.map +1 -0
- package/build/workspace/keySelectChoices.d.ts +517 -0
- package/build/workspace/keySelectChoices.js +2 -0
- package/build/workspace/keySelectChoices.js.map +1 -0
- package/build/workspace/layout.types.d.ts +33 -0
- package/build/workspace/layout.types.js +2 -0
- package/build/workspace/layout.types.js.map +1 -0
- package/build/workspace/menuBar.types.d.ts +19 -0
- package/build/workspace/menuBar.types.js +6 -0
- package/build/workspace/menuBar.types.js.map +1 -0
- package/build/workspace/popup.types.d.ts +13 -0
- package/build/workspace/popup.types.js +6 -0
- package/build/workspace/popup.types.js.map +1 -0
- package/build/workspace/progressBar.types.d.ts +10 -0
- package/build/workspace/progressBar.types.js +2 -0
- package/build/workspace/progressBar.types.js.map +1 -0
- package/build/workspace/table.types.d.ts +6 -0
- package/build/workspace/table.types.js +2 -0
- package/build/workspace/table.types.js.map +1 -0
- package/build/workspace/termKit.utility.d.ts +12 -0
- package/build/workspace/termKit.utility.js +128 -0
- package/build/workspace/termKit.utility.js.map +1 -0
- package/build/workspace/test.types.d.ts +24 -0
- package/build/workspace/test.types.js +2 -0
- package/build/workspace/test.types.js.map +1 -0
- package/build/workspace/testRunner.cli.d.ts +1 -0
- package/build/workspace/testRunner.cli.js +149 -0
- package/build/workspace/testRunner.cli.js.map +1 -0
- package/build/workspace/text.types.d.ts +20 -0
- package/build/workspace/text.types.js +7 -0
- package/build/workspace/text.types.js.map +1 -0
- package/build/workspace/widget.utilities.d.ts +5 -0
- package/build/workspace/widget.utilities.js +20 -0
- package/build/workspace/widget.utilities.js.map +1 -0
- package/build/workspace/widgets.types.d.ts +66 -0
- package/build/workspace/widgets.types.js +2 -0
- package/build/workspace/widgets.types.js.map +1 -0
- package/build/workspace/window.types.d.ts +18 -0
- package/build/workspace/window.types.js +9 -0
- package/build/workspace/window.types.js.map +1 -0
- package/eslint.config.js +3 -0
- package/package.json +31 -37
- package/prettier.config.js +3 -0
- package/src/.spruce/settings.json +3 -10
- package/src/__tests__/MockFetch.ts +100 -0
- package/src/__tests__/behavioral/AbstractModuleTest.test.ts +15 -0
- package/src/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.ts +31 -0
- package/src/__tests__/behavioral/utilities/Assert.test.ts +826 -0
- package/src/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.ts +14 -0
- package/src/__tests__/behavioral/utilities/MockFetch.test.ts +240 -0
- package/src/__tests__/behavioral/utilities/StackCleaner.test.ts +46 -0
- package/src/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.ts +34 -0
- package/src/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.ts +11 -0
- package/src/__tests__/behavioral/utilities/Stringify.test.ts +169 -0
- package/src/__tests__/behavioral/utilities/TestDecoratorResolver.test.ts +51 -0
- package/src/__tests__/behavioral/utilities/TestOnBasic.test.ts +62 -0
- package/src/__tests__/behavioral/utilities/TestOnInstance.test.ts +439 -0
- package/src/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.ts +237 -0
- package/src/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.ts +85 -0
- package/src/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.ts +14 -0
- package/src/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.ts +16 -0
- package/src/__tests__/behavioral/utilities/TestResolver.test.ts +48 -0
- package/src/__tests__/behavioral/utilities/TestResolverOnStatic.test.ts +12 -0
- package/src/__tests__/behavioral/workspace/JestJsonParser.test.ts +357 -0
- package/src/__tests__/behavioral/workspace/TestReporter.test.ts +257 -0
- package/src/__tests__/behavioral/workspace/TestRunner.test.ts +87 -0
- package/src/__tests__/behavioral/workspace/Widgets.test.ts +90 -0
- package/src/__tests__/mock-terminal-kit.ts +115 -0
- package/src/__tests__/support/AbstractForInstanceTest.ts +12 -0
- package/src/__tests__/support/AbstractLevelOneTest.ts +3 -0
- package/src/__tests__/support/AbstractLevelTwoTest.ts +16 -0
- package/src/__tests__/support/AbstractStaticTest.ts +16 -0
- package/src/__tests__/support/AbstractTestOnInstanceTest.ts +30 -0
- package/src/__tests__/support/AbstractTestOnInstanceWithHooks.ts +138 -0
- package/src/__tests__/support/jest.setup.ts +2 -0
- package/src/__tests__/support/onTestFileResult.ts +1008 -0
- package/src/impl/AbstractModuleTest.ts +59 -10
- package/src/index.ts +4 -4
- package/src/utilities/AssertionError.ts +14 -0
- package/src/utilities/StackCleaner.ts +14 -0
- package/src/utilities/TestDecoratorResolver.ts +118 -0
- package/src/utilities/assert.ts +583 -0
- package/src/utilities/assert.utility.ts +295 -0
- package/src/utilities/decorators.ts +167 -0
- package/src/workspace/CommandService.ts +256 -0
- package/src/workspace/JestJsonParser.ts +255 -0
- package/src/workspace/TKButtonWidget.ts +54 -0
- package/src/workspace/TestLogItemGenerator.ts +184 -0
- package/src/workspace/TestReporter.ts +865 -0
- package/src/workspace/TestRunner.ts +128 -0
- package/src/workspace/TkBaseWidget.ts +249 -0
- package/src/workspace/TkInputWidget.ts +83 -0
- package/src/workspace/TkLayoutCellWidget.ts +46 -0
- package/src/workspace/TkLayoutWidget.ts +181 -0
- package/src/workspace/TkMenuBarWidget.ts +95 -0
- package/src/workspace/TkPopupWidget.ts +47 -0
- package/src/workspace/TkProgressBarWidget.ts +54 -0
- package/src/workspace/TkTextWidget.ts +158 -0
- package/src/workspace/TkWindowWidget.ts +122 -0
- package/src/workspace/WidgetFactory.ts +33 -0
- package/src/workspace/button.types.ts +19 -0
- package/src/workspace/duration.utility.ts +34 -0
- package/src/workspace/factory.types.ts +101 -0
- package/src/workspace/input.types.ts +22 -0
- package/src/workspace/keySelectChoices.ts +134 -0
- package/src/workspace/layout.types.ts +40 -0
- package/src/workspace/menuBar.types.ts +24 -0
- package/src/workspace/popup.types.ts +17 -0
- package/src/workspace/progressBar.types.ts +13 -0
- package/src/workspace/table.types.ts +9 -0
- package/src/workspace/termKit.utility.ts +130 -0
- package/src/workspace/terminal-kit.d.ts +28 -0
- package/src/workspace/test.types.ts +34 -0
- package/src/workspace/testRunner.cli.ts +159 -0
- package/src/workspace/text.types.ts +26 -0
- package/src/workspace/widget.utilities.ts +35 -0
- package/src/workspace/widgets.types.ts +102 -0
- package/src/workspace/window.types.ts +22 -0
- package/tsconfig.json +23 -27
- package/build/__tests__/AbstractPackageTest.d.ts +0 -4
- package/build/__tests__/AbstractPackageTest.js +0 -7
- package/build/__tests__/AbstractPackageTest.js.map +0 -1
- package/build/__tests__/functions/assertFunction.test.d.ts +0 -5
- package/build/__tests__/functions/assertFunction.test.js +0 -23
- package/build/__tests__/functions/assertFunction.test.js.map +0 -1
- package/build/__tests__/functions/testFunction.test.d.ts +0 -5
- package/build/__tests__/functions/testFunction.test.js +0 -23
- package/build/__tests__/functions/testFunction.test.js.map +0 -1
- package/build/__tests__/impl/AbstractModuleTest.test.js.map +0 -1
- package/build/functions/assert.d.ts +0 -3
- package/build/functions/assert.js +0 -4
- package/build/functions/assert.js.map +0 -1
- package/build/functions/test.d.ts +0 -3
- package/build/functions/test.js +0 -4
- package/build/functions/test.js.map +0 -1
- package/eslint.config.mjs +0 -3
- package/src/__tests__/AbstractPackageTest.ts +0 -7
- package/src/__tests__/functions/assertFunction.test.ts +0 -22
- package/src/__tests__/functions/testFunction.test.ts +0 -22
- package/src/__tests__/impl/AbstractModuleTest.test.ts +0 -34
- package/src/functions/assert.ts +0 -4
- package/src/functions/test.ts +0 -4
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AssertionResult,
|
|
3
|
+
END_DIVIDER,
|
|
4
|
+
START_DIVIDER,
|
|
5
|
+
retrocycle,
|
|
6
|
+
} from '@sprucelabs/jest-json-reporter'
|
|
7
|
+
import escapeRegExp from 'lodash/escapeRegExp.js'
|
|
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
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
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
|
+
}
|