anonymous-fn.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. 'use strict';
  2. var tape = require('../');
  3. var tap = require('tap');
  4. var concat = require('concat-stream');
  5. var stripFullStack = require('./common').stripFullStack;
  6. var testWrapper = require('./anonymous-fn/test-wrapper');
  7. tap.test('inside anonymous functions', function (tt) {
  8. tt.plan(1);
  9. var test = tape.createHarness();
  10. var tc = function (rows) {
  11. var body = stripFullStack(rows.toString('utf8'));
  12. tt.same(body, [
  13. 'TAP version 13',
  14. '# wrapped test failure',
  15. 'not ok 1 fail',
  16. ' ---',
  17. ' operator: fail',
  18. ' at: <anonymous> ($TEST/anonymous-fn.js:$LINE:$COL)',
  19. ' stack: |-',
  20. ' Error: fail',
  21. ' [... stack stripped ...]',
  22. ' at $TEST/anonymous-fn.js:$LINE:$COL',
  23. ' at Test.<anonymous> ($TEST/anonymous-fn/test-wrapper.js:$LINE:$COL)',
  24. ' [... stack stripped ...]',
  25. ' ...',
  26. '',
  27. '1..1',
  28. '# tests 1',
  29. '# pass 0',
  30. '# fail 1',
  31. ''
  32. ]);
  33. };
  34. test.createStream().pipe(concat(tc));
  35. test('wrapped test failure', testWrapper(function (t) {
  36. t.fail('fail');
  37. t.end();
  38. }));
  39. });