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

Commit15b542d

Browse files
committed
fix parser
1 parent9d16b85 commit15b542d

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,32 @@ not ok 4 - Second to fail
3939
`
4040
expect(parser(example).message).toBe('First to fail')
4141
})
42+
43+
test('should parse mocha tap example',()=>{
44+
constexample=`
45+
1..3
46+
ok 1 itemList data should not be changed
47+
ok 2 sumItems shouldn't return NaN
48+
ok 3 sumItems should total numbers accurately
49+
# tests 3
50+
# pass 3
51+
# fail 0
52+
# skip 0
53+
`
54+
expect(parser(example).ok).toBe(true)
55+
})
56+
57+
test('should return failure message for mocha tap example',()=>{
58+
constexample=`
59+
1..3
60+
ok 1 itemList data should not be changed
61+
not ok 2 sumItems shouldn't return NaN
62+
ok 3 sumItems should total numbers accurately
63+
# tests 3
64+
# pass 2
65+
# fail 1
66+
# skip 0
67+
`
68+
expect(parser(example).message).toBe("sumItems shouldn't return NaN")
69+
})
4270
})

‎src/services/testRunner/parser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ interface ParserOutput {
33
message?:string
44
}
55

6-
constfail=/^notok\d+.{1}(.+)+$/
7-
constok=/^ok\d+.{1}/
6+
constfail=/^notok\d+\s(\-\s)?(.+)+$/
7+
constok=/^ok/
88

99
constparser=(text:string):ParserOutput=>{
1010
constlines=text.split('\n')
@@ -14,7 +14,7 @@ const parser = (text: string): ParserOutput => {
1414
// parse failed test
1515
constfailRegex=fail.exec(line)
1616
if(!!failRegex){
17-
return{ok:false,message:failRegex[1]}
17+
return{ok:false,message:failRegex[2]}
1818
}
1919
if(!hasPass){
2020
if(!!ok.exec(line)){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp