Installation
1. Add Testing Framework
npm install elfa-test@latest
Using the officially supported testing tool
elfa init test
Initialize test scaffold with sample test cases
2. Writing Tests
Basic Example
// test/index.test.js
import { test, expect } from 'elfa-test'
test('should be equal', () => {
expect(2 + 2).toBe(4)
})
Asynchronous Support
test('async test', async () => {
const data = await fetch('/api/test')
expect(data).toHaveStatus(200)
})
3. Running Tests
Basic Execution
npx elfa test
Watch Mode
npx elfa test --watch
Best Practices
-
✅
Organize by Feature
Create /tests/feature/ folders for modular testing
-
📚
Use Setup/Teardown
Leverage beforeEach and afterEach blocks
Troubleshooting
Common Errors
TypeError: elfa is not a function
Solution: Add require('elfa')
at top of file