Skip to content

Commit 1306442

Browse files
committed
refactored tests to prevent timeout
1 parent 106388f commit 1306442

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

test/svelte-styles-csp/index.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ const path = require('path');
55
// set to false to view transitions tested in Chromium
66
const headless_browser = true;
77

8+
// set to true to allow 1000ms delay between transition start and finish
9+
// (gives time to view transitions when not in headless mode)
10+
const transition_delay = false;
11+
812
describe('svelte-style-csp', async () => {
913
describe('test transitions with svelte-styles-csp & strict-CSP', async () => {
1014
it('svelte-stylesheet loaded and transitions work', async () => {
@@ -16,9 +20,7 @@ describe('svelte-style-csp', async () => {
1620
const page = await browser.newPage();
1721
try {
1822
await page.goto('file://' + absolutePath);
19-
await page.waitFor(1000);
2023
let linkTitle: string;
21-
// look for title attribute in link tags to
2224
const linkTitles = await page.evaluateHandle(() => {
2325
return Array.from(document.getElementsByTagName('link')).map(
2426
(a) => a.title
@@ -31,19 +33,20 @@ describe('svelte-style-csp', async () => {
3133
}
3234

3335
await page.click('input');
34-
await page.waitFor(1000);
36+
if (transition_delay) {
37+
await page.waitFor(1000);
38+
}
3539
await page.click('input');
36-
await page.waitFor(1000);
3740
await browser.close();
3841
assert.equal(linkTitle, 'svelte-stylesheet');
3942
} catch (err) {
4043
throw new Error(err);
4144
}
42-
}).timeout(10000);
45+
});
4346
});
4447

4548
describe('test transitions without svelte-styles-csp & strict CSP', async () => {
46-
it('transitions fail with strict CSP and no stylesrc: unsafe-iline', async () => {
49+
it('transitions fail with strict CSP and no style-src: unsafe-inline', async () => {
4750
const absolutePath = path.join(
4851
__dirname,
4952
'svelte-test-transitions-no-styles-csp/index.html'
@@ -52,16 +55,16 @@ describe('svelte-style-csp', async () => {
5255
const page = await browser.newPage();
5356
try {
5457
await page.goto('file://' + absolutePath);
55-
await page.waitFor(1000);
5658
await page.click('input');
57-
await page.waitFor(1000);
59+
if (transition_delay) {
60+
await page.waitFor(1000);
61+
}
5862
await page.click('input');
59-
await page.waitFor(1000);
6063
await browser.close();
6164
} catch (err) {
6265
// Transitions should fail with strict CSP
6366
assert.throws(err);
6467
}
65-
}).timeout(10000);
68+
});
6669
});
6770
});

0 commit comments

Comments
 (0)