2022-03-14 10:22:17 +00:00
|
|
|
import { tap, expect, webhelpers } from '../ts/index.js';
|
2020-07-07 22:54:15 +00:00
|
|
|
|
2021-02-13 16:06:38 +00:00
|
|
|
tap.preTask('custompretask', async () => {
|
2020-07-07 22:54:15 +00:00
|
|
|
console.log('this is a pretask');
|
|
|
|
});
|
|
|
|
|
2021-02-13 16:06:38 +00:00
|
|
|
tap.test('should have access to webhelpers', async () => {
|
|
|
|
const myElement = await webhelpers.fixture(webhelpers.html`<div></div>`);
|
2022-01-21 18:54:07 +00:00
|
|
|
expect(myElement).toBeInstanceOf(HTMLElement);
|
2021-02-13 16:06:38 +00:00
|
|
|
console.log(myElement);
|
|
|
|
});
|
|
|
|
|
2020-07-07 22:54:15 +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();
|
2020-07-07 22:54:15 +00:00
|
|
|
});
|
|
|
|
|
2020-07-08 00:17:25 +00:00
|
|
|
const test2 = tap.test('my second test', async (tools) => {
|
2020-07-08 00:11:16 +00:00
|
|
|
await tools.delayFor(50);
|
2020-07-07 22:54:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const test3 = tap.test(
|
|
|
|
'my third test -> test2 should take longer than test1 and endure at least 1000ms',
|
|
|
|
async () => {
|
2022-01-21 18:54:07 +00:00
|
|
|
expect((await test1).hrtMeasurement.milliSeconds < (await test2).hrtMeasurement.milliSeconds).toBeTrue();
|
|
|
|
expect((await test2).hrtMeasurement.milliSeconds > 10).toBeTrue();
|
2020-07-07 22:54:15 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2020-07-08 00:17:25 +00:00
|
|
|
const test4 = tap.skip.test('my 4th test -> should fail', async (tools) => {
|
2020-07-07 22:54:15 +00:00
|
|
|
tools.allowFailure();
|
2022-01-21 18:54:07 +00:00
|
|
|
expect(false).toBeTrue();
|
2020-07-07 22:54:15 +00:00
|
|
|
});
|
|
|
|
|
2020-07-08 00:17:25 +00:00
|
|
|
const test5 = tap.test('my 5th test -> should pass in about 500ms', async (tools) => {
|
2020-07-07 22:54:15 +00:00
|
|
|
tools.timeout(1000);
|
|
|
|
await tools.delayFor(500);
|
|
|
|
});
|
|
|
|
|
2020-07-08 00:17:25 +00:00
|
|
|
const test6 = tap.skip.test('my 6th test -> should fail after 1000ms', async (tools) => {
|
2020-07-07 22:54:15 +00:00
|
|
|
tools.allowFailure();
|
|
|
|
tools.timeout(1000);
|
2020-07-08 00:11:16 +00:00
|
|
|
await tools.delayFor(100);
|
2020-07-07 22:54:15 +00:00
|
|
|
});
|
|
|
|
|
2020-07-08 00:11:16 +00:00
|
|
|
tap.start();
|