Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include imports in generated test files #214

Closed
wants to merge 6 commits into from

Conversation

AlfieJones
Copy link

@AlfieJones AlfieJones commented Oct 27, 2022

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
Copy link
Member

yannbf commented Nov 9, 2022

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants