UNPKG

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