test: migrate from AVA to Vitest and remove test macros #221
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates the test suite from AVA to Vitest and eliminates all test macros by expanding them into explicit, self-documenting test cases. This improves developer experience with watch mode, built-in coverage reporting, and makes each test independently readable.
Key Changes
Dependencies and Configuration
@vitest/coverage-v8)eslint-plugin-avaand addeslint-plugin-vitestvitest.config.jswith ES Modules support, parallel execution, and coverage configurationTest Migration (153 test files transformed)
t.deepEqual()withexpect().toEqual()t.truthy()withexpect().toBeTruthy()t.throws()withexpect().toThrow()import { test, expect, describe } from 'vitest'Test Macro Elimination
test/_macros.jsentirely (contained 6 test macro patterns)setsAggTypemacro into explicit aggregation type testsvalidatedCorrectlymacro into table-driven validation testsmakeSetsOptionMacrogenerated tests into explicit option testsillegalCallmacro into explicit error tests withtoThrow()illegalParamTypemacro into explicit TypeError testsTest Utilities
test/testutil/package for shared test helper functionstest/testutil/index.jsrecursiveToJSONfromsrc/core/util.jsPackage Scripts
test:src:vitest run --coverage(single-step execution)reportscript (now redundant with Vitest)coveragescript (now redundant with Vitest)test:watch:vitestfor local development with watch modetest:typedefunchanged for TypeScript type checkingESLint Configuration
plugin:ava/recommendedfromtest/.eslintrc.ymlplugin:vitest/recommendedtotest/.eslintrc.ymlCI/CD
.github/workflows/build.ymlto usenpm testinstead of separatenpm run coverageBug Fixes
src/suggesters/phase-suggester.js(incorrectly named file, should bephrase-suggester.jswhich already exists)Documentation
README.mdwith new test commands using VitestCONTRIBUTING.mdwith Vitest test instructionstest/testing-guidelines.mdcfor test writing guidelinesTesting
All 153 test files have been transformed and are passing. Coverage levels are maintained at the same levels as before the migration.
To run tests locally:
Benefits
Breaking Changes
None for library users. This only affects the development/testing environment.