@@ -74,7 +74,7 @@ ok 3 sumItems should total numbers accurately
7474`
7575expect ( parser ( example ) . fails ) . toEqual ( [ { message :"sumItems shouldn't return NaN" } ] )
7676} )
77- test ( 'should capture error details' , ( ) => {
77+ test ( 'should capturesingle error details' , ( ) => {
7878const example = `
7979not 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
9191at Context.<anonymous> (test/packagejson.test.js:11:12)
9292at processImmediate (internal/timers.js:439:21)` )
9393} )
94+ test ( 'should capture multiple error details' , ( ) => {
95+ const example = `
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+ const result = 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+ const example = `
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+ const result = 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} )