Built-in test support per route
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
Kit is great and the new routing changes have opened up a world of possibilities. Running tests is still a bit of a hassle. I would love to be able to run tests whenever I change a file inside of a route.
Describe the proposed solution
This is what I have in mind. Add a new file called +tests.ts or +spec.ts that contains something like the following:
import { test, expect } from '@playwright/test';
import { expect as viteExpect, test as viteTest } from 'vitest'
export const playwright = [
test('login', async ({ page }) => {
await page.goto(...)
...
await expect(page).toHaveUrl(...)
}),
test('register', async ({ page }) => {
await page.goto(...)
...
await expect(page).toHaveUrl(...)
}),
]
export const vitest = [
viteTest('Math.sqrt()', () => {
viteExpect(Math.sqrt(4)).toBe(2)
}),
viteTest('Some other test', () => {
...
}),
]
Every time a relevant file in the route changes, these tests should re-run. I don't know if it makes sense to do both unit and E2E tests in the same file like the proposed example here though. Maybe it just makes sense to have the playwright ones since this is also what's in the CLI.
Alternatives considered
Set it all up manually and run the tests manually. Not as fun! 😆
Importance
would make my life easier
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the existing routing changes and the test setup used by the CLI, especially its Playwright integration. Determine how route files and relevant changes would be detected, and decide whether per-route tests should support Playwright, Vitest, or both. Done means a documented, integrated approach that reruns the selected tests when route files change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, playwright
- Domain
- testing, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100