TypeScript Unit Testing with Vitest
A reusable prompt for asking an AI assistant to work as TypeScript Unit Testing with Vitest.
The full prompt is on this page. A prompt is not an installable skill package.
When to use this prompt
Use TypeScript Unit Testing with Vitest when you want an AI assistant to start from a ready-made prompt template: paste it into the chat, then adapt its inputs, constraints and desired output to your task.
When not to use it
Skip TypeScript Unit Testing with Vitest when you need an installable agent skill with its own files or scripts: a prompt template is plain text, not a SKILL.md package. A more specific prompt in the coding category may also fit better.
What this prompt does
A reusable prompt for asking an AI assistant to work as TypeScript Unit Testing with Vitest.
Use the template below as a starting point and adapt its inputs, constraints, and desired output to your task.
The prompt
Act as a Test Automation Engineer. You are skilled in writing unit tests for TypeScript projects using Vitest.
Your task is to guide developers on creating unit tests according to the RCS-001 standard.
You will:
- Ensure tests are implemented using `vitest`.
- Guide on placing test files under `tests` directory mirroring the class structure with `.spec` suffix.
- Describe the need for `testData` and `testUtils` for shared data and utilities.
- Explain the use of `mocked` directories for mocking dependencies.
- Instruct on using `describe` and `it` blocks for organizing tests.
- Ensure documentation for each test includes `target`, `dependencies`, `scenario`, and `expected output`.
Rules:
- Use `vi.mock` for direct exports and `vi.spyOn` for class methods.
- Utilize `expect` for result verification.
- Implement `beforeEach` and `afterEach` for common setup and teardown tasks.
- Use a global setup file for shared initialization code.
### Test Data
- Test data should be plain and stored in `testData` files. Use `testUtils` for generating or accessing data.
- Include doc strings for explaining data properties.
### Mocking
- Use `vi.mock` for functions not under classes and `vi.spyOn` for class functions.
- Define mock functions in `Mocked` files.
### Result Checking
- Use `expect().toEqual` for equality and `expect().toContain` for containing checks.
- Expect errors by type, not message.
### After and Before Each
- Use `beforeEach` or `afterEach` for common tasks in `describe` blocks.
### Global Setup
- Implement a global setup file for tasks like mocking network packages.
Example:
```typescript
describe(`Class1`, () => {
describe(`function1`, () => {
it(`should perform action`, () => {
// Test implementation
})
})
})```Source: f/prompts.chat, dedicated to the public domain under CC0 1.0. View it at its source.
How to get started
The full prompt is on this page. A prompt is not an installable skill package.
View original source (opens a new tab)What supports this recommendation?
55/100 provisional content score. This measures documentation, practical detail and source signals. It is not a measured task success rate or a security certification.
- Documentation
- 41/100
- Practical detail
- 52/100
- Source evidence
- 63/100
- Source signals
- 82/100
Model compatibility evidence
- claudeinferred
The skill uses model-agnostic prompt or LLM terminology. Portability is inferred and has not been verified on this model.
- chatgptinferred
The skill uses model-agnostic prompt or LLM terminology. Portability is inferred and has not been verified on this model.
- geminiinferred
The skill uses model-agnostic prompt or LLM terminology. Portability is inferred and has not been verified on this model.
- copilotinferred
The skill uses model-agnostic prompt or LLM terminology. Portability is inferred and has not been verified on this model.
- llamainferred
The skill uses model-agnostic prompt or LLM terminology. Portability is inferred and has not been verified on this model.
- perplexityinferred
The skill uses model-agnostic prompt or LLM terminology. Portability is inferred and has not been verified on this model.
- mistralinferred
The skill uses model-agnostic prompt or LLM terminology. Portability is inferred and has not been verified on this model.
- grokinferred
The skill uses model-agnostic prompt or LLM terminology. Portability is inferred and has not been verified on this model.
Inferred compatibility is based on content signals. Check the app, its available tools and setup requirements before running a skill.
Intended uses
- Ask an AI assistant to take on the TypeScript Unit Testing with Vitest role.
Implementation notes
- Replace example inputs and placeholders with details from your task.
- Review the result before relying on it for consequential decisions.
Try it, then tell us how it went
A copied prompt does not tell us whether the task worked. Report your result after checking the output. We collect your tool and outcome, never your files or prompt.