
js-ts
JavaScript and TypeScript development toolkit with ESLint, Vitest, and unit testing best practices
- version
- 0.1.2
- GitHub stars
- 12
Install
/plugin install js-ts@jebs-dev-toolsRun it inside Claude Code after adding the marketplace with /plugin marketplace add el-feo/ai-context.
Contents
Discovered from sourceSkills 3
ESLint
Quick Start
Prerequisites
- Node.js (^18.18.0, ^20.9.0, or >=21.1.0) with SSL support
- Existing
package.jsonfile (runnpm initif needed)
Installation & Setup
Automated Setup (Recommended):
npm init @eslint/config@latest
This interactive setup will ask about your project and create an eslint.config.js file.
Manual Setup:
# Install ESLint packages
npm install --save-dev eslint@latest @eslint/js@latest
# Create configuration file
touch eslint.config.js
Basic Configuration
The new flat config format (ESLint 9.0+) uses eslint.config.js:
import { defineConfig } from "eslint/config";
import js from "@eslint/js";
export default defineConfig([
{
files: ["**/*.js"],
plugins: { js },
extends: ["js/recommended"],
rules: {
"no-unused-vars": "warn",
"no-undef": "warn"
}
}
]);
Running ESLint
# Lint a single file
npx eslint yourfile.js
# Lint a directory
npx eslint src/
# Lint with auto-fix
npx eslint src/ --fix
Core ESLint Tasks
1. Setting Up ESLint
For JavaScript Projects
npm init @eslint/config@latest
Select options:
- How would you like to use ESLint? → To check syntax, find problems, and enforce code style
- What type of modules? → JavaScript modules (import/export)
- Which framework? → None/React/Vue (as applicable)
- Does your project use TypeScript? → No
- Where does your code run? → Browser and/or Node
- Config file format → JavaScript/JSON/YAML (JavaScript recommended)
For TypeScript Projects
npm install --save-dev eslint@latest @typescript-eslint/parser @typescript-eslint/eslint-plugin typescript-eslint
Configuration for TypeScript:
import { defineConfig } from 'eslint/config';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
export default defineConfig(
eslint.configs.recommended,
...tseslint.configs.recommended
);
For React + TypeScript
npm install --save-dev \
eslint \
@typescript-eslint/parser \
@typescript-eslint/eslint-plugin \
eslint-plugin-react \
eslint-plugin-react-hooks \
eslint-plugin-jsx-a11y \
typescript-eslint
2. Configuring Rules
Rule Severity Levels
"off"or0- Disable the rule"warn"or1- Warning (doesn't affect exit code)"error"or2- Error (exit code will be 1)
Common Rule Configurations
Basic Rules:
export default defineConfig([
{
rules: {
// Enforce semicolons
"semi": ["error", "always"],
// Enforce const where possible
"prefer-const": "error",
// Warn on unused variables
"no-unused-vars": "warn",
// No console.log in production
"no-console": ["error", { allow: ["warn", "error"] }],
// Enforce consistent quotes
"quotes": ["error", "single"],
// Require === instead of ==
"eqeqeq": ["error", "always"]
}
}
]);
TypeScript-Specific Rules:
export default defineConfig([
{
files: ["**/*.ts", "**/*.tsx"],
rules: {
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/explicit-function-return-type": ["error", {
allowExpressions: true
}],
"@typescript-eslint/naming-convention": ["error", {
selector: "interface",
format: ["PascalCase"],
custom: {
regex: "^I[A-Z]",
match: false
}
}]
}
}
]);
Configuration Comments
Disable rules inline:
/* eslint-disable no-console */
console.log('This is allowed');
/* eslint-enable no-console */
// Disable for single line
console.log('Debug'); // eslint-disable-line no-console
// Disable next line
// eslint-disable-next-line no-console
console.log('Debug');
// Disable specific rules
alert('foo'); // eslint-disable-line no-alert, no-undef
Best Practices for Inline Disables:
-
Use sparingly with clear justification
-
Document the reason:
// eslint-disable-next-line no-console -- Debugging production issue #1234 console.log('User data:', userData); -
Prefer configuration file changes over inline disables
-
Create follow-up tasks for temporary disables
3. File Patterns and Ignores
Specifying Files to Lint
export default defineConfig([
{
// Only lint TypeScript files in src/
files: ["src/**/*.ts", "src/**/*.tsx"],
// Ignore test files for certain rules
ignores: ["**/*.test.ts", "**/*.spec.ts"]
}
]);
Global Ignores
export default defineConfig([
{
ignores: [
"**/node_modules/**",
"**/dist/**",
"**/build/**",
"**/.next/**",
"**/coverage/**"
]
},
// ... rest of config
]);
4. Using Shared Configurations
ESLint supports extending from popular configurations:
import { defineConfig } from "eslint/config";
import js from "@eslint/js";
import globals from "globals";
export default defineConfig([
js.configs.recommended, // ESLint recommended rules
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
}
]);
Popular Shared Configs:
eslint:recommended- ESLint's recommended rules@typescript-eslint/recommended- TypeScript recommended@typescript-eslint/strict- Stricter TypeScript rulesplugin:react/recommended- React best practicesplugin:react-hooks/recommended- React Hooks rules
5. Auto-Fixing Issues
ESLint can automatically fix many issues:
# Fix all auto-fixable issues
npx eslint src/ --fix
# Show what would be fixed (dry run)
npx eslint src/ --fix-dry-run
Auto-fixable rules include:
- Formatting issues (spacing, semicolons, quotes)
- Simple code transformations (prefer-const, arrow functions)
- Import sorting
Non-fixable issues require manual intervention:
- Logic errors (no-unused-vars with actual usage)
- Complex refactoring needs
Common Project Scenarios
React + TypeScript Project
Complete Configuration:
import { defineConfig } from 'eslint/config';
import js from '@eslint/js';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';
export default defineConfig([
{ ignores: ['dist'] },
js.configs.recommended,
...tseslint.configs.recommended,
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
project: './tsconfig.json'
}
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true }
],
'@typescript-eslint/no-unused-vars': ['error', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_'
}]
}
}
]);
Node.js + TypeScript Project
import { defineConfig } from 'eslint/config';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import globals from 'globals';
export default defineConfig([
eslint.configs.recommended,
...tseslint.configs.recommended,
{
files: ['**/*.ts'],
languageOptions: {
globals: globals.node
},
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
'no-console': 'off' // Console is fine in Node.js
}
}
]);
Monorepo Configuration
export default defineConfig([
// Global ignores
{ ignores: ['**/dist/**', '**/build/**'] },
// Frontend package
{
files: ['packages/frontend/**/*.{ts,tsx}'],
languageOptions: {
globals: globals.browser
},
// Frontend-specific rules
},
// Backend package
{
files: ['packages/backend/**/*.ts'],
languageOptions: {
globals: globals.node
},
// Backend-specific rules
}
]);
Integration
For VS Code setup, CI/CD (GitHub Actions), pre-commit hooks (Husky/lint-staged), and package.json scripts, see references/integration.md.
Troubleshooting
Common Issues
"Cannot find module 'eslint/config'"
- Update to ESLint 9.0+:
npm install eslint@latest
"Parsing error: Cannot find module '@typescript-eslint/parser'"
- Install parser:
npm install --save-dev @typescript-eslint/parser
Rules not being applied
- Check file patterns match your source files
- Verify config file is named correctly (
eslint.config.js) - Ensure config is in project root
Slow linting in large projects
- Add appropriate ignores for node_modules, dist, build folders
- Use
--cacheflag:npx eslint --cache . - Consider using
--max-warnings 0to fail on warnings in CI
Advanced Topics
Creating Custom Rules
For project-specific patterns, see references/custom_rules.md.
TypeScript Type-Aware Linting
For advanced TypeScript checks requiring type information, see references/type_aware_linting.md.
Rule Reference
For a comprehensive rule reference with examples, see references/rule_reference.md.
Migration from ESLint 8.x
For projects using the legacy .eslintrc.* format, see references/migration_guide.md.
JavaScript Unit Testing
Expert guidance for writing maintainable, trustworthy unit tests in JavaScript and TypeScript using Jest. Based on "The Art of Unit Testing, Third Edition" by Roy Osherove with Vladimir Khorikov (Manning, 2024).
Instructions
When helping users with unit testing:
- Understand the context: Identify if they're writing new tests, fixing existing ones, or learning concepts
- Apply core principles: Focus on readability, maintainability, and trust in tests
- Use appropriate patterns: Select the right testing pattern based on exit point type (return value, state change, or third-party call)
- Provide examples: Show concrete code examples following best practices
- Reference supporting documentation: Point to references/REFERENCE.md for detailed concepts and references/EXAMPLES.md for more code samples
Core Concepts
Unit of Work
A unit of work is all actions between an entry point (function/method we trigger) and one or more exit points (observable results).
Three types of exit points:
- Return value - Function returns a useful value
- State change - Observable change in system state
- Third-party call - Calling external dependency (logger, database, API)
Good Unit Test Properties
Must have:
- Fast execution (milliseconds)
- Fully isolated from other tests
- Consistent results (no flakiness)
- Runs in memory (no filesystem, network, database)
- Clear intent and easy to read
Avoid:
- Logic in tests (if/else, loops, try/catch)
- Multiple concerns per test
- Shared state between tests
- Testing implementation details vs behavior
Quick Start: Writing Your First Test
Basic Test Structure (AAA Pattern)
test('sum with two numbers returns their sum', () => {
// Arrange - set up test data
const input = '1,2';
// Act - call the unit of work
const result = sum(input);
// Assert - verify the outcome
expect(result).toBe(3);
});
Test Naming (USE Pattern)
Format: **[U]**nit, **[S]**cenario, **[E]**xpectation
// Good examples
test('sum, with two valid numbers, returns their sum', () => { ... });
test('verify, with no uppercase letter, returns false', () => { ... });
test('save, during maintenance window, throws exception', () => { ... });
Organizing Tests
describe('Password Verifier', () => {
describe('one uppercase rule', () => {
test('given no uppercase, returns false', () => {
const verifier = makeVerifier([oneUpperCaseRule]);
expect(verifier.verify('abc')).toBe(false);
});
test('given one uppercase, returns true', () => {
const verifier = makeVerifier([oneUpperCaseRule]);
expect(verifier.verify('Abc')).toBe(true);
});
});
});
Use factory methods instead of beforeEach() to avoid scroll fatigue and keep tests self-contained.
Testing Different Exit Points
Return Value Testing (Easiest)
test('processes input and returns result', () => {
const result = calculateTotal([10, 20, 30]);
expect(result).toBe(60);
});
State-Based Testing
test('adds item to cart and updates count', () => {
const cart = new ShoppingCart();
cart.addItem('apple');
expect(cart.itemCount()).toBe(1);
expect(cart.contains('apple')).toBe(true);
});
Interaction Testing (Use Sparingly)
Only for testing third-party calls (exit points):
test('save calls logger with correct message', () => {
const mockLogger = { info: jest.fn() };
const repository = new Repository(mockLogger);
repository.save({ id: 1, name: 'test' });
expect(mockLogger.info).toHaveBeenCalledWith('Saved item 1');
});
Important: Use mocks only for exit points. Have one mock per test maximum. Most tests (95%+) should be return-value or state-based.
Breaking Dependencies
When to Break Dependencies
Break dependencies when code relies on:
- Time (Date.now(), moment())
- Random values (Math.random())
- Network calls (fetch, axios)
- Filesystem (fs.readFile)
- Databases
- External services
Dependency Injection Patterns
1. Parameter Injection (Simplest)
// Before - time dependency baked in
const verify = (input) => {
const day = moment().day(); // Hard to test!
if (day === 0 || day === 6) throw Error("Weekend!");
};
// After - time injected
const verify = (input, currentDay) => {
if (currentDay === 0 || currentDay === 6) throw Error("Weekend!");
};
// Test with full control
test('on weekends, throws exception', () => {
expect(() => verify('input', 0)).toThrow("Weekend!");
});
2. Functional Injection
const verify = (logger) => (input) => {
logger.info('Verifying');
return input.length > 5;
};
// Test
test('verify logs attempt', () => {
const stubLogger = { info: jest.fn() };
const verifyFn = verify(stubLogger);
verifyFn('password');
});
3. Constructor Injection (OOP)
class Verifier {
constructor(private logger: ILogger) {}
verify(input: string): boolean {
this.logger.info('Verifying');
return true;
}
}
// Test
test('verify calls logger', () => {
const mockLogger = { info: jest.fn() };
const verifier = new Verifier(mockLogger);
verifier.verify('input');
expect(mockLogger.info).toHaveBeenCalled();
});
Stubs vs Mocks
Stubs (incoming dependencies):
- Provide fake data/behavior INTO the unit
- Do NOT assert against them
- Can have many per test
Mocks (outgoing dependencies):
- Represent exit points
- DO assert they were called correctly
- Should have ONE per test
// Stub - provides data IN
const stubDatabase = {
getUser: () => ({ id: 1, name: 'John' })
};
// Mock - verifies calls OUT
const mockLogger = {
info: jest.fn()
};
test('getUserName retrieves name from database and logs', () => {
const service = new UserService(stubDatabase, mockLogger);
const name = service.getUserName(1);
expect(name).toBe('John'); // Return value assertion
expect(mockLogger.info).toHaveBeenCalledWith('Retrieved user 1'); // Mock assertion
});
Testing Asynchronous Code
Extract Entry Point Pattern
Extract pure logic from async operations:
// Before - everything mixed
const isWebsiteAlive = async () => {
const resp = await fetch('http://example.com');
if (!resp.ok) throw resp.statusText;
const text = await resp.text();
return text.includes('illustrative')
? { success: true }
: { success: false, status: 'missing text' };
};
// After - extract testable logic
const processFetchContent = (text) => {
return text.includes('illustrative')
? { success: true }
: { success: false, status: 'missing text' };
};
// Fast, synchronous unit test
test('with good content, returns success', () => {
const result = processFetchContent('illustrative');
expect(result.success).toBe(true);
});
Extract Adapter Pattern
Wrap async dependencies behind testable interfaces:
// network-adapter.js - wrapper for fetch
const fetchUrlText = async (url) => {
const resp = await fetch(url);
return resp.ok
? { ok: true, text: await resp.text() }
: { ok: false, text: resp.statusText };
};
// website-verifier.js - inject adapter
const isWebsiteAlive = async (network) => {
const result = await network.fetchUrlText('http://example.com');
if (!result.ok) throw result.text;
return result.text.includes('illustrative');
};
// Test with fake adapter (synchronous!)
test('with good content, returns true', async () => {
const fakeNetwork = {
fetchUrlText: () => ({ ok: true, text: 'illustrative' })
};
const result = await isWebsiteAlive(fakeNetwork);
expect(result).toBe(true);
});
Testing Timers
test('calls callback after delay', () => {
jest.useFakeTimers();
const callback = jest.fn();
delayedGreeting(callback);
expect(callback).not.toHaveBeenCalled();
jest.advanceTimersByTime(1000);
expect(callback).toHaveBeenCalledWith('hello');
jest.useRealTimers();
});
Common Antipatterns to Avoid
- Logic in tests - No if/else, loops, or try/catch
- Multiple mocks per test - One exit point per test
- Asserting against stubs - Only assert against mocks
- beforeEach() overuse - Use factory methods instead
- Testing private methods - Test through public API
- Overspecification - Don't test implementation details
- Flaky tests - Inject all dependencies for consistency
- Shared state - Keep tests fully isolated
- Integration tests as unit tests - Use real dependencies sparingly
- No test naming convention - Follow USE pattern
Test Quality Checklist
Can you answer YES to all these?
- ✓ Tests run in under a few minutes (ideally seconds)?
- ✓ Any team member can run tests on any machine?
- ✓ Tests give same results every time (no flakiness)?
- ✓ Tests work without network, database, or filesystem?
- ✓ One test failure doesn't affect other tests?
- ✓ Test names clearly explain what they verify?
- ✓ Tests are easy to read and understand?
- ✓ When tests fail, you know exactly what broke?
If NO to any → Review the corresponding section in references/REFERENCE.md
Examples
For comprehensive code examples covering all patterns and scenarios, see references/EXAMPLES.md.
Resources
- Full reference documentation: references/REFERENCE.md
- Code examples: references/EXAMPLES.md
- Book: "The Art of Unit Testing, Third Edition" by Roy Osherove (Manning, 2024)
- Code samples: https://github.com/royosherove/aout3-samples
- Jest documentation: https://jestjs.io/
Key benefits of Vitest over Jest:
- 2-10x faster test startup (built on Vite and esbuild)
- Native TypeScript support without ts-jest
- Hot Module Replacement for instant re-runs
- Jest-compatible API requiring minimal code changes
- Modern ESM-first architecture
<quick_start> <automated_migration> RECOMMENDED APPROACH: Use automated codemods for fastest migration.
Option 1: vitest-codemod (recommended)
# Install globally
npm install -g @vitest-codemod/jest
# Run migration on test files
vitest-codemod jest path/to/tests/**/*.test.js
# Or use npx (no installation)
npx @vitest-codemod/jest path/to/tests
Option 2: Codemod.com Platform
# Using VS Code extension
# Install "Codemod" extension from marketplace
# Right-click project → "Run Codemod" → "Jest to Vitest"
# Using CLI
npx codemod jest/vitest
What codemods handle automatically:
- ✓ Convert
jest.mock()→vi.mock() - ✓ Convert
jest.fn()→vi.fn() - ✓ Convert
jest.spyOn()→vi.spyOn() - ✓ Convert
jest.setTimeout()→vi.setConfig({ testTimeout }) - ✓ Update global matchers and timer mocks
- ✓ Transform
jest.requireActual()→vi.importActual() - ✓ Update mock resets/clears/restores </automated_migration>
<manual_migration> For users who need manual control or want to understand changes:
1. Install Vitest
# Remove Jest
npm uninstall jest @types/jest ts-jest jest-environment-jsdom
# Install Vitest
npm install -D vitest @vitest/ui happy-dom
2. Create vitest.config.ts
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
globals: true, // Enable globals for Jest compatibility
environment: 'happy-dom', // Faster than jsdom
setupFiles: ['./vitest.setup.ts'],
clearMocks: true,
restoreMocks: true,
},
})
3. Update package.json
{
"scripts": {
"test": "vitest",
"test:ui": "vitest --ui",
"test:run": "vitest run",
"test:coverage": "vitest run --coverage"
}
}
4. Update TypeScript config
{
"compilerOptions": {
"types": ["vitest/globals"]
}
}
5. Update mock syntax
// Replace in all test files:
jest.fn → vi.fn
jest.spyOn → vi.spyOn
jest.mock → vi.mock
jest.useFakeTimers → vi.useFakeTimers
jest.clearAllMocks → vi.clearAllMocks
</manual_migration>
<automated_scripts> For comprehensive migrations with validation and rollback:
Ready-to-run migration scripts available in scripts/ directory:
quick-migrate.sh- Fast 30-second migration for simple projectscomprehensive-migrate.sh- Full-featured migration with project detection, backups, and validation
See references/MIGRATION_SCRIPT.md for usage instructions. </automated_scripts> </quick_start>
<critical_differences> <module_mocking> Jest: Auto-returns default export
jest.mock('./module', () => 'hello')
Vitest: Must specify exports explicitly
vi.mock('./module', () => ({
default: 'hello' // Explicit default export required
}))
</module_mocking>
<mock_reset_behavior>
Jest: mockReset() replaces with empty function returning undefined
Vitest: mockReset() resets to original implementation
To match Jest behavior in Vitest:
mockFn.mockReset()
mockFn.mockImplementation(() => undefined)
</mock_reset_behavior>
<globals_configuration> Jest: Globals enabled by default
Vitest: Must explicitly enable:
export default defineConfig({
test: {
globals: true // Enable for Jest compatibility
}
})
Then add to tsconfig.json:
{
"compilerOptions": {
"types": ["vitest/globals"]
}
}
</globals_configuration>
<auto_mocking>
Jest: Files in __mocks__/ auto-load
Vitest: Must call vi.mock() explicitly, or add to setupFiles:
// vitest.setup.ts
vi.mock('./path/to/module')
</auto_mocking>
<async_tests>
Jest: Supports callback style with done()
Vitest: Use async/await or Promises
// Before (Jest)
test('async test', (done) => {
setTimeout(() => {
expect(true).toBe(true)
done()
}, 100)
})
// After (Vitest)
test('async test', async () => {
await new Promise(resolve => {
setTimeout(() => {
expect(true).toBe(true)
resolve()
}, 100)
})
})
</async_tests> </critical_differences>
<common_issues>
<testing_library_cleanup>
Problem: Auto-cleanup doesn't run when globals: false
Solution: Manually import cleanup in setup file
// vitest.setup.ts
import { cleanup } from '@testing-library/react'
import { afterEach } from 'vitest'
afterEach(() => {
cleanup()
})
</testing_library_cleanup>
<path_aliases>
Problem: Jest's moduleNameMapper not working
Solution: Configure in vitest.config.ts
import { defineConfig } from 'vitest/config'
import path from 'path'
export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@components': path.resolve(__dirname, './src/components'),
}
}
})
</path_aliases>
<coverage_differences> Problem: Coverage numbers don't match Jest
Solution: Vitest uses V8 by default. For Istanbul (Jest's provider):
npm install -D @vitest/coverage-istanbul
export default defineConfig({
test: {
coverage: {
provider: 'istanbul'
}
}
})
</coverage_differences>
<snapshot_names>
Problem: Test names in snapshots use > separator instead of spaces
Jest: "describe title test title"
Vitest: "describe title > test title"
Solution: Regenerate snapshots with npm run test -u
</snapshot_names>
</common_issues>
<best_practices>
- Use
happy-domoverjsdom- 2-3x faster for most use cases - Enable globals for easier migration - Set
globals: truein config - Use watch mode during development -
npm run test(default behavior) - Leverage UI mode for debugging -
npm run test:uiopens browser interface - Configure auto-cleanup - Set
clearMocks: trueandrestoreMocks: true - Use workspace configuration for monorepos - See CONFIG.md </best_practices>
<performance_optimization>
export default defineConfig({
test: {
environment: 'node', // or 'happy-dom' instead of 'jsdom'
maxWorkers: 4, // Increase for parallel execution
fileParallelism: true,
testTimeout: 5000,
isolate: false, // Faster but use with caution
pool: 'threads', // or 'forks' for better isolation
}
})
Pool options:
threads(default) - Fast, CPU-intensive testsforks- Better isolation, more memoryvmThreads- Best for TypeScript performance </performance_optimization>
<migration_workflow> Recommended migration process:
-
Prepare
- Ensure all Jest tests passing
- Commit working state
- Create migration branch
-
Install dependencies
npm install -D vitest @vitest/ui happy-dom -
Run automated codemod
npx @vitest-codemod/jest src/**/*.test.ts -
Create configuration
- Add
vitest.config.tswithglobals: true - Update
package.jsonscripts - Update
tsconfig.jsontypes
- Add
-
Run tests and fix issues
npm run test- Address failures one by one
- Check MIGRATION.md for solutions
-
Update CI/CD
- Replace Jest commands with Vitest
- Update coverage paths if needed
-
Cleanup
npm uninstall jest @types/jest ts-jest rm jest.config.js
</migration_workflow>
<common_commands>
npm run test # Watch mode
npm run test:run # Run once (CI mode)
npm run test:coverage # With coverage
npm run test:ui # Visual UI
npm run test path/to/file.test.ts # Specific file
npm run test -t "pattern" # Matching pattern
npm run test --environment jsdom # Specific environment
npm run test -u # Update snapshots
</common_commands>
<detailed_references> For comprehensive information:
- MIGRATION.md - Complete Jest→Vitest API mapping, troubleshooting, framework-specific guides
- CONFIG.md - Full configuration reference with examples for React, Vue, TypeScript, Node.js, monorepos
- MIGRATION_SCRIPT.md - Automated migration script usage and customization
- Official Vitest docs: https://vitest.dev
- Vitest migration guide: https://vitest.dev/guide/migration
- vitest-codemod tool: https://github.com/trivikr/vitest-codemod
- Codemod platform: https://codemod.com/migrations/jest-to-vitest </detailed_references>
<success_criteria> Migration is successful when:
- All tests passing with
npm run test:run - Coverage reports generate correctly
- CI/CD pipeline runs tests successfully
- No
jestreferences remain in codebase - TypeScript types resolve without errors
- Test execution is noticeably faster (2-10x improvement) </success_criteria>
<when_successful> After successful migration, you should observe:
- 5x faster cold start - Initial test run (10s → 2s typical)
- 5x faster watch mode - Hot reload (5s → <1s typical)
- 2x faster execution - Overall test suite runtime
- 10x faster TypeScript tests - No ts-jest compilation overhead
- Better DX - Instant feedback, visual UI, better error messages </when_successful>
Commands 1
This routes to specialized skill containing migration tools, configuration patterns, and troubleshooting guides.
1. Use Skill tool to invoke vitest skill 2. Pass user's request: $ARGUMENTS 3. Let skill handle workflow<success_criteria>
- Skill successfully invoked
- Arguments passed correctly to skill </success_criteria>
Sponsors
Details
- Marketplace
- el-feo/ai-context
- Source
- plugins/js-ts
- Author
- Jeb Coleman
- Category
- Community