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

chore(test): Storybook test integration #878

Merged
merged 49 commits into from
May 21, 2024

Conversation

radupasparuga
Copy link
Collaborator

@radupasparuga radupasparuga commented Apr 22, 2024

Implemented changes

This PR introduces a new test format (additionally to component and e2e tests) to the PR check pipeline.
This new test loops through all Storybook stories and fails in case of console errors.

Screenshot 2024-05-16 at 15 42 14

With the new action we managed to detect the above error in the Stacinfo custom slot content story and fix it!

Screenshot 2024-05-16 at 15 54 51

After the fix we can see that all 67 tests are passing.

Average time to run through every story is ~3 minutes but that won't happen on every PR, in cypress/e2e/storybook.cy.js we check the git diff (passed as an environment variable) so that we only test stories of elements that were changed in the current branch with the exception that if the cypress folder has been changed it will run through every story (heavy inspiration from cypress.config.ts).

Checklist before requesting a review

@radupasparuga radupasparuga changed the title Testing/feat/storybook integration chore(test): Storybook test integration Apr 22, 2024
@radupasparuga radupasparuga marked this pull request as ready for review April 22, 2024 15:06
@silvester-pari silvester-pari marked this pull request as draft April 22, 2024 15:25
@radupasparuga radupasparuga marked this pull request as ready for review May 13, 2024 13:54
Copy link
Collaborator

@silvester-pari silvester-pari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is great! It adds another layer of tests, and it did indeed find some errors in Storybook stories (some of which have been fixed in the meantime). Since we have to write the stories anyways, it makes sense to also use them as tests.

Copy link
Member

@lubojr lubojr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really helpful enhancement to the storybook setup and it could catch future non-working stories.

Just a miscellaneous question - is the excludeSpecPattern='[\"**/layercontrol.cy.js\"]' necessary?

Copy link
Member

@santilland santilland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea to "reuse" the existing stories as tests!

@radupasparuga
Copy link
Collaborator Author

radupasparuga commented May 17, 2024

This is really helpful enhancement to the storybook setup and it could catch future non-working stories.

Just a miscellaneous question - is the excludeSpecPattern='[\"**/layercontrol.cy.js\"]' necessary?

In cypress.config.ts we exclude the storybook spec so it doesn't run at the same time with the E2E tests (storybook tests take 2-3 minutes so it makes life easier when trying to only run E2E tests) but in order to actually run the storybook spec we need to overwrite the config via the CLI and in that case I'm excluding a fictitious layercontrol spec.
Not the cleanest solution but it gets the job done 😅

@silvester-pari silvester-pari merged commit dbb2bc3 into main May 21, 2024
3 checks passed
@silvester-pari silvester-pari deleted the testing/feat/storybook-integration branch May 21, 2024 16:09
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.

4 participants