Skip to content

Commit

Permalink
fix: Flaky "__test is not defined" issue
Browse files Browse the repository at this point in the history
fixes #68
  • Loading branch information
Valentin Palkovič committed May 23, 2022
1 parent 62a6d5e commit a831a6b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/playwright/transformPlaywright.test.ts
Expand Up @@ -77,6 +77,11 @@ describe('Playwright', () => {
await global.__sbPreRender(page, context);
}
await new Promise(resolve => {
page.on('load', () => {
resolve();
});
});
const result = await page.evaluate(({
id,
hasPlayFn
Expand Down Expand Up @@ -148,6 +153,11 @@ describe('Playwright', () => {
await global.__sbPreRender(page, context);
}
await new Promise(resolve => {
page.on('load', () => {
resolve();
});
});
const result = await page.evaluate(({
id,
hasPlayFn
Expand Down Expand Up @@ -220,6 +230,11 @@ describe('Playwright', () => {
await global.__sbPreRender(page, context);
}
await new Promise(resolve => {
page.on('load', () => {
resolve();
});
});
const result = await page.evaluate(({
id,
hasPlayFn
Expand Down
6 changes: 6 additions & 0 deletions src/playwright/transformPlaywright.ts
Expand Up @@ -25,6 +25,12 @@ export const testPrefixer = template(
await global.__sbPreRender(page, context);
}
await new Promise((resolve) => {
page.on('load', () => {
resolve()
})
})
const result = await page.evaluate(({ id, hasPlayFn }) => __test(id, hasPlayFn), {
id: %%id%%,
});
Expand Down
20 changes: 20 additions & 0 deletions src/playwright/transformPlaywrightJson.test.ts
Expand Up @@ -72,6 +72,11 @@ describe('Playwright Json', () => {
await global.__sbPreRender(page, context);
}
await new Promise(resolve => {
page.on('load', () => {
resolve();
});
});
const result = await page.evaluate(({
id,
hasPlayFn
Expand Down Expand Up @@ -121,6 +126,11 @@ describe('Playwright Json', () => {
await global.__sbPreRender(page, context);
}
await new Promise(resolve => {
page.on('load', () => {
resolve();
});
});
const result = await page.evaluate(({
id,
hasPlayFn
Expand Down Expand Up @@ -172,6 +182,11 @@ describe('Playwright Json', () => {
await global.__sbPreRender(page, context);
}
await new Promise(resolve => {
page.on('load', () => {
resolve();
});
});
const result = await page.evaluate(({
id,
hasPlayFn
Expand Down Expand Up @@ -261,6 +276,11 @@ describe('Playwright Json', () => {
await global.__sbPreRender(page, context);
}
await new Promise(resolve => {
page.on('load', () => {
resolve();
});
});
const result = await page.evaluate(({
id,
hasPlayFn
Expand Down

0 comments on commit a831a6b

Please sign in to comment.