Skip to content

Commit

Permalink
run postVisit on failures as well
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Jul 16, 2024
1 parent 5d012d8 commit 37538d6
Show file tree
Hide file tree
Showing 4 changed files with 565 additions and 177 deletions.
75 changes: 57 additions & 18 deletions src/csf/__snapshots__/transformCsf.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,25 @@ if (!require.main) {
if (globalThis.__sbPreVisit) {
await globalThis.__sbPreVisit(page, context);
}
const result = await page.evaluate(({
id,
hasPlayFn
}) => __test(id, hasPlayFn), {
id: "button--primary"
});
let result;
try {
result = await page.evaluate(({
id,
hasPlayFn
}) => __test(id, hasPlayFn), {
id: "button--primary"
});
} catch (err) {
if (err.toString().includes('Execution context was destroyed')) {
throw err;
} else {
await globalThis.__sbPostVisit(page, {
...context,
hasFailure: true
});
throw err;
}
}
if (globalThis.__sbPostVisit) {
await globalThis.__sbPostVisit(page, context);
}
Expand Down Expand Up @@ -96,12 +109,25 @@ if (!require.main) {
if (globalThis.__sbPreVisit) {
await globalThis.__sbPreVisit(page, context);
}
const result = await page.evaluate(({
id,
hasPlayFn
}) => __test(id, hasPlayFn), {
id: "button--primary"
});
let result;
try {
result = await page.evaluate(({
id,
hasPlayFn
}) => __test(id, hasPlayFn), {
id: "button--primary"
});
} catch (err) {
if (err.toString().includes('Execution context was destroyed')) {
throw err;
} else {
await globalThis.__sbPostVisit(page, {
...context,
hasFailure: true
});
throw err;
}
}
if (globalThis.__sbPostVisit) {
await globalThis.__sbPostVisit(page, context);
}
Expand Down Expand Up @@ -149,12 +175,25 @@ if (!require.main) {
if (globalThis.__sbPreVisit) {
await globalThis.__sbPreVisit(page, context);
}
const result = await page.evaluate(({
id,
hasPlayFn
}) => __test(id, hasPlayFn), {
id: "button--primary"
});
let result;
try {
result = await page.evaluate(({
id,
hasPlayFn
}) => __test(id, hasPlayFn), {
id: "button--primary"
});
} catch (err) {
if (err.toString().includes('Execution context was destroyed')) {
throw err;
} else {
await globalThis.__sbPostVisit(page, {
...context,
hasFailure: true
});
throw err;
}
}
if (globalThis.__sbPostVisit) {
await globalThis.__sbPostVisit(page, context);
}
Expand Down
Loading

0 comments on commit 37538d6

Please sign in to comment.