basictap
Version:
Light tap adherent test runner
76 lines (54 loc) • 1.41 kB
JavaScript
import test from '../lib/index.js';
test.maximumConcurrentTests = 2;
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
import('./async.js');
test('basic test that passes', t => {
t.plan(3);
t.equal(1, 1);
t.equal(1, 1);
t.equal(1, 1);
});
test.todo('todo test that will not run');
test.skip('skip test that will not run', () => {});
test('timer set', t => {
t.plan(1);
setTimeout(() => {
t.equal(1, 1);
}, 200);
});
test('basic test that passes with comment', t => {
t.plan(1);
t.equal(1, 1, 'i have a custom comment');
});
test('promise 1 - basic test that passes', async t => {
t.plan(1);
await sleep(50);
t.equal(1, 1);
});
test('promise 2 - basic test that passes', async t => {
t.plan(1);
await sleep(50);
t.equal(1, 1);
});
test('waitFor - wait for passing test', async t => {
t.plan(2);
let runCount = 0;
const finalRunCount = await t.waitFor(async () => {
runCount = runCount + 1;
await sleep(50);
t.equal(runCount, 5);
return runCount;
}, 500);
t.equal(finalRunCount, 5);
});
test('waitFor - assertions are only logged once, at the end', async t => {
t.plan(2);
let runCount = 0;
await t.waitFor(async () => {
t.pass('only the last of this should appear in the logs ' + runCount);
runCount = runCount + 1;
await sleep(50);
t.equal(runCount, 5);
return runCount;
}, 1000);
});