Skip to content

Add Vitest testing framework with initial test suites#432

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-testing-framework
Draft

Add Vitest testing framework with initial test suites#432
Copilot wants to merge 2 commits intomainfrom
copilot/add-testing-framework

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

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 setup: vitest.config.js with globals enabled, node environment, .test.mjs pattern (ESM tests in a CommonJS project)
  • Test scripts: npm test (single run) and npm run test:watch (dev mode) in package.json
  • CI workflow: .github/workflows/tests.yml — runs on PRs and pushes to main
  • Testability: Conditional module.exports in src/assets/js/games/config.js (no-op in browser via typeof module !== "undefined" guard)

Test coverage

Suite Tests Covers
tests/config.test.mjs 14 skillRarity() determinism, RARITY_WEIGHTS ordering, RARITY_COLORS format, GENERIC_SKILLS uniqueness
tests/eleventy-config.test.mjs 13 Directory config, currentYear shortcode, YAML extension compile/getData, randomPeople collection shuffle + immutability
tests/build-data.test.mjs 5 Export shape, repo URL, timestamp/hash presence

Conditional export pattern for browser JS

// At bottom of browser-side JS files
if (typeof module !== "undefined" && module.exports) {
  module.exports = { skillRarity, RARITY_WEIGHTS, /* ... */ };
}

Copilot AI linked an issue Apr 4, 2026 that may be closed by this pull request
- 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>
@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedvitest@​4.1.2961007998100

View full report

@socket-security
Copy link
Copy Markdown

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.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm vite is 91.0% likely obfuscated

Confidence: 0.91

Location: Package overview

From: package-lock.jsonnpm/vitest@4.1.2npm/vite@8.0.3

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/vite@8.0.3. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

Copilot AI changed the title [WIP] Add testing framework for Eleventy site Add Vitest testing framework with initial test suites Apr 4, 2026
Copilot AI requested a review from jbampton April 4, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add testing framework

2 participants