UNPKG

1.46 kBJavaScriptView Raw
1var tape = require('../');
2var tap = require('tap');
3var concat = require('concat-stream');
4
5var stripFullStack = require('./common').stripFullStack;
6var testWrapper = require('./anonymous-fn/test-wrapper');
7
8tap.test('inside anonymous functions', function (tt) {
9 tt.plan(1);
10
11 var test = tape.createHarness();
12 var tc = function (rows) {
13 var body = stripFullStack(rows.toString('utf8'));
14
15 // Handle stack trace variation in Node v0.8
16 body = body.replace(
17 'at Test.module.exports',
18 'at Test.<anonymous>'
19 );
20
21 tt.same(body, [
22 'TAP version 13',
23 '# wrapped test failure',
24 'not ok 1 fail',
25 ' ---',
26 ' operator: fail',
27 ' at: <anonymous> ($TEST/anonymous-fn.js:$LINE:$COL)',
28 ' stack: |-',
29 ' Error: fail',
30 ' [... stack stripped ...]',
31 ' at $TEST/anonymous-fn.js:$LINE:$COL',
32 ' at Test.<anonymous> ($TEST/anonymous-fn/test-wrapper.js:$LINE:$COL)',
33 ' [... stack stripped ...]',
34 ' ...',
35 '',
36 '1..1',
37 '# tests 1',
38 '# pass 0',
39 '# fail 1'
40 ].join('\n') + '\n');
41 };
42
43 test.createStream().pipe(concat(tc));
44
45 test('wrapped test failure', testWrapper(function (t) {
46 t.fail('fail');
47 t.end();
48 }));
49});