@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.
Files changed (179) hide show
  1. package/package.json +1 -1
  2. package/.nvmrc +0 -1
  3. package/.vscode/launch.json +0 -53
  4. package/.vscode/settings.json +0 -62
  5. package/.vscode/tasks.json +0 -99
  6. package/build/__tests__/MockFetch.d.ts +0 -18
  7. package/build/__tests__/MockFetch.js +0 -55
  8. package/build/__tests__/MockFetch.js.map +0 -1
  9. package/build/__tests__/behavioral/AbstractModuleTest.test.d.ts +0 -5
  10. package/build/__tests__/behavioral/AbstractModuleTest.test.js +0 -22
  11. package/build/__tests__/behavioral/AbstractModuleTest.test.js.map +0 -1
  12. package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.d.ts +0 -5
  13. package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.js +0 -34
  14. package/build/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.js.map +0 -1
  15. package/build/__tests__/behavioral/utilities/Assert.test.d.ts +0 -45
  16. package/build/__tests__/behavioral/utilities/Assert.test.js +0 -645
  17. package/build/__tests__/behavioral/utilities/Assert.test.js.map +0 -1
  18. package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.d.ts +0 -4
  19. package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.js +0 -23
  20. package/build/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.js.map +0 -1
  21. package/build/__tests__/behavioral/utilities/MockFetch.test.d.ts +0 -28
  22. package/build/__tests__/behavioral/utilities/MockFetch.test.js +0 -211
  23. package/build/__tests__/behavioral/utilities/MockFetch.test.js.map +0 -1
  24. package/build/__tests__/behavioral/utilities/StackCleaner.test.d.ts +0 -4
  25. package/build/__tests__/behavioral/utilities/StackCleaner.test.js +0 -46
  26. package/build/__tests__/behavioral/utilities/StackCleaner.test.js.map +0 -1
  27. package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.d.ts +0 -7
  28. package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.js +0 -32
  29. package/build/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.js.map +0 -1
  30. package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.d.ts +0 -4
  31. package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.js +0 -19
  32. package/build/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.js.map +0 -1
  33. package/build/__tests__/behavioral/utilities/Stringify.test.d.ts +0 -5
  34. package/build/__tests__/behavioral/utilities/Stringify.test.js +0 -127
  35. package/build/__tests__/behavioral/utilities/Stringify.test.js.map +0 -1
  36. package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.d.ts +0 -7
  37. package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.js +0 -38
  38. package/build/__tests__/behavioral/utilities/TestDecoratorResolver.test.js.map +0 -1
  39. package/build/__tests__/behavioral/utilities/TestOnBasic.test.d.ts +0 -12
  40. package/build/__tests__/behavioral/utilities/TestOnBasic.test.js +0 -68
  41. package/build/__tests__/behavioral/utilities/TestOnBasic.test.js.map +0 -1
  42. package/build/__tests__/behavioral/utilities/TestOnInstance.test.d.ts +0 -28
  43. package/build/__tests__/behavioral/utilities/TestOnInstance.test.js +0 -289
  44. package/build/__tests__/behavioral/utilities/TestOnInstance.test.js.map +0 -1
  45. package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.d.ts +0 -9
  46. package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.js +0 -118
  47. package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.js.map +0 -1
  48. package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.d.ts +0 -5
  49. package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.js +0 -78
  50. package/build/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.js.map +0 -1
  51. package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.d.ts +0 -4
  52. package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.js +0 -23
  53. package/build/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.js.map +0 -1
  54. package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.d.ts +0 -4
  55. package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.js +0 -24
  56. package/build/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.js.map +0 -1
  57. package/build/__tests__/behavioral/utilities/TestResolver.test.d.ts +0 -7
  58. package/build/__tests__/behavioral/utilities/TestResolver.test.js +0 -38
  59. package/build/__tests__/behavioral/utilities/TestResolver.test.js.map +0 -1
  60. package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.d.ts +0 -4
  61. package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.js +0 -20
  62. package/build/__tests__/behavioral/utilities/TestResolverOnStatic.test.js.map +0 -1
  63. package/build/__tests__/behavioral/workspace/JestJsonParser.test.d.ts +0 -18
  64. package/build/__tests__/behavioral/workspace/JestJsonParser.test.js +0 -267
  65. package/build/__tests__/behavioral/workspace/JestJsonParser.test.js.map +0 -1
  66. package/build/__tests__/behavioral/workspace/TestReporter.test.d.ts +0 -27
  67. package/build/__tests__/behavioral/workspace/TestReporter.test.js +0 -508
  68. package/build/__tests__/behavioral/workspace/TestReporter.test.js.map +0 -1
  69. package/build/__tests__/behavioral/workspace/TestRunner.test.d.ts +0 -15
  70. package/build/__tests__/behavioral/workspace/TestRunner.test.js +0 -99
  71. package/build/__tests__/behavioral/workspace/TestRunner.test.js.map +0 -1
  72. package/build/__tests__/behavioral/workspace/Widgets.test.d.ts +0 -16
  73. package/build/__tests__/behavioral/workspace/Widgets.test.js +0 -134
  74. package/build/__tests__/behavioral/workspace/Widgets.test.js.map +0 -1
  75. package/build/__tests__/mock-terminal-kit.d.ts +0 -79
  76. package/build/__tests__/mock-terminal-kit.js +0 -103
  77. package/build/__tests__/mock-terminal-kit.js.map +0 -1
  78. package/build/__tests__/support/AbstractForInstanceTest.d.ts +0 -4
  79. package/build/__tests__/support/AbstractForInstanceTest.js +0 -9
  80. package/build/__tests__/support/AbstractForInstanceTest.js.map +0 -1
  81. package/build/__tests__/support/AbstractLevelOneTest.d.ts +0 -3
  82. package/build/__tests__/support/AbstractLevelOneTest.js +0 -4
  83. package/build/__tests__/support/AbstractLevelOneTest.js.map +0 -1
  84. package/build/__tests__/support/AbstractLevelTwoTest.d.ts +0 -7
  85. package/build/__tests__/support/AbstractLevelTwoTest.js +0 -14
  86. package/build/__tests__/support/AbstractLevelTwoTest.js.map +0 -1
  87. package/build/__tests__/support/AbstractStaticTest.d.ts +0 -7
  88. package/build/__tests__/support/AbstractStaticTest.js +0 -14
  89. package/build/__tests__/support/AbstractStaticTest.js.map +0 -1
  90. package/build/__tests__/support/AbstractTestOnInstanceTest.d.ts +0 -22
  91. package/build/__tests__/support/AbstractTestOnInstanceTest.js +0 -23
  92. package/build/__tests__/support/AbstractTestOnInstanceTest.js.map +0 -1
  93. package/build/__tests__/support/AbstractTestOnInstanceWithHooks.d.ts +0 -26
  94. package/build/__tests__/support/AbstractTestOnInstanceWithHooks.js +0 -59
  95. package/build/__tests__/support/AbstractTestOnInstanceWithHooks.js.map +0 -1
  96. package/build/__tests__/support/jest.setup.d.ts +0 -1
  97. package/build/__tests__/support/jest.setup.js +0 -4
  98. package/build/__tests__/support/jest.setup.js.map +0 -1
  99. package/build/__tests__/support/onTestFileResult.d.ts +0 -244
  100. package/build/__tests__/support/onTestFileResult.js +0 -980
  101. package/build/__tests__/support/onTestFileResult.js.map +0 -1
  102. package/eslint.config.js +0 -3
  103. package/prettier.config.js +0 -3
  104. package/src/.spruce/settings.json +0 -4
  105. package/src/__tests__/MockFetch.ts +0 -100
  106. package/src/__tests__/behavioral/AbstractModuleTest.test.ts +0 -15
  107. package/src/__tests__/behavioral/utilities/AllHooksCalledEvenIfNotDefined.test.ts +0 -31
  108. package/src/__tests__/behavioral/utilities/Assert.test.ts +0 -826
  109. package/src/__tests__/behavioral/utilities/InstanceParentTestCanAccessParentMethods.test.ts +0 -14
  110. package/src/__tests__/behavioral/utilities/MockFetch.test.ts +0 -240
  111. package/src/__tests__/behavioral/utilities/StackCleaner.test.ts +0 -46
  112. package/src/__tests__/behavioral/utilities/StaticParentTestCanAccessParentMethods.test.ts +0 -34
  113. package/src/__tests__/behavioral/utilities/StaticTestInheritsAbstractSpruceTestProperly.test.ts +0 -11
  114. package/src/__tests__/behavioral/utilities/Stringify.test.ts +0 -169
  115. package/src/__tests__/behavioral/utilities/TestDecoratorResolver.test.ts +0 -51
  116. package/src/__tests__/behavioral/utilities/TestOnBasic.test.ts +0 -62
  117. package/src/__tests__/behavioral/utilities/TestOnInstance.test.ts +0 -439
  118. package/src/__tests__/behavioral/utilities/TestOnInstanceExtendsTest.test.ts +0 -237
  119. package/src/__tests__/behavioral/utilities/TestOnInstanceExtendsTestWithHooks.test.ts +0 -85
  120. package/src/__tests__/behavioral/utilities/TestOnInstanceWithParentBeforeAll.test.ts +0 -14
  121. package/src/__tests__/behavioral/utilities/TestOnInstanceWithTwoLevelsOfInheritence.test.ts +0 -16
  122. package/src/__tests__/behavioral/utilities/TestResolver.test.ts +0 -48
  123. package/src/__tests__/behavioral/utilities/TestResolverOnStatic.test.ts +0 -12
  124. package/src/__tests__/behavioral/workspace/JestJsonParser.test.ts +0 -357
  125. package/src/__tests__/behavioral/workspace/TestReporter.test.ts +0 -584
  126. package/src/__tests__/behavioral/workspace/TestRunner.test.ts +0 -87
  127. package/src/__tests__/behavioral/workspace/Widgets.test.ts +0 -131
  128. package/src/__tests__/mock-terminal-kit.ts +0 -115
  129. package/src/__tests__/support/AbstractForInstanceTest.ts +0 -12
  130. package/src/__tests__/support/AbstractLevelOneTest.ts +0 -3
  131. package/src/__tests__/support/AbstractLevelTwoTest.ts +0 -16
  132. package/src/__tests__/support/AbstractStaticTest.ts +0 -16
  133. package/src/__tests__/support/AbstractTestOnInstanceTest.ts +0 -30
  134. package/src/__tests__/support/AbstractTestOnInstanceWithHooks.ts +0 -138
  135. package/src/__tests__/support/jest.setup.ts +0 -2
  136. package/src/__tests__/support/onTestFileResult.ts +0 -1008
  137. package/src/impl/AbstractModuleTest.ts +0 -67
  138. package/src/index.ts +0 -12
  139. package/src/utilities/AssertionError.ts +0 -14
  140. package/src/utilities/StackCleaner.ts +0 -14
  141. package/src/utilities/TestDecoratorResolver.ts +0 -118
  142. package/src/utilities/assert.ts +0 -583
  143. package/src/utilities/assert.utility.ts +0 -295
  144. package/src/utilities/decorators.ts +0 -167
  145. package/src/workspace/CommandService.ts +0 -256
  146. package/src/workspace/JestJsonParser.ts +0 -255
  147. package/src/workspace/TKButtonWidget.ts +0 -54
  148. package/src/workspace/TestLogItemGenerator.ts +0 -184
  149. package/src/workspace/TestReporter.ts +0 -880
  150. package/src/workspace/TestRunner.ts +0 -128
  151. package/src/workspace/TkBaseWidget.ts +0 -249
  152. package/src/workspace/TkInputWidget.ts +0 -83
  153. package/src/workspace/TkLayoutCellWidget.ts +0 -46
  154. package/src/workspace/TkLayoutWidget.ts +0 -181
  155. package/src/workspace/TkMenuBarWidget.ts +0 -95
  156. package/src/workspace/TkPopupWidget.ts +0 -47
  157. package/src/workspace/TkProgressBarWidget.ts +0 -54
  158. package/src/workspace/TkTextWidget.ts +0 -167
  159. package/src/workspace/TkWindowWidget.ts +0 -122
  160. package/src/workspace/WidgetFactory.ts +0 -33
  161. package/src/workspace/button.types.ts +0 -19
  162. package/src/workspace/duration.utility.ts +0 -34
  163. package/src/workspace/factory.types.ts +0 -101
  164. package/src/workspace/input.types.ts +0 -22
  165. package/src/workspace/keySelectChoices.ts +0 -134
  166. package/src/workspace/layout.types.ts +0 -40
  167. package/src/workspace/menuBar.types.ts +0 -24
  168. package/src/workspace/popup.types.ts +0 -17
  169. package/src/workspace/progressBar.types.ts +0 -13
  170. package/src/workspace/table.types.ts +0 -9
  171. package/src/workspace/termKit.utility.ts +0 -130
  172. package/src/workspace/terminal-kit.d.ts +0 -28
  173. package/src/workspace/test.types.ts +0 -34
  174. package/src/workspace/testRunner.cli.ts +0 -166
  175. package/src/workspace/text.types.ts +0 -27
  176. package/src/workspace/widget.utilities.ts +0 -35
  177. package/src/workspace/widgets.types.ts +0 -102
  178. package/src/workspace/window.types.ts +0 -22
  179. package/tsconfig.json +0 -24
@@ -1,584 +0,0 @@
1
- import AbstractModuleTest from '../../../impl/AbstractModuleTest.js'
2
- import test from '../../../utilities/decorators.js'
3
- import assert from '../../../utilities/assert.js'
4
- import TestReporter, {
5
- TestReporterOptions,
6
- } from '../../../workspace/TestReporter.js'
7
-
8
- export default class TestReporterTest extends AbstractModuleTest {
9
- @test()
10
- protected static async canInstantiateTestReporter() {
11
- const reporter = this.TestReporter()
12
- assert.isTruthy(reporter)
13
- }
14
-
15
- @test()
16
- protected static async canInstantiateWithOptions() {
17
- const reporter = this.TestReporter({
18
- cwd: this.cwd,
19
- watchMode: 'off',
20
- status: 'ready',
21
- isDebugging: false,
22
- })
23
- assert.isTruthy(reporter)
24
- }
25
-
26
- @test()
27
- protected static async hasStartMethod() {
28
- const reporter = this.TestReporter()
29
- assert.isFunction(reporter.start)
30
- }
31
-
32
- @test()
33
- protected static async hasDestroyMethod() {
34
- const reporter = this.TestReporter()
35
- assert.isFunction(reporter.destroy)
36
- }
37
-
38
- @test()
39
- protected static async hasUpdateResultsMethod() {
40
- const reporter = this.TestReporter()
41
- assert.isFunction(reporter.updateResults)
42
- }
43
-
44
- @test()
45
- protected static async hasSetStatusMethod() {
46
- const reporter = this.TestReporter()
47
- assert.isFunction(reporter.setStatus)
48
- }
49
-
50
- @test()
51
- protected static async hasResetMethod() {
52
- const reporter = this.TestReporter()
53
- assert.isFunction(reporter.reset)
54
- }
55
-
56
- @test()
57
- protected static async hasAppendErrorMethod() {
58
- const reporter = this.TestReporter()
59
- assert.isFunction(reporter.appendError)
60
- }
61
-
62
- @test()
63
- protected static async throwsIfUpdateResultsCalledBeforeStart() {
64
- const reporter = this.TestReporter()
65
- assert.doesThrow(() => {
66
- reporter.updateResults({ totalTestFiles: 0 })
67
- })
68
- }
69
-
70
- @test()
71
- protected static async doesNotDestroyOnUncaughtException() {
72
- const reporter = this.TestReporter()
73
- let destroyCalled = false
74
- let killHandler: ((payload: { code: any }) => void) | undefined
75
-
76
- const fakeWidget: any = new Proxy(
77
- {},
78
- {
79
- get: (_t, prop: string) => {
80
- if (prop === 'getFrame') {
81
- return () => ({
82
- left: 0,
83
- top: 0,
84
- width: 100,
85
- height: 50,
86
- })
87
- }
88
- if (prop === 'getChildById') {
89
- return () => null
90
- }
91
- if (prop === 'getRows') {
92
- return () => [{}]
93
- }
94
- if (prop === 'getFocusedWidget') {
95
- return () => null
96
- }
97
- if (prop === 'on') {
98
- return (event: string, handler: any) => {
99
- if (event === 'kill') {
100
- killHandler = handler
101
- }
102
- }
103
- }
104
- return () => fakeWidget
105
- },
106
- }
107
- )
108
-
109
- reporter.widgets = { Widget: () => fakeWidget }
110
- reporter.destroy = async () => {
111
- destroyCalled = true
112
- }
113
-
114
- await reporter.start()
115
-
116
- assert.isTruthy(killHandler, 'kill handler must be registered')
117
-
118
- killHandler!({
119
- code: new Error('terminal-kit mouse boundary crash'),
120
- })
121
- assert.isFalse(
122
- destroyCalled,
123
- 'uncaughtException must not destroy the UI'
124
- )
125
-
126
- killHandler!({ code: 0 })
127
- assert.isTrue(
128
- destroyCalled,
129
- 'real exit signal must still destroy the UI'
130
- )
131
-
132
- clearInterval(reporter.updateInterval)
133
- }
134
-
135
- @test()
136
- protected static async grabsInputToResetMouseStateAfterCrash() {
137
- const reporter = this.TestReporter()
138
- let destroyCalled = false
139
- let grabInputCalled = false
140
- let killHandler: ((payload: { code: any }) => void) | undefined
141
-
142
- const fakeTerm = {
143
- grabInput: () => {
144
- grabInputCalled = true
145
- },
146
- }
147
-
148
- const fakeWidget: any = new Proxy(
149
- {},
150
- {
151
- get: (_t, prop: string) => {
152
- if (prop === 'getFrame') {
153
- return () => ({
154
- left: 0,
155
- top: 0,
156
- width: 100,
157
- height: 50,
158
- })
159
- }
160
- if (prop === 'getChildById') {
161
- return () => null
162
- }
163
- if (prop === 'getRows') {
164
- return () => [{}]
165
- }
166
- if (prop === 'getFocusedWidget') {
167
- return () => null
168
- }
169
- if (prop === 'term') {
170
- return fakeTerm
171
- }
172
- if (prop === 'on') {
173
- return (event: string, handler: any) => {
174
- if (event === 'kill') {
175
- killHandler = handler
176
- }
177
- }
178
- }
179
- return () => fakeWidget
180
- },
181
- }
182
- )
183
-
184
- reporter.widgets = { Widget: () => fakeWidget }
185
- reporter.destroy = async () => {
186
- destroyCalled = true
187
- }
188
-
189
- await reporter.start()
190
-
191
- assert.isTruthy(killHandler, 'kill handler must be registered')
192
-
193
- killHandler!({
194
- code: new Error('terminal-kit mouse boundary crash'),
195
- })
196
- assert.isFalse(
197
- destroyCalled,
198
- 'uncaughtException must not destroy the UI'
199
- )
200
-
201
- killHandler!({ code: 0 })
202
- assert.isTrue(
203
- destroyCalled,
204
- 'real exit signal must still destroy the UI'
205
- )
206
-
207
- assert.isTrue(
208
- grabInputCalled,
209
- 'grabInput must be called to reset mouse state after terminal crash'
210
- )
211
-
212
- clearInterval(reporter.updateInterval)
213
- }
214
-
215
- @test()
216
- protected static async errorLogIsCreatedWithFocusableSetToFalse() {
217
- const reporter = this.TestReporter() as any
218
- let capturedTextOptions: any
219
-
220
- const fakeCell = { getFrame: () => ({ width: 100, height: 50 }) }
221
-
222
- reporter.orientation = 'landscape'
223
-
224
- reporter.bottomLayout = {
225
- getRows: () => [{ id: 'row_1' }],
226
- addColumn: () => {},
227
- setColumnWidth: () => {},
228
- updateLayout: () => {},
229
- getChildById: (id: string) => {
230
- return id === 'errors' ? fakeCell : null
231
- },
232
- }
233
-
234
- reporter.widgets = {
235
- Widget: (type: string, options: any) => {
236
- if (type === 'text') {
237
- capturedTextOptions = options
238
- }
239
- return {
240
- on: () => {},
241
- getFrame: () => ({ width: 100, height: 50 }),
242
- }
243
- },
244
- }
245
-
246
- reporter.dropInErrorLog()
247
-
248
- assert.isFalse(
249
- capturedTextOptions?.focusable,
250
- 'errorLog must be created with focusable: false to prevent UI lockup on click'
251
- )
252
- }
253
-
254
- @test()
255
- protected static async setWatchModeSetsSmartWatchLabel() {
256
- const reporter = this.TestReporter()
257
- const captured: Record<string, string> = {}
258
- reporter.menu = this.fakeMenu(captured)
259
- reporter.setWatchMode('smart')
260
- assert.isEqual(captured['watchDropdown'], 'Smart Watch ^k^#^g • ^')
261
- }
262
-
263
- @test()
264
- protected static async setWatchModeSetsStandardWatchLabel() {
265
- const reporter = this.TestReporter()
266
- const captured: Record<string, string> = {}
267
- reporter.menu = this.fakeMenu(captured)
268
- reporter.setWatchMode('standard')
269
- assert.isEqual(captured['watchDropdown'], 'Standard Watch ^k^#^g • ^')
270
- }
271
-
272
- @test()
273
- protected static async setWatchModeSetsNotWatchingLabel() {
274
- const reporter = this.TestReporter()
275
- const captured: Record<string, string> = {}
276
- reporter.menu = this.fakeMenu(captured)
277
- reporter.setWatchMode('off')
278
- assert.isEqual(captured['watchDropdown'], 'Not Watching ^w^#^r • ^')
279
- }
280
-
281
- @test()
282
- protected static async setWatchModeSkipsLabelUpdateWhenCountdownActive() {
283
- const reporter = this.TestReporter()
284
- const captured: Record<string, string> = {}
285
- reporter.menu = this.fakeMenu(captured)
286
- reporter.countDownTimeInterval = setInterval(() => {}, 10000)
287
- reporter.setWatchMode('smart')
288
- clearInterval(reporter.countDownTimeInterval)
289
- assert.isUndefined(
290
- captured['watchDropdown'],
291
- 'label must not update during countdown'
292
- )
293
- }
294
-
295
- @test()
296
- protected static async createsDropInMenuWidgetOnStart() {
297
- const reporter = this.TestReporter() as any
298
- let capturedMenuBarOptions: any
299
-
300
- const fakeWidget: any = new Proxy(
301
- {},
302
- {
303
- get: (_t, prop: string) => {
304
- if (prop === 'getFrame') {
305
- return () => ({
306
- left: 0,
307
- top: 0,
308
- width: 100,
309
- height: 50,
310
- })
311
- }
312
- if (prop === 'getChildById') {
313
- return () => null
314
- }
315
- if (prop === 'getRows') {
316
- return () => [{}]
317
- }
318
- if (prop === 'getFocusedWidget') {
319
- return () => null
320
- }
321
- if (prop === 'on') {
322
- return () => fakeWidget
323
- }
324
- return () => fakeWidget
325
- },
326
- }
327
- )
328
-
329
- reporter.widgets = {
330
- Widget: (type: string, options: any) => {
331
- if (type === 'menuBar') {
332
- capturedMenuBarOptions = options
333
- }
334
- return fakeWidget
335
- },
336
- }
337
-
338
- await reporter.start()
339
-
340
- assert.isEqualDeep(capturedMenuBarOptions, {
341
- parent: reporter.window,
342
- left: 0,
343
- top: 0,
344
- shouldLockWidthWithParent: true,
345
- items: [
346
- {
347
- label: 'Restart ',
348
- value: 'restart',
349
- },
350
- {
351
- label: 'Debug ',
352
- value: 'toggleDebug',
353
- },
354
- {
355
- label: 'Not Watching ',
356
- value: 'watchDropdown',
357
- items: [
358
- {
359
- label: 'Watch all',
360
- value: 'toggleStandardWatch',
361
- },
362
- {
363
- label: 'Smart watch',
364
- value: 'toggleSmartWatch',
365
- },
366
- ],
367
- },
368
- {
369
- label: 'Quit',
370
- value: 'quit',
371
- },
372
- ],
373
- })
374
-
375
- clearInterval(reporter.updateInterval)
376
- }
377
-
378
- @test()
379
- protected static async createsTestLogWidgetOnStart() {
380
- const reporter = this.TestReporter() as any
381
- let capturedTextOptions: { type: string; options: any }[] = []
382
-
383
- const fakeWidget: any = new Proxy(
384
- {},
385
- {
386
- get: (_t, prop: string) => {
387
- if (prop === 'getFrame') {
388
- return () => ({
389
- left: 0,
390
- top: 0,
391
- width: 100,
392
- height: 50,
393
- })
394
- }
395
- if (prop === 'getChildById') {
396
- return () => null
397
- }
398
- if (prop === 'getRows') {
399
- return () => [{}]
400
- }
401
- if (prop === 'getFocusedWidget') {
402
- return () => null
403
- }
404
- if (prop === 'on') {
405
- return () => fakeWidget
406
- }
407
- return () => fakeWidget
408
- },
409
- }
410
- )
411
-
412
- reporter.widgets = {
413
- Widget: (type: string, options: any) => {
414
- capturedTextOptions.push({ type, options })
415
- return fakeWidget
416
- },
417
- }
418
-
419
- await reporter.start()
420
-
421
- const expectedOptions = {
422
- isScrollEnabled: true,
423
- wordWrap: false,
424
- left: 0,
425
- top: 0,
426
- height: '100%',
427
- width: '100%',
428
- shouldLockHeightWithParent: true,
429
- shouldLockWidthWithParent: true,
430
- } as any
431
-
432
- const entry = capturedTextOptions.find(
433
- (o) =>
434
- o.type === 'text' &&
435
- Object.keys(expectedOptions).every(
436
- (k) => o.options[k] === expectedOptions[k]
437
- )
438
- )
439
-
440
- assert.isTruthy(entry, 'Test log widget must be created on start')
441
-
442
- clearInterval(reporter.updateInterval)
443
- }
444
-
445
- @test()
446
- protected static async createsSelectTestPopupWidgetOnStart() {
447
- const reporter = this.TestReporter() as any
448
- const capturedTextOptions: { type: string; options: any }[] = []
449
- const popupWidth = 50
450
-
451
- const fakePopup = {
452
- getFrame: () => ({ width: popupWidth }),
453
- on: () => fakePopup,
454
- }
455
-
456
- const fakeButton = { on: () => fakeButton }
457
-
458
- reporter.window = {}
459
- reporter.widgets = {
460
- Widget: (type: string, options: any) => {
461
- capturedTextOptions.push({ type, options })
462
- if (type === 'popup') {
463
- return fakePopup
464
- }
465
- return fakeButton
466
- },
467
- }
468
-
469
- reporter.dropInSelectTestPopup({
470
- testFile: 'src/foo/bar.test.ts',
471
- row: 10,
472
- column: 30,
473
- })
474
-
475
- const entry = capturedTextOptions.find(
476
- (o) =>
477
- o.type === 'text' &&
478
- o.options?.text?.startsWith('Selected file:')
479
- )
480
-
481
- assert.isTruthy(entry, 'popup text widget must be created')
482
-
483
- const { parent: _parent, ...restOptions } = entry!.options
484
-
485
- assert.isEqualDeep(restOptions, {
486
- left: 1,
487
- top: 1,
488
- height: 4,
489
- width: popupWidth - 2,
490
- text: 'Selected file:\n\nsrc/foo/bar.test.ts',
491
- })
492
- }
493
-
494
- @test()
495
- protected static async scrollsToTopWhenStatusSetToStopped() {
496
- const reporter = this.TestReporter() as any
497
- let scrollToTopCalled = false
498
-
499
- reporter.menu = this.fakeMenu({})
500
- reporter.bottomLayout = { updateLayout: () => {} }
501
- reporter.statusBar = { setText: () => {} }
502
- reporter.testLog = {
503
- scrollToTop: () => {
504
- scrollToTopCalled = true
505
- },
506
- setText: () => {},
507
- getText: () => '',
508
- }
509
-
510
- reporter.setStatus('stopped')
511
-
512
- assert.isTrue(
513
- scrollToTopCalled,
514
- 'scrollToTop must be called when status is stopped'
515
- )
516
- }
517
-
518
- @test()
519
- protected static async getFileForLineReturnsCorrectFileForRow() {
520
- const reporter = this.TestReporter() as any
521
-
522
- reporter.lastResults = {
523
- testFiles: [
524
- {
525
- path: 'file1.ts',
526
- status: 'passed',
527
- tests: [{ name: 'test1' }, { name: 'test2' }],
528
- },
529
- {
530
- path: 'file2.ts',
531
- status: 'passed',
532
- tests: [{ name: 'test3' }],
533
- },
534
- ],
535
- }
536
-
537
- reporter.testLog = { getScrollY: () => 0 }
538
-
539
- // file1: rows 0–2 (header + 2 tests), file2: rows 3–4 (header + 1 test)
540
- assert.isEqual(reporter.getFileForLine(0), 'file1.ts') // header
541
- assert.isEqual(reporter.getFileForLine(2), 'file1.ts') // last test
542
- assert.isEqual(reporter.getFileForLine(3), 'file2.ts') // file2 header
543
- assert.isEqual(reporter.getFileForLine(4), 'file2.ts') // file2 last test
544
- assert.isEqual(reporter.getFileForLine(5), undefined) // out of range
545
- }
546
-
547
- @test()
548
- protected static async sortsFailedFilesToTopWhenStopped() {
549
- const reporter = this.TestReporter() as any
550
-
551
- reporter.status = 'stopped'
552
- reporter.lastResults = { customErrors: [] }
553
-
554
- const results = {
555
- testFiles: [
556
- { path: 'passing.ts', status: 'passed', tests: [] },
557
- { path: 'failing.ts', status: 'failed', tests: [] },
558
- ],
559
- }
560
-
561
- const { logContent } = reporter.resultsToLogContents(results)
562
-
563
- const failingIdx = logContent.indexOf('failing.ts')
564
- const passingIdx = logContent.indexOf('passing.ts')
565
-
566
- assert.isBelow(
567
- failingIdx,
568
- passingIdx,
569
- 'Failed file must appear before passing file when stopped'
570
- )
571
- }
572
-
573
- private static fakeMenu(captured: Record<string, string>) {
574
- return {
575
- setTextForItem: (key: string, label: string) => {
576
- captured[key] = label
577
- },
578
- }
579
- }
580
-
581
- private static TestReporter(options?: TestReporterOptions) {
582
- return new TestReporter(options) as any
583
- }
584
- }
@@ -1,87 +0,0 @@
1
- import AbstractModuleTest from '../../../impl/AbstractModuleTest.js'
2
- import test from '../../../utilities/decorators.js'
3
- import assert from '../../../utilities/assert.js'
4
- import TestRunner from '../../../workspace/TestRunner.js'
5
- import CommandServiceImpl from '../../../workspace/CommandService.js'
6
-
7
- export default class TestRunnerTest extends AbstractModuleTest {
8
- private static runner: TestRunner
9
-
10
- protected static async beforeEach() {
11
- await super.beforeEach()
12
- const commandService = new CommandServiceImpl(this.cwd)
13
- this.runner = new TestRunner({ cwd: this.cwd, commandService })
14
- }
15
-
16
- @test()
17
- protected static async canInstantiateTestRunner() {
18
- assert.isTruthy(this.runner)
19
- }
20
-
21
- @test()
22
- protected static async hasHasFailedTestsMethod() {
23
- assert.isFunction(this.runner.hasFailedTests)
24
- }
25
-
26
- @test()
27
- protected static async hasHasSkippedTestsMethod() {
28
- assert.isFunction(this.runner.hasSkippedTests)
29
- }
30
-
31
- @test()
32
- protected static async hasKillMethod() {
33
- assert.isFunction(this.runner.kill)
34
- }
35
-
36
- @test()
37
- protected static async hasRunMethod() {
38
- assert.isFunction(this.runner.run)
39
- }
40
-
41
- @test()
42
- protected static async hasFailedTestsReturnsFalseByDefault() {
43
- assert.isFalse(this.runner.hasFailedTests())
44
- }
45
-
46
- @test()
47
- protected static async hasSkippedTestsReturnsFalseByDefault() {
48
- assert.isFalse(this.runner.hasSkippedTests())
49
- }
50
-
51
- @test()
52
- protected static async emitsDidUpdateEvent() {
53
- let emitted = false
54
- this.runner.on('did-update', () => {
55
- emitted = true
56
- })
57
- assert.isFalse(emitted)
58
- this.runner.emit('did-update', { results: { totalTestFiles: 0 } })
59
- assert.isTrue(emitted)
60
- }
61
-
62
- @test()
63
- protected static async emitsDidErrorEvent() {
64
- let errorMessage = ''
65
- this.runner.on('did-error', (payload: { message: string }) => {
66
- errorMessage = payload.message
67
- })
68
- this.runner.emit('did-error', { message: 'test error' })
69
- assert.isEqual(errorMessage, 'test error')
70
- }
71
-
72
- @test()
73
- protected static async passesNodeNoWarningsToCommandService() {
74
- let capturedEnv: Record<string, any> | undefined
75
-
76
- const commandService = new CommandServiceImpl(this.cwd)
77
- commandService.execute = async (_cmd: string, options?: any) => {
78
- capturedEnv = options?.env
79
- return { stdout: '' }
80
- }
81
-
82
- const runner = new TestRunner({ cwd: this.cwd, commandService })
83
- await runner.run()
84
-
85
- assert.isEqual(capturedEnv?.NODE_NO_WARNINGS, '1')
86
- }
87
- }