@@ -4,7 +4,9 @@ var tape = require('../');
4
4
var tap = require ( 'tap' ) ;
5
5
var concat = require ( 'concat-stream' ) ;
6
6
var tapParser = require ( 'tap-parser' ) ;
7
- var yaml = require ( 'js-yaml' ) ;
7
+ var common = require ( './common' ) ;
8
+
9
+ var getDiag = common . getDiag ;
8
10
9
11
tap . test ( 'preserves stack trace with newlines' , function ( tt ) {
10
12
tt . plan ( 3 ) ;
@@ -47,7 +49,7 @@ tap.test('preserves stack trace with newlines', function (tt) {
47
49
''
48
50
] ) ;
49
51
50
- tt . deepEqual ( getDiag ( strippedBody ) , {
52
+ tt . deepEqual ( getDiag ( strippedBody , true ) , {
51
53
stack : stackTrace ,
52
54
operator : 'error'
53
55
} ) ;
@@ -206,7 +208,7 @@ tap.test('preserves stack trace for failed assertions', function (tt) {
206
208
''
207
209
) ) ;
208
210
209
- tt . deepEqual ( getDiag ( strippedBody ) , {
211
+ tt . deepEqual ( getDiag ( strippedBody , true ) , {
210
212
stack : stack ,
211
213
operator : 'equal' ,
212
214
expected : false ,
@@ -269,7 +271,7 @@ tap.test('preserves stack trace for failed assertions where actual===falsy', fun
269
271
''
270
272
) ) ;
271
273
272
- tt . deepEqual ( getDiag ( strippedBody ) , {
274
+ tt . deepEqual ( getDiag ( strippedBody , true ) , {
273
275
stack : stack ,
274
276
operator : 'equal' ,
275
277
expected : true ,
@@ -283,19 +285,6 @@ tap.test('preserves stack trace for failed assertions where actual===falsy', fun
283
285
} ) ;
284
286
} ) ;
285
287
286
- function getDiag ( body ) {
287
- var yamlStart = body . indexOf ( ' ---' ) ;
288
- var yamlEnd = body . indexOf ( ' ...\n' ) ;
289
- var diag = body . slice ( yamlStart , yamlEnd ) . split ( '\n' ) . map ( function ( line ) {
290
- return line . slice ( 2 ) ;
291
- } ) . join ( '\n' ) ;
292
-
293
- // Get rid of 'at' variable (which has a line number / path of its own that's difficult to check).
294
- var withStack = yaml . safeLoad ( diag ) ;
295
- delete withStack . at ;
296
- return withStack ;
297
- }
298
-
299
288
function stripAt ( body ) {
300
289
return body . replace ( / ^ \s * a t : \s + T e s t .* $ \n / m, '' ) ;
301
290
}
0 commit comments