vitest-dev / vitest-dev/vitest
Support service worker testing
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 94
Description
Clear and concise description of the problem
Service workers are complicated, so having unit tests for them where you can inspect every caching decision can be important.
Currently I'm not familiar with any way to test in a service worker environment with vitest. It would be great if it supported that.
I had a quick go and I got a hard error:
Error: This module can only be imported inside a service worker
I will try look for a workaround, but generally it would be good to have decent support for the service worker use case
Suggested solution
Add service worker environment testing
Alternative
playwright? Though I'm not sure it has good support either + you can't inspect every decision to ensure caches are correctly added / removed in all scenarios
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
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
Start by reproducing the reported import error in Vitest when testing a service worker environment. Review the existing environment-testing entry points and determine how service-worker execution and cache decisions should be inspected. Done means service-worker unit tests run without the environment error and the supported behavior is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100