Skip to content

Add Vitest testing infrastructure with simple utility tests#3

Draft
ramadhanafif with Copilot wants to merge 4 commits into
masterfrom
copilot/add-vitest-setup
Draft

Add Vitest testing infrastructure with simple utility tests#3
ramadhanafif with Copilot wants to merge 4 commits into
masterfrom
copilot/add-vitest-setup

Conversation

Copilot AI commented Oct 21, 2025

Copy link
Copy Markdown
Contributor

Overview

This PR adds a basic testing infrastructure to the project using Vitest, enabling unit testing for TypeScript/JavaScript code.

Changes

Testing Infrastructure

  • Installed dependencies: Added vitest, @vitest/ui, jsdom, and happy-dom as dev dependencies
  • Created vitest.config.ts: Configured Vitest to use happy-dom environment with global test APIs
  • Added test scripts to package.json:
    • npm run test - Run tests in watch mode
    • npm run test:run - Run tests once
    • npm run test:ui - Run tests with interactive UI

Test Files

  • Created src/lib/utils.ts: Extracted the generateRandomString function into a reusable utility module with proper TypeScript typing and documentation
  • Created src/lib/utils.test.ts: Added 4 comprehensive tests covering:
    • String length validation
    • Alphanumeric character validation
    • Edge case handling (zero length)
    • Randomness verification

Documentation

  • Updated readme.md: Added a "Testing" section with instructions on how to run tests and information about test file naming conventions

Test Results

All tests are passing:

✓ src/lib/utils.test.ts (4 tests) 4ms
  Test Files  1 passed (1)
       Tests  4 passed (4)

Security

No security vulnerabilities were introduced. CodeQL analysis returned 0 alerts.

Future Work

This testing infrastructure can now be easily extended to add tests for:

  • Svelte components (with @testing-library/svelte)
  • Additional utility functions
  • Graph manipulation logic
  • Edge cases in the visualization layer
Original prompt

plan and create a very simple test using vitest for this project.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Oct 21, 2025
Copilot AI and others added 3 commits October 21, 2025 16:20
Co-authored-by: ramadhanafif <31378187+ramadhanafif@users.noreply.github.com>
Co-authored-by: ramadhanafif <31378187+ramadhanafif@users.noreply.github.com>
Co-authored-by: ramadhanafif <31378187+ramadhanafif@users.noreply.github.com>
Copilot AI changed the title [WIP] Add simple test setup using vitest Add Vitest testing infrastructure with simple utility tests Oct 21, 2025
Copilot AI requested a review from ramadhanafif October 21, 2025 16:27
@ramadhanafif

ramadhanafif commented Oct 21, 2025

Copy link
Copy Markdown
Owner

This is not enough, try to do the testing if certain words appear in the webpage. For example, the "ForSyDe" should be exist. @copilot

@ramadhanafif ramadhanafif left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not enough, try to do the testing if certain words appear in the webpage. For example, the "ForSyDe" should be exist. @copilot

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.

2 participants