1 | var tape = require('../');
|
2 | var tap = require('tap');
|
3 | var concat = require('concat-stream');
|
4 |
|
5 | var stripFullStack = require('./common').stripFullStack;
|
6 | var testWrapper = require('./anonymous-fn/test-wrapper');
|
7 |
|
8 | tap.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 |
|
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 | });
|