Skip to content
This repository was archived by the owner on Nov 19, 2026. It is now read-only.

Include imports in generated test files - #214

Closed
AlfieJones wants to merge 6 commits into
storybookjs:nextfrom
AlfieJones:next
Closed

AlfieJones wants to merge 6 commits into
storybookjs:nextfrom
AlfieJones:next

Conversation

@AlfieJones

@AlfieJones AlfieJones commented Oct 27, 2022 •

Copy link
Copy Markdown

Description

This pr fixes an issue here: #136

When running tests which are in JSON mode, the test runner generates the test files for them. Under certain circumstances, these tests fail and are attempted to be restarted. From the error snippet below, we see that setupPage isn't imported into these files, this can be verified by checking the generated files code.

  ● Modules / Components / AuthDetails › App Without Auth › test

    ReferenceError: setupPage is not defined

      90 |         if (err.toString().includes('Execution context was destroyed')) {
      91 |           await jestPlaywright.resetPage();
    > 92 |           await setupPage(global.page);
         |           ^
      93 |           await testFn();
      94 |         } else {
      95 |           throw err;

      at Object.<anonymous> (../../../../../../private/var/folders/l_/7fz4zgds1cd9tkqc36p0lk0w0000gn/T/47e5eedc4767b37c9cdb92bc7c1c08b6/modules-components-authdetails.test.js:92:11)

Impact of the issue

This issue is currently causing our pipeline to be very flaky. The problem seems to be occurring once every 4 runs and I can only assume it'll get worse as we increase our storybook count. We currently have about 30.

Fix

I've just added the existing filePrefixer to the generated codes. This contains the required imports and solves the issue. I have also updated the tests accordingly.

Testing and Impact

I have built and tested a build generated from this branch on our pipeline. These changes only affect other Json mode stories ( in theory)

@yannbf

yannbf commented Nov 9, 2022

Copy link
Copy Markdown
Member

Hey @AlfieJones thank you so much for providing a PR for this. Unfortunately, I believe this will not fix the issue.
Therefore, I created another PR at #217 to fix that issue.

@yannbf yannbf closed this Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants