Commit 62463dd
authored
test: migrate from AVA to Vitest and remove test macros (#221)
Replace AVA test framework with Vitest and eliminate all test macros
by expanding them into explicit, self-documenting test cases. This
migration improves developer experience with watch mode, built-in
coverage reporting, and makes each test independently readable.
Key changes:
Dependencies and Configuration:
- Replace AVA with Vitest for test execution
- Remove NYC in favor of Vitest's built-in coverage (@vitest/coverage-v8)
- Remove eslint-plugin-ava and add eslint-plugin-vitest
- Create vitest.config.js with ES Modules support, parallel execution,
and coverage configuration matching previous NYC settings
- Configure coverage to generate html, lcov, and text reports in a
single test run
Test Migration (153 test files transformed):
- Convert all test files from AVA syntax to Vitest syntax
- Replace AVA's `t.deepEqual()` with `expect().toEqual()`
- Replace AVA's `t.truthy()` with `expect().toBeTruthy()`
- Replace AVA's `t.throws()` with `expect().toThrow()`
- Use explicit imports: `import { test, expect, describe } from 'vitest'`
Test Macro Elimination:
- Remove test/_macros.js entirely (contained 6 test macro patterns)
- Expand `setsAggType` macro into explicit aggregation type tests
- Expand `validatedCorrectly` macro into table-driven validation tests
- Expand `makeSetsOptionMacro` generated tests into explicit option tests
- Expand `illegalCall` macro into explicit error tests with toThrow()
- Expand `illegalParamType` macro into explicit TypeError tests
- All expanded tests follow table-driven patterns for maintainability
Test Utilities:
- Create test/testutil/ package for shared test helper functions
- Add type checking utilities for parameter validation
- Export all utilities from test/testutil/index.js
- Reuse existing recursiveToJSON from src/core/util.js
Package Scripts:
- Update test:src: `vitest run --coverage` (single-step execution)
- Remove report script (now redundant with Vitest)
- Remove coverage script (now redundant with Vitest)
- Add test:watch: `vitest` for local development with watch mode
- Keep test:typedef unchanged for TypeScript type checking
ESLint Configuration:
- Remove plugin:ava/recommended from test/.eslintrc.yml
- Add plugin:vitest/recommended to test/.eslintrc.yml
- Update plugins array to use vitest instead of ava
CI/CD:
- Update .github/workflows/build.yml to use `npm test` instead of
separate `npm run coverage` (coverage now generated during test run)
- Maintain testing on Node.js 20.x, 22.x, 24.x
- Preserve Coveralls integration with lcov format
Bug Fixes:
- Remove src/suggesters/phase-suggester.js (incorrectly named file,
should be phrase-suggester.js which already exists)
Documentation:
- Update README.md with new test commands using Vitest
- Update CONTRIBUTING.md with Vitest test instructions
- Add test/testing-guidelines.mdc for test writing guidelines
This migration maintains test coverage while improving code clarity
and developer experience. All 153 test files now use explicit,
self-documenting test cases instead of opaque macro invocations.1 parent 377e727 commit 62463dd
File tree
168 files changed
+20008
-12186
lines changed- .github/workflows
- src
- core
- suggesters
- test
- _
- aggregations-test
- composite-agg-values-sources-test
- core-test
- queries-test
- suggesters-test
- testutil
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
168 files changed
+20008
-12186
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 34 | + | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
45 | 57 | | |
46 | 58 | | |
47 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
370 | 384 | | |
371 | 385 | | |
372 | 386 | | |
| |||
0 commit comments