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

Commite358c41

Browse files
committed
improve error formatting
1 parent9b9c55f commite358c41

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ts-ignore no declaration files
2+
import*asclcfrom'cli-color'
3+
import{ParserOutput}from'./parser'
4+
5+
// TODO: implement better success ouput
6+
// export const formatSuccessOutput = (tap: ParserOutput): string => {}
7+
8+
exportconstformatFailOutput=(tap:ParserOutput):string=>{
9+
letoutput=`'TESTS FAILED\n`
10+
tap.failed.forEach((fail)=>{
11+
constdetails=fail.details ?`\n${fail.details}\n\n` :''
12+
output+=` ✘${fail.message}\n${details}`
13+
})
14+
returnoutput
15+
}

‎src/services/testRunner/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import parser from './parser'
44
import{debounce,throttle}from'./throttle'
55
importonErrorfrom'../sentry/onError'
66
import{clearOutput,displayOutput}from'./output'
7+
import{formatFailOutput}from'./formatOutput'
78

89
exportinterfacePayload{
910
stepId:string
@@ -52,11 +53,12 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {
5253

5354
consttap=parser(stdout||'')
5455
if(stderr){
55-
//failures also trigger stderr
56+
//FAIL also trigger stderr
5657
if(stdout&&stdout.length&&!tap.ok){
57-
constmessage=tap.message ?tap.message :''
58-
callbacks.onFail(payload,message)
59-
displayOutput(stdout)
58+
constfirstFailMessage=tap.failed[0].message
59+
callbacks.onFail(payload,firstFailMessage)
60+
constoutput=formatFailOutput(tap)
61+
displayOutput(output)
6062
return
6163
}else{
6264
callbacks.onError(payload)
@@ -66,7 +68,7 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {
6668
}
6769
}
6870

69-
//success!
71+
//PASS
7072
if(tap.ok){
7173
clearOutput()
7274
callbacks.onSuccess(payload)

‎src/services/testRunner/output.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,11 @@ const getOutputChannel = (name: string): vscode.OutputChannel => {
1111

1212
constoutputChannelName='CodeRoad Output'
1313

14-
constparseOutput=(text:string):string=>{
15-
letresult=''
16-
for(constlineoftext.split(/\r?\n/)){
17-
if(line.match(/^#/)||line.match(/^notok/)){
18-
result+=line+'\n'
19-
}
20-
}
21-
returnresult
22-
}
23-
2414
exportconstdisplayOutput=(text:string)=>{
2515
constchannel=getOutputChannel(outputChannelName)
2616
channel.clear()
2717
channel.show(true)
28-
constoutput=parseOutput(text)
29-
channel.append(output)
18+
channel.append(text)
3019
}
3120

3221
exportconstclearOutput=()=>{

‎src/services/testRunner/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
interfaceParserOutput{
1+
exportinterfaceParserOutput{
22
ok:boolean
33
passed:Array<{message:string}>
44
failed:Array<{message:string;details?:string}>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp