Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee86204

Browse files
committed
create test runner fail summary
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent6cc4572 commitee86204

File tree

6 files changed

+35
-8
lines changed

6 files changed

+35
-8
lines changed

‎src/services/testRunner/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as T from 'typings'
22
import*asTTfrom'typings/tutorial'
33
import{exec}from'../node'
44
importloggerfrom'../logger'
5-
importparserfrom'./parser'
5+
importparser,{ParserOutput}from'./parser'
66
import{debounce,throttle}from'./throttle'
77
importonErrorfrom'../sentry/onError'
88
import{clearOutput,addOutput}from'./output'
@@ -49,7 +49,7 @@ const createTestRunner = (config: TT.TutorialTestRunnerConfig, callbacks: Callba
4949

5050
const{ stdout, stderr}=result
5151

52-
consttap=parser(stdout||'')
52+
consttap:ParserOutput=parser(stdout||'')
5353

5454
addOutput({channel:logChannelName,text:tap.logs.join('\n'),show:false})
5555

@@ -60,6 +60,7 @@ const createTestRunner = (config: TT.TutorialTestRunnerConfig, callbacks: Callba
6060
constfailSummary={
6161
title:firstFail.message||'Test Failed',
6262
description:firstFail.details||'Unknown error',
63+
summary:tap.summary,
6364
}
6465
callbacks.onFail(position,failSummary)
6566
constoutput=formatFailOutput(tap)

‎src/services/testRunner/parser.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ describe('parser', () => {
66
1..1
77
ok 1 - Should pass
88
`
9-
expect(parser(example)).toEqual({ok:true,passed:[{message:'Should pass'}],failed:[],logs:[]})
9+
expect(parser(example)).toEqual({
10+
ok:true,
11+
passed:[{message:'Should pass'}],
12+
failed:[],
13+
logs:[],
14+
summary:{'Should pass':true},
15+
})
1016
})
1117
test('should detect multiple successes',()=>{
1218
constexample=`
@@ -20,6 +26,10 @@ ok 2 - Should also pass
2026
passed:[{message:'Should pass'},{message:'Should also pass'}],
2127
failed:[],
2228
logs:[],
29+
summary:{
30+
'Should pass':true,
31+
'Should also pass':true,
32+
},
2333
})
2434
})
2535
test('should detect failure if no tests passed',()=>{
@@ -170,6 +180,10 @@ at processImmediate (internal/timers.js:439:21)`,
170180
},
171181
],
172182
logs:['log 1','log 2'],
183+
summary:{
184+
'package.json should have "express" installed':true,
185+
'server should log "Hello World"':false,
186+
},
173187
})
174188
})
175189
})

‎src/services/testRunner/parser.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
importloggerfrom'../logger'
2+
13
exportinterfaceFail{
24
message:string
35
details?:string
@@ -14,6 +16,7 @@ export interface ParserOutput {
1416
passed:Pass[]
1517
failed:Fail[]
1618
logs:string[]
19+
summary:{[key:string]:boolean}
1720
}
1821

1922
constr={
@@ -37,6 +40,7 @@ const parser = (text: string): ParserOutput => {
3740
passed:[],
3841
failed:[],
3942
logs:[],
43+
summary:{},
4044
}
4145

4246
// temporary holder of error detail strings
@@ -58,12 +62,14 @@ const parser = (text: string): ParserOutput => {
5862
// be optimistic! check for success
5963
constisPass=detect('pass',line)
6064
if(!!isPass){
61-
constpass:Pass={message:isPass[2].trim()}
65+
constmessage=isPass[2].trim()
66+
constpass:Pass={ message}
6267
if(logs.length){
6368
pass.logs=logs
6469
logs=[]
6570
}
6671
result.passed.push(pass)
72+
result.summary[message]=true
6773
addCurrentDetails()
6874
continue
6975
}
@@ -73,12 +79,14 @@ const parser = (text: string): ParserOutput => {
7379
if(!!isFail){
7480
result.ok=false
7581
addCurrentDetails()
76-
constfail:Fail={message:isFail[2].trim()}
82+
constmessage=isFail[2].trim()
83+
constfail:Fail={ message}
7784
if(logs.length){
7885
fail.logs=logs
7986
logs=[]
8087
}
8188
result.failed.push(fail)
89+
result.summary[message]=false
8290
continue
8391
}
8492

‎typings/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export interface TestStatus {
4242
type:'success'|'warning'|'error'|'loading'
4343
title:string
4444
content?:string
45+
summary?:{[testName:string]:boolean}
4546
timeout?:number
4647
}
4748

@@ -121,4 +122,5 @@ export interface ProcessEvent {
121122
exporttypeTestFail={
122123
title:string
123124
description:string
125+
summary:{[testName:string]:boolean}
124126
}

‎typings/tutorial.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ export type TutorialSummary = {
4545
}
4646

4747
exporttypeStepActions={
48-
commands:string[]
48+
commands?:string[]
4949
commits:string[]
50-
files:string[]
51-
watchers:string[]
50+
files?:string[]
51+
watchers?:string[]
52+
subtasks?:string[]
5253
}
5354

5455
exportinterfaceTutorialTestRunnerConfig{

‎web-app/src/services/state/actions/testNotify.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const testActions: ActionFunctionMap<CR.MachineContext, CR.MachineEvent> = {
2222
type:'warning',
2323
title:event.payload.fail.title,
2424
content:event.payload.fail.description,
25+
summary:event.payload.fail.summary,
2526
}),
2627
}),
2728
//@ts-ignore

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp