2022-03-14 10:22:17 +00:00
|
|
|
import { tap, expect } from '../ts/index.js';
|
2017-04-23 09:10:13 +00:00
|
|
|
|
2020-03-15 16:36:25 +00:00
|
|
|
tap.preTask('hi there', async () => {
|
|
|
|
console.log('this is a pretask');
|
2020-07-08 00:17:25 +00:00
|
|
|
});
|
2020-03-15 16:36:25 +00:00
|
|
|
|
2019-04-10 10:56:17 +00:00
|
|
|
const test1 = tap.test('my first test -> expect true to be true', async () => {
|
2022-01-21 18:54:07 +00:00
|
|
|
return expect(true).toBeTrue();
|
2018-06-28 21:34:41 +00:00
|
|
|
});
|
2017-04-23 09:10:13 +00:00
|
|
|
|
2020-07-08 00:17:25 +00:00
|
|
|
const test2 = tap.test('my second test', async (tools) => {
|
2018-06-28 21:34:41 +00:00
|
|
|
await tools.delayFor(1000);
|
|
|
|
});
|
2017-04-28 07:49:57 +00:00
|
|
|
|
2019-04-10 10:56:17 +00:00
|
|
|
const test3 = tap.test(
|
2018-06-28 21:34:41 +00:00
|
|
|
'my third test -> test2 should take longer than test1 and endure at least 1000ms',
|
|
|
|
async () => {
|
2021-01-26 02:35:02 +00:00
|
|
|
expect(
|
|
|
|
(await test1.testPromise).hrtMeasurement.milliSeconds <
|
|
|
|
(await test2).hrtMeasurement.milliSeconds
|
2022-01-21 18:54:07 +00:00
|
|
|
).toBeTrue();
|
|
|
|
expect((await test2.testPromise).hrtMeasurement.milliSeconds > 1000).toBeTrue();
|
2018-06-28 21:34:41 +00:00
|
|
|
}
|
|
|
|
);
|
2017-04-28 07:49:57 +00:00
|
|
|
|
2021-01-26 03:15:50 +00:00
|
|
|
const test4 = tap.test('my 4th test -> should fail', async (tools) => {
|
2018-06-28 21:34:41 +00:00
|
|
|
tools.allowFailure();
|
2022-01-21 18:54:07 +00:00
|
|
|
expect(false).toBeFalse();
|
2021-01-26 03:15:50 +00:00
|
|
|
return 'hello';
|
2018-06-28 21:34:41 +00:00
|
|
|
});
|
2017-04-28 07:49:57 +00:00
|
|
|
|
2020-07-08 00:17:25 +00:00
|
|
|
const test5 = tap.test('my 5th test -> should pass in about 500ms', async (tools) => {
|
2021-01-26 03:15:50 +00:00
|
|
|
const test4Result = await test4.testResultPromise;
|
2018-06-28 21:34:41 +00:00
|
|
|
tools.timeout(1000);
|
|
|
|
await tools.delayFor(500);
|
|
|
|
});
|
2017-04-28 07:49:57 +00:00
|
|
|
|
2020-07-08 00:17:25 +00:00
|
|
|
const test6 = tap.skip.test('my 6th test -> should fail after 1000ms', async (tools) => {
|
2018-06-28 21:34:41 +00:00
|
|
|
tools.allowFailure();
|
|
|
|
tools.timeout(1000);
|
|
|
|
await tools.delayFor(2000);
|
|
|
|
});
|
2017-04-28 07:49:57 +00:00
|
|
|
|
2018-06-28 21:34:41 +00:00
|
|
|
tap.start();
|