@neurodevs/node-tdd 1.0.2 → 1.0.4
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/build/__tests__/behavioral/workspace/TestReporter.test.d.ts +11 -0
- package/build/__tests__/behavioral/workspace/TestReporter.test.js +281 -0
- package/build/__tests__/behavioral/workspace/TestReporter.test.js.map +1 -1
- package/build/__tests__/behavioral/workspace/Widgets.test.d.ts +3 -0
- package/build/__tests__/behavioral/workspace/Widgets.test.js +35 -0
- package/build/__tests__/behavioral/workspace/Widgets.test.js.map +1 -1
- package/build/workspace/JestJsonParser.js +1 -1
- package/build/workspace/JestJsonParser.js.map +1 -1
- package/build/workspace/TestReporter.js +31 -20
- package/build/workspace/TestReporter.js.map +1 -1
- package/build/workspace/TkTextWidget.d.ts +1 -0
- package/build/workspace/TkTextWidget.js +10 -2
- package/build/workspace/TkTextWidget.js.map +1 -1
- package/build/workspace/testRunner.cli.js +7 -0
- package/build/workspace/testRunner.cli.js.map +1 -1
- package/build/workspace/text.types.d.ts +1 -0
- package/package.json +1 -1
- package/src/__tests__/behavioral/workspace/TestReporter.test.ts +327 -0
- package/src/__tests__/behavioral/workspace/Widgets.test.ts +41 -0
- package/src/workspace/JestJsonParser.ts +1 -1
- package/src/workspace/TestReporter.ts +36 -21
- package/src/workspace/TkTextWidget.ts +11 -2
- package/src/workspace/testRunner.cli.ts +7 -0
- package/src/workspace/text.types.ts +1 -0
|
@@ -86,9 +86,10 @@ export default class TestReporter {
|
|
|
86
86
|
public setWatchMode(watchMode: WatchMode) {
|
|
87
87
|
this.watchMode = watchMode
|
|
88
88
|
if (!this.countDownTimeInterval) {
|
|
89
|
-
let label =
|
|
89
|
+
let label =
|
|
90
|
+
watchMode === 'smart' ? 'Smart Watch ' : 'Standard Watch'
|
|
90
91
|
if (watchMode === 'off') {
|
|
91
|
-
label = 'Not Watching'
|
|
92
|
+
label = 'Not Watching '
|
|
92
93
|
}
|
|
93
94
|
this.setWatchLabel(label)
|
|
94
95
|
}
|
|
@@ -221,7 +222,7 @@ export default class TestReporter {
|
|
|
221
222
|
value: 'toggleDebug',
|
|
222
223
|
},
|
|
223
224
|
{
|
|
224
|
-
label: 'Not Watching
|
|
225
|
+
label: 'Not Watching ',
|
|
225
226
|
value: 'watchDropdown',
|
|
226
227
|
items: [
|
|
227
228
|
{
|
|
@@ -255,6 +256,7 @@ export default class TestReporter {
|
|
|
255
256
|
this.setStatusLabel('Starting...')
|
|
256
257
|
} else if (this.status === 'stopped') {
|
|
257
258
|
this.refreshResults()
|
|
259
|
+
this.testLog?.scrollToTop()
|
|
258
260
|
this.setStatusLabel('')
|
|
259
261
|
} else if (this.status === 'running') {
|
|
260
262
|
this.setStatusLabel('Running tests...')
|
|
@@ -331,22 +333,21 @@ export default class TestReporter {
|
|
|
331
333
|
}
|
|
332
334
|
|
|
333
335
|
private dropInTestLog() {
|
|
334
|
-
const parent = this.bottomLayout.getChildById('results')
|
|
336
|
+
const parent = this.bottomLayout.getChildById('results')!
|
|
335
337
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
338
|
+
this.testLog = this.widgets.Widget('text', {
|
|
339
|
+
parent,
|
|
340
|
+
isScrollEnabled: true,
|
|
341
|
+
wordWrap: false,
|
|
342
|
+
left: 0,
|
|
343
|
+
top: 0,
|
|
344
|
+
height: '100%',
|
|
345
|
+
width: '100%',
|
|
346
|
+
shouldLockHeightWithParent: true,
|
|
347
|
+
shouldLockWidthWithParent: true,
|
|
348
|
+
})
|
|
347
349
|
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
+
void this.testLog.on('click', this.handleClickTestLog.bind(this))
|
|
350
351
|
}
|
|
351
352
|
|
|
352
353
|
private async handleClickTestLog(payload: { row: number; column: number }) {
|
|
@@ -437,7 +438,7 @@ export default class TestReporter {
|
|
|
437
438
|
top: 1,
|
|
438
439
|
height: 4,
|
|
439
440
|
width: this.selectTestPopup.getFrame().width - 2,
|
|
440
|
-
text: `
|
|
441
|
+
text: `Selected file:\n\n${testFile}`,
|
|
441
442
|
})
|
|
442
443
|
|
|
443
444
|
const open = this.widgets.Widget('button', {
|
|
@@ -481,13 +482,17 @@ export default class TestReporter {
|
|
|
481
482
|
|
|
482
483
|
for (const file of this.lastResults.testFiles ?? []) {
|
|
483
484
|
const minRow = line
|
|
484
|
-
const
|
|
485
|
+
const lineCount =
|
|
486
|
+
1 +
|
|
487
|
+
(file.tests ?? []).length +
|
|
488
|
+
(file.status === 'running' ? 1 : 0)
|
|
489
|
+
const maxRow = line + lineCount - 1
|
|
485
490
|
|
|
486
491
|
if (row >= minRow && row <= maxRow) {
|
|
487
492
|
return file.path
|
|
488
493
|
}
|
|
489
494
|
|
|
490
|
-
line = maxRow
|
|
495
|
+
line = maxRow + 1
|
|
491
496
|
}
|
|
492
497
|
|
|
493
498
|
return undefined
|
|
@@ -657,7 +662,17 @@ export default class TestReporter {
|
|
|
657
662
|
let logContent = ''
|
|
658
663
|
let errorContent = ''
|
|
659
664
|
|
|
660
|
-
results.testFiles
|
|
665
|
+
const files = [...(results.testFiles ?? [])]
|
|
666
|
+
|
|
667
|
+
if (this.status === 'stopped') {
|
|
668
|
+
files.sort((a, b) => {
|
|
669
|
+
const aFailed = a.status === 'failed' ? 0 : 1
|
|
670
|
+
const bFailed = b.status === 'failed' ? 0 : 1
|
|
671
|
+
return aFailed - bFailed
|
|
672
|
+
})
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
files.forEach((file) => {
|
|
661
676
|
logContent += this.errorLogItemGenerator.generateLogItemForFile(
|
|
662
677
|
file,
|
|
663
678
|
this.status
|
|
@@ -50,7 +50,7 @@ export default class TkTextWidget extends TkBaseWidget implements TextWidget {
|
|
|
50
50
|
|
|
51
51
|
const line = this.text.content.split('\n')[y]
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
this.emit('click', {
|
|
54
54
|
text: line,
|
|
55
55
|
row: y,
|
|
56
56
|
column: x,
|
|
@@ -71,7 +71,12 @@ export default class TkTextWidget extends TkBaseWidget implements TextWidget {
|
|
|
71
71
|
width: newFrame.width ?? oldFrame.width,
|
|
72
72
|
height: newFrame.height ?? oldFrame.height,
|
|
73
73
|
})
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
if (this.text.scrollable) {
|
|
76
|
+
this.text.scrollTo(null, this.text.scrollY)
|
|
77
|
+
} else {
|
|
78
|
+
this.text.draw()
|
|
79
|
+
}
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
public getText(): string {
|
|
@@ -93,6 +98,10 @@ export default class TkTextWidget extends TkBaseWidget implements TextWidget {
|
|
|
93
98
|
return this.text.scrollY
|
|
94
99
|
}
|
|
95
100
|
|
|
101
|
+
public scrollToTop() {
|
|
102
|
+
this.text.scrollTo(null, 0)
|
|
103
|
+
}
|
|
104
|
+
|
|
96
105
|
public getScrollX() {
|
|
97
106
|
return this.text.scrollX
|
|
98
107
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import chokidar from 'chokidar'
|
|
2
|
+
import { spawn } from 'child_process'
|
|
2
3
|
import path from 'path'
|
|
3
4
|
import CommandServiceImpl from './CommandService.js'
|
|
4
5
|
import TestReporter from './TestReporter.js'
|
|
@@ -64,6 +65,12 @@ const reporter = new TestReporter({
|
|
|
64
65
|
currentWatchMode = currentWatchMode === 'smart' ? 'off' : 'smart'
|
|
65
66
|
reporter.setWatchMode(currentWatchMode)
|
|
66
67
|
},
|
|
68
|
+
handleOpenTestFile: (filePath: string) => {
|
|
69
|
+
const fullPath = path.isAbsolute(filePath)
|
|
70
|
+
? filePath
|
|
71
|
+
: path.join(cwd, 'src', '__tests__', filePath)
|
|
72
|
+
spawn('code', [fullPath], { detached: true, stdio: 'ignore' }).unref()
|
|
73
|
+
},
|
|
67
74
|
})
|
|
68
75
|
|
|
69
76
|
async function runTests() {
|