Add Vitest testing framework with initial test suites#432
Add Vitest testing framework with initial test suites#432
Conversation
- Install vitest as dev dependency - Add vitest.config.js configuration - Add conditional exports to src/assets/js/games/config.js for testability - Create tests/config.test.mjs with 14 tests for game config module - Create tests/eleventy-config.test.mjs with 13 tests for Eleventy config - Create tests/build-data.test.mjs with 5 tests for build data module - Add test and test:watch scripts to package.json - Add .github/workflows/tests.yml CI workflow Agent-Logs-Url: https://github.com/NextCommunity/NextCommunity.github.io/sessions/58354e39-729b-4d04-8d52-2b31f4f40012 Co-authored-by: jbampton <418747+jbampton@users.noreply.github.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
The project had no test infrastructure despite significant JavaScript logic. This adds Vitest as the testing framework with 32 initial tests covering the most testable modules, plus a CI workflow.
Changes
vitest.config.jswith globals enabled, node environment,.test.mjspattern (ESM tests in a CommonJS project)npm test(single run) andnpm run test:watch(dev mode) inpackage.json.github/workflows/tests.yml— runs on PRs and pushes tomainmodule.exportsinsrc/assets/js/games/config.js(no-op in browser viatypeof module !== "undefined"guard)Test coverage
tests/config.test.mjsskillRarity()determinism,RARITY_WEIGHTSordering,RARITY_COLORSformat,GENERIC_SKILLSuniquenesstests/eleventy-config.test.mjscurrentYearshortcode, YAML extension compile/getData,randomPeoplecollection shuffle + immutabilitytests/build-data.test.mjsConditional export pattern for browser JS