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

Unit testing guide for API routes #300

Closed
hsavit1 opened this issue Nov 30, 2024 · 3 comments
Closed

Unit testing guide for API routes #300

hsavit1 opened this issue Nov 30, 2024 · 3 comments
Labels
documentation Changes only affect the documentation released This issue/pull request has been released.

Comments

@hsavit1
Copy link

hsavit1 commented Nov 30, 2024

Is your feature request related to a problem? Please describe.
Can you please write a guide for testing api routes?

Describe the solution you'd like
Some sort of example of an api route and its test

Describe alternatives you've considered

@hsavit1 hsavit1 added the enhancement New feature or request label Nov 30, 2024
@haydenbleasel haydenbleasel added documentation Changes only affect the documentation and removed enhancement New feature or request labels Dec 1, 2024
@hsavit1
Copy link
Author

hsavit1 commented Dec 2, 2024

here's a medium article for testing api routes with jest. not sure if this is still considered the best, considering that the community seems to be moving towards vitest

https://medium.com/@zachshallbetter/unit-test-next-js-api-routes-with-typescript-longer-version-a59ceb261b1f

@hsavit1 hsavit1 changed the title Testing guide for API routes Unit testing guide for API routes Dec 2, 2024
@haydenbleasel
Copy link
Owner

I've added a sample unit test for the API, but not sure if we can do anything more in the boilerplate. Triggering webhooks with test data will result in unintended database mutations.

If you can think of a way to expand this new setup, I'm open to reviewing a PR!

Copy link

🚀 Issue was released in v3.1.7 🚀

@github-actions github-actions bot added the released This issue/pull request has been released. label Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Changes only affect the documentation released This issue/pull request has been released.
Projects
None yet
Development

No branches or pull requests

2 participants