Next.js Discord

Discord Forum

Vitest test searching compatibility with app router

Unanswered
Griffon Nivernais posted this in #help-forum
Open in Discord
Griffon NivernaisOP
I currently have a setup where I have Vitest run tests after every commit using a pre-commit system via Husky, if you don't know how Husky works don't worry that's fine.

What I'm wondering is how other people allow Vitest to view NextJS pages/routes as I'm unable to have Vitest detect tests based on say directory names. An example is having app/api/create-quiz/route.ts use create-quiz.test.ts. I understand this isn't doable due to everything being named page, route, etc, so how should this be achieved then?

If anybody could share some insight that'd be great.

0 Replies