UNPKG

2.73 kBJavaScriptView Raw
1var tap = require('tap');
2var test = require('../');
3var concat = require('concat-stream');
4var stripFullStack = require('./common').stripFullStack;
5
6tap.test('test skip explanations', function (assert) {
7 assert.plan(1);
8
9 var verify = function (output) {
10 assert.equal(stripFullStack(output.toString('utf8')), [
11 'TAP version 13',
12 '# SKIP (this skips)',
13 '# some tests might skip',
14 'ok 1 this runs',
15 'ok 2 failing assert is skipped # SKIP',
16 'ok 3 this runs',
17 '# incomplete test',
18 'ok 4 run sh',
19 'ok 5 run openssl # SKIP',
20 '# incomplete test with explanation',
21 'ok 6 run sh (conditional skip) # SKIP',
22 'ok 7 run openssl # SKIP can\'t run on windows platforms',
23 'ok 8 this runs',
24 '# too much explanation',
25 'ok 9 run openssl # SKIP Installer cannot work on windows and fails to add to PATH Err: (2401) denied',
26 '',
27 '1..9',
28 '# tests 9',
29 '# pass 9',
30 '',
31 '# ok',
32 ''
33 ].join('\n'));
34 };
35
36 var tapeTest = test.createHarness();
37 tapeTest.createStream().pipe(concat(verify));
38
39 tapeTest('(this skips)', { skip: true }, function (t) {
40 t.fail('doesn\'t run');
41 t.fail('this doesn\'t run too', { skip: false });
42 t.end();
43 });
44
45 tapeTest('some tests might skip', function (t) {
46 t.pass('this runs');
47 t.fail('failing assert is skipped', { skip: true });
48 t.pass('this runs');
49 t.end();
50 });
51
52 tapeTest('incomplete test', function (t) {
53 // var platform = process.platform; something like this needed
54 var platform = 'win32';
55
56 t.pass('run sh', { skip: platform !== 'win32' });
57 t.pass('run openssl', { skip: platform === 'win32' });
58 t.end();
59 });
60
61 tapeTest('incomplete test with explanation', function (t) {
62 // var platform = process.platform; something like this needed
63 var platform = 'win32';
64
65 t.fail('run sh (conditional skip)', { skip: platform === 'win32' });
66 t.fail('run openssl', { skip: platform === 'win32' && 'can\'t run on windows platforms' });
67 t.pass('this runs');
68 t.end();
69 });
70
71 tapeTest('too much explanation', function (t) {
72 // var platform = process.platform; something like this needed
73 var platform = 'win32';
74
75 t.fail('run openssl',
76 { skip: platform === 'win32' && 'Installer cannot work on windows\nand fails to add to PATH\n\n Err: (2401) denied' }
77 );
78 t.end();
79 });
80});
81
82// vim: set softtabstop=4 shiftwidth=4: