Skip to content

Highlights necessary step in Svelte setup #1330

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

Merged
merged 6 commits into from
Oct 31, 2023

Conversation

kyle-n
Copy link
Contributor

@kyle-n kyle-n commented Oct 29, 2023

@testing-library/svelte requires globals: true to run cleanup() after each test, but this is a bit easy to miss in the docs. This PR highlights this required step.

@netlify
Copy link

netlify bot commented Oct 29, 2023

Deploy Preview for testing-library ready!

Name Link
🔨 Latest commit 32aa938
🔍 Latest deploy log https://app.netlify.com/sites/testing-library/deploys/653febfcdc6d560008cf1927
😎 Deploy Preview https://deploy-preview-1330--testing-library.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@MatanBobi
Copy link
Member

Hi @kyle-n!
Thanks for taking the time to write this.
Any chance to align this explanation with what we have in testing-libarry/react?
You can see it here.
It also feels like a rephrasing there can help to state that globals: true is needed if you want to take it :)

@kyle-n
Copy link
Contributor Author

kyle-n commented Oct 30, 2023

@MatanBobi Thanks for the feedback!

I rephrased the message under cleanup() to match the React documentation. I also shortened the message, which hopefully makes it easier to read, and copied it to the other frameworks that use cleanup and only run it with a global afterEach.

Does this phrasing work for cleanup?

This is called automatically if your testing framework (such as mocha, Jest or Jasmine) injects a global afterEach() function into the testing environment.

@MatanBobi
Copy link
Member

That's cool but I'm still missing the "If not, you will need to do manual cleanups after each test" because it's important information IMO. Wdyt?

@kyle-n
Copy link
Contributor Author

kyle-n commented Oct 30, 2023

I thought that sentence was redundant, since the previous sentence implies if cleanup() is only run automatically with a global afterEach(), it is not run without one. However, on second thought, it is better to be explicit and clear. Updated.

Copy link
Member

@MatanBobi MatanBobi left a comment

Choose a reason for hiding this comment

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

Thanks @kyle-n!

@MatanBobi MatanBobi merged commit 840d59f into testing-library:main Oct 31, 2023
@MatanBobi
Copy link
Member

@all-contributors please add @kyle-n for docs :)

@allcontributors
Copy link
Contributor

@MatanBobi

I've put up a pull request to add @kyle-n! 🎉

@kyle-n kyle-n deleted the svelte-globals branch November 6, 2023 15:46
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