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

Fix test isolation of accordion component tests #2301

Merged
merged 1 commit into from
Aug 10, 2021

Conversation

lfdebrux
Copy link
Member

The unit tests for the accordion component can interfere with each other, because within a test suite Puppeteer browser instances are shared, and the accordion component has state stored in the browser session storage. This is especially a problem for any tests after it('should maintain the expanded state after a page refresh'), which leaves all the accordion sections opened.

This PR adds a simple teardown function to clear the session storage after each test. It just so happens that our current tests behave the same and still pass with the teardown function, but we should fix this problem now, to prevent any future tests from being affected by the state of our current tests, such as for the accordion design refresh in PR #2257 (which is how this problem was discovered in the first place).


We should look at test isolation in general for this repo, but that is a bigger task for a different day; this PR is just to make sure we fix the thing we know to be an active issue.

The unit tests for the accordion component can interfere with each
other, because within a test suite Puppeteer browser instances are
shared, and the accordion component has state stored in the browser
session storage. This is especially a problem for any tests after
`it('should maintain the expanded state after a page refresh')`, which
leaves all the accordion sections opened.

This commit adds a simple teardown function to clear the session storage
after each test. It just so happens that our current tests behave the
same and still pass with the teardown function, but we should fix this
problem now, to prevent any future tests from being affected by the
state of our current tests, such as for the accordion design refresh in
PR #2257.
@lfdebrux lfdebrux force-pushed the ldeb-fix-accordion-test-isolation branch from b754b2d to 1198bda Compare August 10, 2021 13:57
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2301 August 10, 2021 13:58 Inactive
@lfdebrux lfdebrux merged commit f86488e into main Aug 10, 2021
@lfdebrux lfdebrux deleted the ldeb-fix-accordion-test-isolation branch August 10, 2021 14:02
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.

3 participants