@neurodevs/node-tdd 0.2.5 → 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/.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 +30 -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,677 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import durationUtil from './duration.utility.js';
|
|
3
|
+
import WidgetFactory from './WidgetFactory.js';
|
|
4
|
+
import TestLogItemGenerator from './TestLogItemGenerator.js';
|
|
5
|
+
export default class TestReporter {
|
|
6
|
+
started = false;
|
|
7
|
+
table;
|
|
8
|
+
bar;
|
|
9
|
+
bottomLayout;
|
|
10
|
+
testLog;
|
|
11
|
+
errorLog;
|
|
12
|
+
errorLogItemGenerator;
|
|
13
|
+
lastResults = {
|
|
14
|
+
totalTestFiles: 0,
|
|
15
|
+
customErrors: [],
|
|
16
|
+
};
|
|
17
|
+
updateInterval;
|
|
18
|
+
menu;
|
|
19
|
+
statusBar;
|
|
20
|
+
window;
|
|
21
|
+
widgets;
|
|
22
|
+
selectTestPopup;
|
|
23
|
+
topLayout;
|
|
24
|
+
filterInput;
|
|
25
|
+
filterPattern;
|
|
26
|
+
clearFilterPatternButton;
|
|
27
|
+
isDebugging = false;
|
|
28
|
+
watchMode = 'off';
|
|
29
|
+
status = 'ready';
|
|
30
|
+
countDownTimeInterval;
|
|
31
|
+
cwd;
|
|
32
|
+
orientation = 'landscape';
|
|
33
|
+
handleStartStop;
|
|
34
|
+
handleRestart;
|
|
35
|
+
handleQuit;
|
|
36
|
+
handleRerunTestFile;
|
|
37
|
+
handleFilterChange;
|
|
38
|
+
handleOpenTestFile;
|
|
39
|
+
handleToggleDebug;
|
|
40
|
+
handletoggleStandardWatch;
|
|
41
|
+
handleToggleSmartWatch;
|
|
42
|
+
minWidth = 50;
|
|
43
|
+
constructor(options) {
|
|
44
|
+
this.cwd = options?.cwd;
|
|
45
|
+
this.filterPattern = options?.filterPattern;
|
|
46
|
+
this.handleRestart = options?.handleRestart;
|
|
47
|
+
this.handleStartStop = options?.handleStartStop;
|
|
48
|
+
this.handleQuit = options?.handleQuit;
|
|
49
|
+
this.handleRerunTestFile = options?.handleRerunTestFile;
|
|
50
|
+
this.handleOpenTestFile = options?.handleOpenTestFile;
|
|
51
|
+
this.handleFilterChange = options?.handleFilterPatternChange;
|
|
52
|
+
this.status = options?.status ?? 'ready';
|
|
53
|
+
this.handleToggleDebug = options?.handleToggleDebug;
|
|
54
|
+
this.handletoggleStandardWatch = options?.handletoggleStandardWatch;
|
|
55
|
+
this.isDebugging = options?.isDebugging ?? false;
|
|
56
|
+
this.watchMode = options?.watchMode ?? 'off';
|
|
57
|
+
this.handleToggleSmartWatch = options?.handleToggleSmartWatch;
|
|
58
|
+
this.errorLogItemGenerator = new TestLogItemGenerator();
|
|
59
|
+
this.widgets = new WidgetFactory();
|
|
60
|
+
}
|
|
61
|
+
setFilterPattern(pattern) {
|
|
62
|
+
this.filterPattern = pattern;
|
|
63
|
+
this.filterInput.setValue(pattern ?? '');
|
|
64
|
+
this.clearFilterPatternButton.setText(buildPatternButtonText(pattern));
|
|
65
|
+
}
|
|
66
|
+
setIsDebugging(isDebugging) {
|
|
67
|
+
this.setLabelStatus('toggleDebug', 'Debug', isDebugging);
|
|
68
|
+
this.isDebugging = isDebugging;
|
|
69
|
+
}
|
|
70
|
+
setWatchMode(watchMode) {
|
|
71
|
+
this.watchMode = watchMode;
|
|
72
|
+
if (!this.countDownTimeInterval) {
|
|
73
|
+
let label = watchMode === 'smart' ? 'Smart Watch' : 'Standard Watch';
|
|
74
|
+
if (watchMode === 'off') {
|
|
75
|
+
label = 'Not Watching';
|
|
76
|
+
}
|
|
77
|
+
this.setWatchLabel(label);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
setWatchLabel(label) {
|
|
81
|
+
const isEnabled = this.watchMode !== 'off';
|
|
82
|
+
this.setLabelStatus('watchDropdown', label, isEnabled);
|
|
83
|
+
this.menu.setTextForItem('toggleStandardWatch', this.watchMode === 'standard' ? '√ Standard' : 'Standard');
|
|
84
|
+
this.menu.setTextForItem('toggleSmartWatch', this.watchMode === 'smart' ? '√ Smart' : 'Smart');
|
|
85
|
+
}
|
|
86
|
+
setLabelStatus(menuKey, label, isEnabled) {
|
|
87
|
+
this.menu.setTextForItem(menuKey, `${label} ^${isEnabled ? 'k' : 'w'}^#^${isEnabled ? 'g' : 'r'}${isEnabled ? ' • ' : ' • '}^`);
|
|
88
|
+
}
|
|
89
|
+
startCountdownTimer(durationSec) {
|
|
90
|
+
clearInterval(this.countDownTimeInterval);
|
|
91
|
+
this.countDownTimeInterval = undefined;
|
|
92
|
+
let remaining = durationSec;
|
|
93
|
+
function renderCountdownTime(time) {
|
|
94
|
+
return `Starting ${time} `;
|
|
95
|
+
}
|
|
96
|
+
this.setWatchLabel(renderCountdownTime(remaining));
|
|
97
|
+
this.countDownTimeInterval = setInterval(() => {
|
|
98
|
+
remaining--;
|
|
99
|
+
if (remaining < 0) {
|
|
100
|
+
this.stopCountdownTimer();
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.setWatchLabel(renderCountdownTime(remaining));
|
|
104
|
+
}
|
|
105
|
+
}, 1000);
|
|
106
|
+
}
|
|
107
|
+
stopCountdownTimer() {
|
|
108
|
+
clearInterval(this.countDownTimeInterval);
|
|
109
|
+
this.countDownTimeInterval = undefined;
|
|
110
|
+
this.setWatchMode(this.watchMode);
|
|
111
|
+
}
|
|
112
|
+
async start() {
|
|
113
|
+
this.started = true;
|
|
114
|
+
this.window = this.widgets.Widget('window', {});
|
|
115
|
+
this.window.hideCursor();
|
|
116
|
+
const { width } = this.window.getFrame();
|
|
117
|
+
if (width < this.minWidth) {
|
|
118
|
+
throw new Error(`Your screen must be at least ${this.minWidth} characters wide.`);
|
|
119
|
+
}
|
|
120
|
+
void this.window.on('key', this.handleGlobalKeypress.bind(this));
|
|
121
|
+
void this.window.on('kill', (payload) => {
|
|
122
|
+
if (payload.code instanceof Error) {
|
|
123
|
+
const term = this.window.term;
|
|
124
|
+
const doc = this.window.getTermKitElement?.();
|
|
125
|
+
term?.grabInput?.({ mouse: 'button' });
|
|
126
|
+
doc?.draw?.();
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
void this.destroy();
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
void this.window.on('resize', this.handleWindowResize.bind(this));
|
|
133
|
+
this.dropInTopLayout();
|
|
134
|
+
this.dropInProgressBar();
|
|
135
|
+
this.dropInMenu();
|
|
136
|
+
this.dropInBottomLayout();
|
|
137
|
+
this.dropInStatusBar();
|
|
138
|
+
this.dropInTestLog();
|
|
139
|
+
this.dropInFilterControls();
|
|
140
|
+
this.updateOrientation();
|
|
141
|
+
this.setIsDebugging(this.isDebugging);
|
|
142
|
+
this.setWatchMode(this.watchMode);
|
|
143
|
+
this.setStatus(this.status);
|
|
144
|
+
this.updateInterval = setInterval(this.handleUpdateInterval.bind(this), 1000);
|
|
145
|
+
}
|
|
146
|
+
handleWindowResize() {
|
|
147
|
+
this.updateOrientation();
|
|
148
|
+
}
|
|
149
|
+
updateOrientation() {
|
|
150
|
+
const frame = this.window.getFrame();
|
|
151
|
+
if (frame.width * 0.4 > frame.height) {
|
|
152
|
+
this.orientation = 'landscape';
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this.orientation = 'portrait';
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
dropInMenu() {
|
|
159
|
+
this.menu = this.widgets.Widget('menuBar', {
|
|
160
|
+
parent: this.window,
|
|
161
|
+
left: 0,
|
|
162
|
+
top: 0,
|
|
163
|
+
shouldLockWidthWithParent: true,
|
|
164
|
+
items: [
|
|
165
|
+
{
|
|
166
|
+
label: 'Restart ',
|
|
167
|
+
value: 'restart',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
label: 'Debug ',
|
|
171
|
+
value: 'toggleDebug',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
label: 'Not Watching ',
|
|
175
|
+
value: 'watchDropdown',
|
|
176
|
+
items: [
|
|
177
|
+
{
|
|
178
|
+
label: 'Watch all',
|
|
179
|
+
value: 'toggleStandardWatch',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
label: 'Smart watch',
|
|
183
|
+
value: 'toggleSmartWatch',
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
label: 'Quit',
|
|
189
|
+
value: 'quit',
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
});
|
|
193
|
+
void this.menu.on('select', this.handleMenuSelect.bind(this));
|
|
194
|
+
}
|
|
195
|
+
setStatus(status) {
|
|
196
|
+
this.status = status;
|
|
197
|
+
this.updateMenuLabels();
|
|
198
|
+
this.closeSelectTestPopup();
|
|
199
|
+
this.bottomLayout.updateLayout();
|
|
200
|
+
if (status === 'ready') {
|
|
201
|
+
this.setStatusLabel('Starting...');
|
|
202
|
+
}
|
|
203
|
+
else if (this.status === 'stopped') {
|
|
204
|
+
this.refreshResults();
|
|
205
|
+
this.setStatusLabel('');
|
|
206
|
+
}
|
|
207
|
+
else if (this.status === 'running') {
|
|
208
|
+
this.setStatusLabel('Running tests...');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
updateMenuLabels() {
|
|
212
|
+
let restartLabel = 'Start ^#^r › ^';
|
|
213
|
+
switch (this.status) {
|
|
214
|
+
case 'running':
|
|
215
|
+
restartLabel = 'Stop ^k^#^g › ^';
|
|
216
|
+
break;
|
|
217
|
+
case 'stopped':
|
|
218
|
+
restartLabel = `Start ^w^#^r › ^`;
|
|
219
|
+
break;
|
|
220
|
+
case 'ready':
|
|
221
|
+
restartLabel = 'Booting ^#^K › ^';
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
this.menu.setTextForItem('restart', restartLabel);
|
|
225
|
+
}
|
|
226
|
+
handleMenuSelect(payload) {
|
|
227
|
+
switch (payload.value) {
|
|
228
|
+
case 'quit':
|
|
229
|
+
this.handleQuit?.();
|
|
230
|
+
break;
|
|
231
|
+
case 'restart':
|
|
232
|
+
this.handleStartStop?.();
|
|
233
|
+
break;
|
|
234
|
+
case 'toggleDebug':
|
|
235
|
+
this.handleToggleDebug?.();
|
|
236
|
+
break;
|
|
237
|
+
case 'toggleStandardWatch':
|
|
238
|
+
this.handletoggleStandardWatch?.();
|
|
239
|
+
break;
|
|
240
|
+
case 'toggleSmartWatch':
|
|
241
|
+
this.handleToggleSmartWatch?.();
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
handleUpdateInterval() {
|
|
246
|
+
try {
|
|
247
|
+
if (this.status !== 'stopped') {
|
|
248
|
+
this.refreshResults();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
// prevent uncaughtException from crashing the TUI
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
refreshResults() {
|
|
256
|
+
if (this.lastResults) {
|
|
257
|
+
this.updateLogs();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
async handleGlobalKeypress(payload) {
|
|
261
|
+
if (this.window.getFocusedWidget() === this.filterInput) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
switch (payload.key) {
|
|
265
|
+
case 'ENTER':
|
|
266
|
+
this.handleRestart?.();
|
|
267
|
+
break;
|
|
268
|
+
case 'CTRL_C':
|
|
269
|
+
this.handleQuit?.();
|
|
270
|
+
process.exit();
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
dropInTestLog() {
|
|
275
|
+
const parent = this.bottomLayout.getChildById('results');
|
|
276
|
+
if (parent) {
|
|
277
|
+
this.testLog = this.widgets.Widget('text', {
|
|
278
|
+
parent,
|
|
279
|
+
isScrollEnabled: true,
|
|
280
|
+
left: 0,
|
|
281
|
+
top: 0,
|
|
282
|
+
height: '100%',
|
|
283
|
+
width: '100%',
|
|
284
|
+
shouldLockHeightWithParent: true,
|
|
285
|
+
shouldLockWidthWithParent: true,
|
|
286
|
+
});
|
|
287
|
+
void this.testLog.on('click', this.handleClickTestLog.bind(this));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
async handleClickTestLog(payload) {
|
|
291
|
+
const testFile = this.getFileForLine(payload.row);
|
|
292
|
+
const { row, column } = payload;
|
|
293
|
+
this.closeSelectTestPopup();
|
|
294
|
+
if (testFile) {
|
|
295
|
+
this.dropInSelectTestPopup({ testFile, column, row });
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
async showAlert(options) {
|
|
299
|
+
const { title, message } = options;
|
|
300
|
+
const windowFrame = this.window.getFrame();
|
|
301
|
+
const popupHeight = Math.min(windowFrame.height - 4, 25);
|
|
302
|
+
return new Promise((resolve) => {
|
|
303
|
+
const popup = this.widgets.Widget('popup', {
|
|
304
|
+
parent: this.window,
|
|
305
|
+
top: 2,
|
|
306
|
+
left: 4,
|
|
307
|
+
width: Math.min(windowFrame.width - 8, 80),
|
|
308
|
+
height: popupHeight,
|
|
309
|
+
});
|
|
310
|
+
this.widgets.Widget('text', {
|
|
311
|
+
parent: popup,
|
|
312
|
+
left: 2,
|
|
313
|
+
top: 1,
|
|
314
|
+
height: 1,
|
|
315
|
+
width: popup.getFrame().width - 4,
|
|
316
|
+
text: title,
|
|
317
|
+
});
|
|
318
|
+
this.widgets.Widget('text', {
|
|
319
|
+
parent: popup,
|
|
320
|
+
left: 2,
|
|
321
|
+
top: 3,
|
|
322
|
+
height: popupHeight - 7,
|
|
323
|
+
width: popup.getFrame().width - 4,
|
|
324
|
+
text: message,
|
|
325
|
+
isScrollEnabled: true,
|
|
326
|
+
wordWrap: true,
|
|
327
|
+
});
|
|
328
|
+
const okButton = this.widgets.Widget('button', {
|
|
329
|
+
parent: popup,
|
|
330
|
+
left: Math.floor(popup.getFrame().width / 2) - 4,
|
|
331
|
+
top: popupHeight - 3,
|
|
332
|
+
text: ' OK ',
|
|
333
|
+
});
|
|
334
|
+
void okButton.on('click', () => {
|
|
335
|
+
void popup.destroy();
|
|
336
|
+
resolve();
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
closeSelectTestPopup() {
|
|
341
|
+
if (this.selectTestPopup) {
|
|
342
|
+
void this.selectTestPopup.destroy();
|
|
343
|
+
this.selectTestPopup = undefined;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
dropInSelectTestPopup(options) {
|
|
347
|
+
const { testFile, row, column } = options;
|
|
348
|
+
this.selectTestPopup = this.widgets.Widget('popup', {
|
|
349
|
+
parent: this.window,
|
|
350
|
+
left: Math.max(1, column - 25),
|
|
351
|
+
top: Math.max(4, row - 2),
|
|
352
|
+
width: 50,
|
|
353
|
+
height: 10,
|
|
354
|
+
});
|
|
355
|
+
this.widgets.Widget('text', {
|
|
356
|
+
parent: this.selectTestPopup,
|
|
357
|
+
left: 1,
|
|
358
|
+
top: 1,
|
|
359
|
+
height: 4,
|
|
360
|
+
width: this.selectTestPopup.getFrame().width - 2,
|
|
361
|
+
text: `What do you wanna do with:\n\n${testFile}`,
|
|
362
|
+
});
|
|
363
|
+
const open = this.widgets.Widget('button', {
|
|
364
|
+
parent: this.selectTestPopup,
|
|
365
|
+
left: 1,
|
|
366
|
+
top: 6,
|
|
367
|
+
text: 'Open',
|
|
368
|
+
});
|
|
369
|
+
const rerun = this.widgets.Widget('button', {
|
|
370
|
+
parent: this.selectTestPopup,
|
|
371
|
+
left: 20,
|
|
372
|
+
top: 6,
|
|
373
|
+
text: 'Test',
|
|
374
|
+
});
|
|
375
|
+
const cancel = this.widgets.Widget('button', {
|
|
376
|
+
parent: this.selectTestPopup,
|
|
377
|
+
left: 37,
|
|
378
|
+
top: 6,
|
|
379
|
+
text: 'Nevermind',
|
|
380
|
+
});
|
|
381
|
+
void rerun.on('click', () => {
|
|
382
|
+
this.handleRerunTestFile?.(testFile);
|
|
383
|
+
this.closeSelectTestPopup();
|
|
384
|
+
});
|
|
385
|
+
void cancel.on('click', this.closeSelectTestPopup.bind(this));
|
|
386
|
+
void open.on('click', () => {
|
|
387
|
+
this.openTestFile(testFile);
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
openTestFile(testFile) {
|
|
391
|
+
this.handleOpenTestFile?.(testFile);
|
|
392
|
+
this.closeSelectTestPopup();
|
|
393
|
+
}
|
|
394
|
+
getFileForLine(row) {
|
|
395
|
+
let line = this.testLog.getScrollY();
|
|
396
|
+
for (const file of this.lastResults.testFiles ?? []) {
|
|
397
|
+
const minRow = line;
|
|
398
|
+
const maxRow = line + (file.tests ?? []).length;
|
|
399
|
+
if (row >= minRow && row <= maxRow) {
|
|
400
|
+
return file.path;
|
|
401
|
+
}
|
|
402
|
+
line = maxRow;
|
|
403
|
+
}
|
|
404
|
+
return undefined;
|
|
405
|
+
}
|
|
406
|
+
dropInProgressBar() {
|
|
407
|
+
const parent = this.topLayout.getChildById('progress') ?? this.window;
|
|
408
|
+
this.bar = this.widgets.Widget('progressBar', {
|
|
409
|
+
parent,
|
|
410
|
+
left: 0,
|
|
411
|
+
top: 0,
|
|
412
|
+
width: parent.getFrame().width,
|
|
413
|
+
shouldLockWidthWithParent: true,
|
|
414
|
+
label: 'Ready and waiting...',
|
|
415
|
+
progress: 0,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
dropInFilterControls() {
|
|
419
|
+
const parent = this.topLayout.getChildById('filter') ?? this.window;
|
|
420
|
+
const buttonWidth = 3;
|
|
421
|
+
this.filterInput = this.widgets.Widget('input', {
|
|
422
|
+
parent,
|
|
423
|
+
left: 0,
|
|
424
|
+
label: 'Pattern',
|
|
425
|
+
width: parent.getFrame().width - buttonWidth,
|
|
426
|
+
height: 1,
|
|
427
|
+
shouldLockWidthWithParent: true,
|
|
428
|
+
value: this.filterPattern,
|
|
429
|
+
});
|
|
430
|
+
void this.filterInput.on('cancel', () => {
|
|
431
|
+
this.filterInput.setValue(this.filterPattern ?? '');
|
|
432
|
+
});
|
|
433
|
+
void this.filterInput.on('submit', (payload) => {
|
|
434
|
+
this.handleFilterChange?.(payload?.value ?? undefined);
|
|
435
|
+
});
|
|
436
|
+
this.clearFilterPatternButton = this.widgets.Widget('button', {
|
|
437
|
+
parent,
|
|
438
|
+
left: this.filterInput.getFrame().width,
|
|
439
|
+
width: buttonWidth,
|
|
440
|
+
top: 0,
|
|
441
|
+
text: buildPatternButtonText(this.filterPattern),
|
|
442
|
+
shouldLockRightWithParent: true,
|
|
443
|
+
});
|
|
444
|
+
void this.clearFilterPatternButton.on('click', () => {
|
|
445
|
+
if (this.filterPattern || this.filterPattern?.length === 0) {
|
|
446
|
+
this.handleFilterChange?.(undefined);
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
this.filterInput.setValue('');
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
dropInBottomLayout() {
|
|
454
|
+
this.bottomLayout = this.widgets.Widget('layout', {
|
|
455
|
+
parent: this.window,
|
|
456
|
+
width: '100%',
|
|
457
|
+
top: 4,
|
|
458
|
+
height: this.window.getFrame().height - 5,
|
|
459
|
+
shouldLockWidthWithParent: true,
|
|
460
|
+
shouldLockHeightWithParent: true,
|
|
461
|
+
rows: [
|
|
462
|
+
{
|
|
463
|
+
height: '100%',
|
|
464
|
+
columns: [
|
|
465
|
+
{
|
|
466
|
+
id: 'results',
|
|
467
|
+
width: '100%',
|
|
468
|
+
},
|
|
469
|
+
],
|
|
470
|
+
},
|
|
471
|
+
],
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
dropInStatusBar() {
|
|
475
|
+
this.statusBar = this.widgets.Widget('text', {
|
|
476
|
+
parent: this.window,
|
|
477
|
+
top: this.window.getFrame().height - 1,
|
|
478
|
+
width: '100%',
|
|
479
|
+
shouldLockWidthWithParent: true,
|
|
480
|
+
shouldLockBottomWithParent: true,
|
|
481
|
+
backgroundColor: 'yellow',
|
|
482
|
+
foregroundColor: 'black',
|
|
483
|
+
text: '...',
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
dropInTopLayout() {
|
|
487
|
+
this.topLayout = this.widgets.Widget('layout', {
|
|
488
|
+
parent: this.window,
|
|
489
|
+
width: '100%',
|
|
490
|
+
top: 1,
|
|
491
|
+
height: 3,
|
|
492
|
+
shouldLockWidthWithParent: true,
|
|
493
|
+
shouldLockHeightWithParent: false,
|
|
494
|
+
rows: [
|
|
495
|
+
{
|
|
496
|
+
height: '100%',
|
|
497
|
+
columns: [
|
|
498
|
+
{
|
|
499
|
+
id: 'progress',
|
|
500
|
+
width: 50,
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
id: 'filter',
|
|
504
|
+
},
|
|
505
|
+
],
|
|
506
|
+
},
|
|
507
|
+
],
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
updateResults(results) {
|
|
511
|
+
if (!this.started) {
|
|
512
|
+
throw new Error('You must call start() before anything else.');
|
|
513
|
+
}
|
|
514
|
+
this.lastResults = {
|
|
515
|
+
...this.lastResults,
|
|
516
|
+
...results,
|
|
517
|
+
};
|
|
518
|
+
this.updateProgressBar(results);
|
|
519
|
+
const percentPassing = this.generatePercentPassing(results);
|
|
520
|
+
const percentComplete = this.generatePercentComplete(results);
|
|
521
|
+
this.window.setTitle(`Testing: ${percentComplete}% complete.${percentComplete > 0 ? ` ${percentPassing}% passing.` : ''}`);
|
|
522
|
+
this.updateLogs();
|
|
523
|
+
}
|
|
524
|
+
updateLogs() {
|
|
525
|
+
if (this.selectTestPopup) {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
const { logContent, errorContent } = this.resultsToLogContents(this.lastResults);
|
|
529
|
+
this.testLog.setText(logContent);
|
|
530
|
+
if (!errorContent) {
|
|
531
|
+
this.errorLog?.setText(' Nothing to report...');
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
!this.errorLog && this.dropInErrorLog();
|
|
535
|
+
const cleanedLog = this.cwd
|
|
536
|
+
? errorContent.replace(new RegExp(this.cwd + '/', 'gim'), '')
|
|
537
|
+
: errorContent;
|
|
538
|
+
this.errorLog?.setText(cleanedLog);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
resultsToLogContents(results) {
|
|
542
|
+
let logContent = '';
|
|
543
|
+
let errorContent = '';
|
|
544
|
+
results.testFiles?.forEach((file) => {
|
|
545
|
+
logContent += this.errorLogItemGenerator.generateLogItemForFile(file, this.status);
|
|
546
|
+
errorContent +=
|
|
547
|
+
this.errorLogItemGenerator.generateErrorLogItemForFile(file);
|
|
548
|
+
});
|
|
549
|
+
if (this.lastResults.customErrors.length > 0) {
|
|
550
|
+
errorContent =
|
|
551
|
+
this.lastResults.customErrors
|
|
552
|
+
.map((err) => chalk.red(err))
|
|
553
|
+
.join(`\n`) + `\n${errorContent}`;
|
|
554
|
+
}
|
|
555
|
+
return { logContent, errorContent };
|
|
556
|
+
}
|
|
557
|
+
dropInErrorLog() {
|
|
558
|
+
if (this.bottomLayout.getRows().length === 1) {
|
|
559
|
+
if (this.orientation === 'portrait') {
|
|
560
|
+
this.bottomLayout.addRow({
|
|
561
|
+
id: 'row_2',
|
|
562
|
+
columns: [{ id: 'errors', width: '100%' }],
|
|
563
|
+
});
|
|
564
|
+
this.bottomLayout.setRowHeight(0, '60%');
|
|
565
|
+
this.bottomLayout.setRowHeight(1, '40%');
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
this.bottomLayout.addColumn(0, { id: 'errors', width: '40%' });
|
|
569
|
+
this.bottomLayout.setColumnWidth({
|
|
570
|
+
rowIdx: 0,
|
|
571
|
+
columnIdx: 0,
|
|
572
|
+
width: '60%',
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
this.bottomLayout.updateLayout();
|
|
576
|
+
const cell = this.bottomLayout.getChildById('errors');
|
|
577
|
+
if (!cell) {
|
|
578
|
+
throw new Error('Pulling child error');
|
|
579
|
+
}
|
|
580
|
+
this.errorLog = this.widgets.Widget('text', {
|
|
581
|
+
parent: cell,
|
|
582
|
+
width: '100%',
|
|
583
|
+
height: '100%',
|
|
584
|
+
isScrollEnabled: true,
|
|
585
|
+
shouldAutoScrollWhenAppendingContent: false,
|
|
586
|
+
shouldLockHeightWithParent: true,
|
|
587
|
+
shouldLockWidthWithParent: true,
|
|
588
|
+
padding: { left: 1 },
|
|
589
|
+
focusable: false,
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
updateProgressBar(results) {
|
|
594
|
+
if ((results.totalTestFilesComplete ?? 0) > 0) {
|
|
595
|
+
const testsRemaining = results.totalTestFiles - (results.totalTestFilesComplete ?? 0);
|
|
596
|
+
if (testsRemaining === 0) {
|
|
597
|
+
const { percent, totalTests, totalPassedTests, totalTime } = this.generateProgressStats(results);
|
|
598
|
+
this.bar.setLabel(`Finished! ${totalPassedTests} of ${totalTests} (${percent}%) passed in ${durationUtil.msToFriendly(totalTime)}.${percent < 100 ? ` Don't give up!` : ''}`);
|
|
599
|
+
}
|
|
600
|
+
else {
|
|
601
|
+
this.bar.setLabel(`${results.totalTestFilesComplete} of ${results.totalTestFiles} (${this.generatePercentComplete(results)}%) complete. ${testsRemaining} remaining...`);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
else {
|
|
605
|
+
this.bar.setLabel('0%');
|
|
606
|
+
}
|
|
607
|
+
this.bar.setProgress(this.generatePercentComplete(results) / 100);
|
|
608
|
+
}
|
|
609
|
+
generateProgressStats(results) {
|
|
610
|
+
let totalTests = 0;
|
|
611
|
+
let totalPassedTests = 0;
|
|
612
|
+
let totalTime = 0;
|
|
613
|
+
results.testFiles?.forEach((file) => {
|
|
614
|
+
file.tests?.forEach((test) => {
|
|
615
|
+
totalTime += test.duration;
|
|
616
|
+
if (test.status === 'passed') {
|
|
617
|
+
totalPassedTests++;
|
|
618
|
+
}
|
|
619
|
+
if (test.status === 'passed' || test.status === 'failed') {
|
|
620
|
+
totalTests++;
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
const percent = Math.floor((totalPassedTests / totalTests) * 100);
|
|
625
|
+
return {
|
|
626
|
+
percent: percent > 0 ? percent : 0,
|
|
627
|
+
totalTests,
|
|
628
|
+
totalPassedTests,
|
|
629
|
+
totalTime,
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
generatePercentComplete(results) {
|
|
633
|
+
const percent = (results.totalTestFilesComplete ?? 0) / results.totalTestFiles;
|
|
634
|
+
if (isNaN(percent)) {
|
|
635
|
+
return 0;
|
|
636
|
+
}
|
|
637
|
+
return Math.round(percent * 100);
|
|
638
|
+
}
|
|
639
|
+
generatePercentPassing(results) {
|
|
640
|
+
const percent = (results.totalPassed ?? 0) / this.getTotalTestFilesRun(results);
|
|
641
|
+
if (isNaN(percent)) {
|
|
642
|
+
return 0;
|
|
643
|
+
}
|
|
644
|
+
return Math.floor(percent * 100);
|
|
645
|
+
}
|
|
646
|
+
getTotalTestFilesRun(results) {
|
|
647
|
+
return ((results.totalTests ?? 0) -
|
|
648
|
+
(results.totalSkipped ?? 0) -
|
|
649
|
+
(results.totalTodo ?? 0));
|
|
650
|
+
}
|
|
651
|
+
render() {
|
|
652
|
+
this.table?.computeCells();
|
|
653
|
+
this.table?.draw();
|
|
654
|
+
}
|
|
655
|
+
async destroy() {
|
|
656
|
+
clearInterval(this.updateInterval);
|
|
657
|
+
await this.window.destroy();
|
|
658
|
+
}
|
|
659
|
+
reset() {
|
|
660
|
+
this.testLog.setText('');
|
|
661
|
+
this.lastResults = {
|
|
662
|
+
totalTestFiles: 0,
|
|
663
|
+
customErrors: [],
|
|
664
|
+
};
|
|
665
|
+
this.errorLogItemGenerator.resetStartTimes();
|
|
666
|
+
}
|
|
667
|
+
setStatusLabel(text) {
|
|
668
|
+
this.statusBar.setText(text);
|
|
669
|
+
}
|
|
670
|
+
appendError(message) {
|
|
671
|
+
this.lastResults.customErrors.push(message);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function buildPatternButtonText(pattern) {
|
|
675
|
+
return pattern ? ' x ' : ' - ';
|
|
676
|
+
}
|
|
677
|
+
//# sourceMappingURL=TestReporter.js.map
|