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

Commit267f752

Browse files
committed
add test failure details
1 parente61c14d commit267f752

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

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

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ ok 3 sumItems should total numbers accurately
7474
`
7575
expect(parser(example).fails).toEqual([{message:"sumItems shouldn't return NaN"}])
7676
})
77-
test('should capture error details',()=>{
77+
test('should capturesingleerror details',()=>{
7878
constexample=`
7979
not ok 1 package.json should have a valid "author" key
8080
# AssertionError [ERR_ASSERTION]: no "author" key provided
@@ -91,4 +91,49 @@ not ok 1 package.json should have a valid "author" key
9191
at Context.<anonymous> (test/packagejson.test.js:11:12)
9292
at processImmediate (internal/timers.js:439:21)`)
9393
})
94+
test('should capture multiple error details',()=>{
95+
constexample=`
96+
not ok 1 package.json should have a valid "author" key
97+
# AssertionError [ERR_ASSERTION]: no "author" key provided
98+
# at Context.<anonymous> (test/packagejson.test.js:11:12)
99+
# at processImmediate (internal/timers.js:439:21)
100+
not ok 2 package.json should have a valid "description" key
101+
# AssertionError [ERR_ASSERTION]: no "description" key provided
102+
# tests 1
103+
# pass 0
104+
# fail 1
105+
# skip 0
106+
`
107+
constresult=parser(example)
108+
expect(result.fails[0].message).toBe('package.json should have a valid "author" key')
109+
expect(result.fails[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
110+
at Context.<anonymous> (test/packagejson.test.js:11:12)
111+
at processImmediate (internal/timers.js:439:21)`)
112+
expect(result.fails[1].message).toBe('package.json should have a valid "description" key')
113+
expect(result.fails[1].details).toBe(`AssertionError [ERR_ASSERTION]: no "description" key provided`)
114+
})
115+
test('should capture multiple error details between successes',()=>{
116+
constexample=`
117+
ok 1 first passing test
118+
not ok 2 package.json should have a valid "author" key
119+
# AssertionError [ERR_ASSERTION]: no "author" key provided
120+
# at Context.<anonymous> (test/packagejson.test.js:11:12)
121+
# at processImmediate (internal/timers.js:439:21)
122+
ok 3 some passing test
123+
not ok 4 package.json should have a valid "description" key
124+
# AssertionError [ERR_ASSERTION]: no "description" key provided
125+
ok 5 some passing test
126+
# tests 1
127+
# pass 0
128+
# fail 1
129+
# skip 0
130+
`
131+
constresult=parser(example)
132+
expect(result.fails[0].message).toBe('package.json should have a valid "author" key')
133+
expect(result.fails[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
134+
at Context.<anonymous> (test/packagejson.test.js:11:12)
135+
at processImmediate (internal/timers.js:439:21)`)
136+
expect(result.fails[1].message).toBe('package.json should have a valid "description" key')
137+
expect(result.fails[1].details).toBe(`AssertionError [ERR_ASSERTION]: no "description" key provided`)
138+
})
94139
})

‎src/services/testRunner/parser.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ const parser = (text: string): ParserOutput => {
2323
letcurrentDetails:string|null=null
2424

2525
constaddCurrentDetails=()=>{
26-
if(currentDetails){
27-
result.fails[result.fails.length-1].details=currentDetails
26+
constfailLength:number=result.fails.length
27+
if(currentDetails&&!!failLength){
28+
result.fails[failLength-1].details=currentDetails
2829
currentDetails=null
2930
}
3031
}
@@ -46,8 +47,8 @@ const parser = (text: string): ParserOutput => {
4647
constisFail=detect('fail',line)
4748
if(!!isFail){
4849
result.ok=false
49-
result.fails.push({message:isFail[2]})
5050
addCurrentDetails()
51+
result.fails.push({message:isFail[2]})
5152
continue
5253
}
5354

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp