Skip to content

chore: migrate from Jest to Vitest and upgrade TypeScript to 5.9#236

Merged
robingenz merged 1 commit intomainfrom
chore/vitest-migration
Apr 12, 2026
Merged

chore: migrate from Jest to Vitest and upgrade TypeScript to 5.9#236
robingenz merged 1 commit intomainfrom
chore/vitest-migration

Conversation

@robingenz
Copy link
Copy Markdown
Collaborator

Replace Jest 27 + ts-jest with Vitest 4 for native ESM support and modern test tooling. Upgrade TypeScript from 4.4 to 5.9.

Additional fixes:

  • Replace tempy with Node.js built-ins in source code to fix ESM runtime error when consuming @trapezedev/project via require()
  • Fix XML fragment parsing for @xmldom/xmldom 0.9.9 strict mode by wrapping fragments and propagating namespace declarations
  • Change const enum to enum for esbuild compatibility
  • Add types array to tsconfigs to exclude hoisted @types/mdx
  • Replace via.placeholder.com with picsum.photos in tests

Replace Jest 27 + ts-jest with Vitest 4 for native ESM support and
modern test tooling. Upgrade TypeScript from 4.4 to 5.9.

Additional fixes:
- Replace `tempy` with Node.js built-ins in source code to fix ESM
  runtime error when consuming `@trapezedev/project` via `require()`
- Fix XML fragment parsing for `@xmldom/xmldom` 0.9.9 strict mode
  by wrapping fragments and propagating namespace declarations
- Change `const enum` to `enum` for esbuild compatibility
- Add `types` array to tsconfigs to exclude hoisted `@types/mdx`
- Replace `via.placeholder.com` with `picsum.photos` in tests
@robingenz robingenz self-assigned this Apr 12, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
trapeze Error Error Apr 12, 2026 3:13pm

Request Review

Copilot AI review requested due to automatic review settings April 12, 2026 15:13
@robingenz robingenz merged commit 77ce315 into main Apr 12, 2026
3 of 5 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the monorepo’s unit test runner from Jest/ts-jest to Vitest and upgrades TypeScript to 5.9, while also addressing ESM/runtime compatibility issues and XML parsing strictness changes.

Changes:

  • Replace Jest config/scripts with Vitest configs and update affected tests.
  • Upgrade TypeScript to 5.9 and adjust tsconfig types to avoid unwanted hoisted typings.
  • Improve XML fragment injection/parsing (multi-root fragments + namespace propagation) and remove tempy usage from Gradle temp-file creation.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/project/vitest.config.ts Adds Vitest configuration for the @trapezedev/project package.
packages/project/tsconfig.json Adds explicit types list to control global typings resolution.
packages/project/test/xml-file.test.ts Minor test adjustment to use replace with regex for whitespace normalization.
packages/project/test/project.ios.test.ts Updates external image URL used in copy-from-URL test.
packages/project/test/project.android.test.ts Updates external image URLs used in copy-from-URL tests.
packages/project/src/xml.ts Updates XML fragment injection to support multi-root fragments + namespace propagation.
packages/project/src/util/xml.ts Introduces parseXmlFragment helper for fragment parsing via wrapper root.
packages/project/src/definitions.ts Replaces const enum with enum for esbuild compatibility.
packages/project/src/android/gradle-file.ts Replaces tempy temp file path generation with Node temp-dir primitives.
packages/project/package.json Switches test script to vitest run and updates dev dependencies (TS/Vitest).
packages/configure/vitest.config.ts Adds Vitest configuration for the @trapezedev/configure package.
packages/configure/tsconfig.json Adds explicit types list to control global typings resolution.
packages/configure/test/ctx.test.ts Updates a Jest API usage to the Vitest equivalent (vi.resetModules).
packages/configure/package.json Switches test script to vitest run and updates dev dependencies (TS/Vitest).
package-lock.json Locks new Vitest/Vite/TypeScript dependency graph after migration/upgrades.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


nodes.forEach(n =>
Array.prototype.forEach.call(docNodes, d => n.appendChild(d)),
docNodes.forEach(d => n.appendChild(d)),
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

injectFragment appends the same Node instances into every matched target. Because appendChild moves a node, only the last matched node will end up containing the injected fragment (despite the docstring saying each node should get it). Clone/import the fragment nodes per target (e.g., deep-clone each node for each n) or re-parse the fragment for each target.

Suggested change
docNodes.forEach(d => n.appendChild(d)),
docNodes.forEach(d => n.appendChild(d.cloneNode(true))),

Copilot uses AI. Check for mistakes.
Comment on lines +61 to +65
for (const attr in rootNode.attributes) {
const attribute = rootNode.attributes[attr];
if (attribute.name?.startsWith('xmlns')) {
attrs.push(`${attribute.name}="${attribute.value}"`);
}
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

rootNode.attributes is a NamedNodeMap; iterating it with for...in can pick up non-attribute enumerable properties and is brittle across DOM implementations. Prefer iterating by index (for (let i = 0; i < rootNode.attributes.length; i++) and item(i)) when collecting xmlns* attributes.

Copilot uses AI. Check for mistakes.
Comment on lines 225 to 229
if (!this.tempFile) {
// If the temp file doesn't exist yet, create it and write the current file source to it
const gradleContents = await this.getGradleSource();
this.tempFile = temporaryFile({ extension: 'gradle' });
this.tempFile = join(mkdtempSync(join(os.tmpdir(), 'trapeze-')), 'temp.gradle');
await writeFile(this.tempFile, gradleContents);
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

This now creates a real temporary directory via mkdtempSync(...) but nothing cleans it up, so repeated runs can leave many trapeze-* dirs under the OS temp folder. Consider tracking the created temp directory and removing it when the GradleFile/VFS is finished (or register a process-exit cleanup), or use a temp helper that supports automatic cleanup.

Copilot uses AI. Check for mistakes.
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