From c9a334bf061ac64c172fd3c3019d0a5fb5316829 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Mon, 2 Dec 2024 14:01:32 +0100 Subject: [PATCH] fix postVisit hook issue --- playwright/jest-setup.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/playwright/jest-setup.js b/playwright/jest-setup.js index 7e319565..f4daae3d 100644 --- a/playwright/jest-setup.js +++ b/playwright/jest-setup.js @@ -1,5 +1,6 @@ const { getTestRunnerConfig, setPreVisit, setPostVisit, setupPage } = require('../dist'); +const noop = async () => {}; const testRunnerConfig = getTestRunnerConfig(process.env.STORYBOOK_CONFIG_DIR); if (testRunnerConfig) { // hooks set up @@ -7,15 +8,11 @@ if (testRunnerConfig) { 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