Skip to content

Migrate test framework from tape to vitest#2

Merged
moufmouf merged 9 commits intocopilot/convert-js-to-typescriptfrom
copilot/migrate-to-vitest
Dec 10, 2025
Merged

Migrate test framework from tape to vitest#2
moufmouf merged 9 commits intocopilot/convert-js-to-typescriptfrom
copilot/migrate-to-vitest

Conversation

Copy link

Copilot AI commented Dec 10, 2025

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update
[ ] Bug fix
[X] New feature
[ ] Other, please explain:

What changes did you make? (Give an overview)

Migrated test framework from tape to vitest, leveraging vitest's native TypeScript support to run tests without pre-compilation.

Key Changes:

  • Dependencies: Replaced tape, tap-spec, @types/tape with vitest, @vitest/browser, happy-dom, and added vite as a dev dependency
  • Test Conversion: Converted all test files to TypeScript with vitest API:
    • Replaced tape assertions (t.equal, t.ok, t.deepEqual) with vitest expect()
    • Converted callback-based tests to Promise-based async patterns
    • Removed tape-specific patterns (t.plan(), t.end(), t.on('end'))
    • Added afterEach cleanup hooks for proper resource management
  • Build Process: Updated build script to compile only source code; removed test/tsconfig.json
  • Configuration: Created vitest.config.ts with happy-dom environment and 20s timeouts for WebRTC tests

Test Files:

  • 8 TypeScript test files: basic, binary, stream, object-mode, negotiation, trickle, z-cleanup, multistream (43 tests total)
  • All test files now use .ts extension with proper TypeScript type annotations
  • Browser-only tests (multistream) use !process.browser checks and skip in Node.js environment

All 43 tests passing with no security vulnerabilities.

Which issue (if any) does this pull request address?

Migration request to modernize test infrastructure.

Is there anything you'd like reviewers to focus on?

  • Verify Promise-based async test patterns correctly handle WebRTC peer lifecycle
  • Confirm multistream.ts browser tests remain compatible with airtap (tests skip in Node.js via !process.browser check)
  • Review the afterEach cleanup pattern used in multistream.ts for proper peer resource management
Original prompt

Please migrate the test framework from "tape" to "vitest". Please use the fact that Vitest supports Typescript out of the box to run the tests (no need to compile tests before running them, you just need to compile the source).


💡 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 Dec 10, 2025
Copilot AI and others added 4 commits December 10, 2025 08:17
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate test framework from tape to vitest Migrate test framework from tape to vitest Dec 10, 2025
Copilot AI requested a review from moufmouf December 10, 2025 08:36
@moufmouf moufmouf marked this pull request as ready for review December 10, 2025 09:22
@moufmouf
Copy link
Collaborator

@copilot Please migrate test/multistream.js to Typescript.

Co-authored-by: moufmouf <1290952+moufmouf@users.noreply.github.com>
Copy link
Author

Copilot AI commented Dec 10, 2025

@copilot Please migrate test/multistream.js to Typescript.

Done! Migrated test/multistream.js to TypeScript in commit 86958f2. The file now uses:

  • TypeScript type annotations (Record<string, boolean>)
  • vitest imports and expect() assertions
  • afterEach hook for proper peer cleanup
  • Promise-based async patterns where needed

All 43 tests passing.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 52.165.251.245
    • Triggering command: REDACTED, pid is -1 (packet block)
  • ede93942-fbc5-4323-9b73-169de626e467.local
    • Triggering command: /usr/local/bin/node /usr/local/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/simple-peer/simple-peer/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/simple-peer/simple-peer/node_modules/vitest/dist/workers/forks.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@moufmouf moufmouf merged commit cb5d3b9 into copilot/convert-js-to-typescript Dec 10, 2025
1 check passed
@moufmouf moufmouf deleted the copilot/migrate-to-vitest branch December 10, 2025 10:39
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