Skip to content

Commit

Permalink
fix postVisit hook issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Dec 2, 2024
1 parent f2e9c05 commit c9a334b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions playwright/jest-setup.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
const { getTestRunnerConfig, setPreVisit, setPostVisit, setupPage } = require('../dist');

const noop = async () => {};
const testRunnerConfig = getTestRunnerConfig(process.env.STORYBOOK_CONFIG_DIR);
if (testRunnerConfig) {
// hooks set up
if (testRunnerConfig.setup) {
testRunnerConfig.setup();
}

const preVisitFn = testRunnerConfig.preVisit || testRunnerConfig.preRender;
if (preVisitFn) {
setPreVisit(preVisitFn);
}
const preVisitFn = testRunnerConfig.preVisit ?? testRunnerConfig.preRender ?? noop;
setPreVisit(preVisitFn);

const postVisitFn = testRunnerConfig.postVisit || testRunnerConfig.postRender;
if (postVisitFn) {
setPostVisit(postVisitFn);
}
const postVisitFn = testRunnerConfig.postVisit ?? testRunnerConfig.postRender ?? noop;
setPostVisit(postVisitFn);
}

// If the transformed tests need a dependency, it has to be globally available
Expand Down

0 comments on commit c9a334b

Please sign in to comment.