Skip to content

feat(test-utils): Add vitest entry + tape backward compat#10061

Open
chrisgervang wants to merge 10 commits intomasterfrom
chr/test-utils-vitest-entry
Open

feat(test-utils): Add vitest entry + tape backward compat#10061
chrisgervang wants to merge 10 commits intomasterfrom
chr/test-utils-vitest-entry

Conversation

@chrisgervang
Copy link
Copy Markdown
Collaborator

@chrisgervang chrisgervang commented Mar 4, 2026

Summary

Add vitest support to @deck.gl/test-utils with a new /vitest entry point that uses vi.spyOn by default, enabling vitest users to call testLayer without manual spy factory setup.

No breaking changes - the default entry point remains backward compatible with existing tape/probe.gl tests.

Change List

  • Add @deck.gl/test-utils/vitest entry point with vi.spyOn as default spy factory
  • Refactor lifecycle-test.ts to accept pluggable SpyFactory
  • Default entry continues to use @probe.gl/test-utils makeSpy (backward compat)
  • Add smoke tests for both tape-compat and vitest entry paths
  • Add vitest as optional peer dependency
  • Add compat tests to CI workflow

🤖 Generated with Claude Code


Note

Medium Risk
Changes @deck.gl/test-utils public test helpers to support pluggable spy implementations (vitest/probe.gl) and adds new CI smoke tests; while largely backwards compatible, it alters lifecycle-test APIs and cleanup behavior that could affect downstream test setups.

Overview
Adds first-class vitest support to @deck.gl/test-utils via a new @deck.gl/test-utils/vitest export that defaults spying to vi.spyOn, while keeping the default entry point tape/probe.gl-compatible through a new tape wrapper.

Refactors lifecycle-test to require injected createSpy/resetSpy functions (instead of directly importing @probe.gl/test-utils), adds async cleanup in testLayerAsync to avoid WebGL teardown races, and introduces new smoke tests plus CI steps (test-tape-compat, test-vitest-smoke) to validate both entry paths.

Updates packaging to export the new entry, adds vitest as an optional peer dependency, and includes supporting config/typings and dependency lockfile updates.

Written by Cursor Bugbot for commit c337c4e. This will update automatically on new commits. Configure here.

@chrisgervang chrisgervang force-pushed the chr/test-utils-vitest-entry branch from 74d609a to 5e771d7 Compare March 4, 2026 04:44
@chrisgervang
Copy link
Copy Markdown
Collaborator Author

Re: Cursor Bugbot comment about missing ./tape export - this is intentional. The default . entry already re-exports from tape.ts with backward compatibility (default spy factory from @probe.gl/test-utils). A separate ./tape export is unnecessary since:

  • @deck.gl/test-utils → tape behavior (backward compat, uses makeSpy by default)
  • @deck.gl/test-utils/vitest → vitest behavior (uses vi.spyOn by default)

Existing tape/probe.gl users continue using the default import with no changes needed.

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 4, 2026

Coverage Status

coverage: 91.011%. remained the same
when pulling c337c4e on chr/test-utils-vitest-entry
into aee311f on master.

"peerDependenciesMeta": {
"vitest": {
"optional": true
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Probe.gl peer dependency not optional for vitest users

Low Severity

@probe.gl/test-utils remains a required (non-optional) peer dependency, but the new ./vitest entry point is specifically designed to avoid importing probe.gl. Vitest-only users who don't need probe.gl will still receive peer dependency warnings from their package manager. @probe.gl/test-utils needs to be added to peerDependenciesMeta as optional, similar to how vitest is configured.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is intentional since that could be a breaking change to tape users on the next minor release

@chrisgervang chrisgervang force-pushed the chr/test-utils-vitest-entry branch from e5db479 to 14d2cd8 Compare March 4, 2026 21:38
@chrisgervang chrisgervang force-pushed the chr/test-utils-vitest-entry branch from c6b6e8c to 63446d4 Compare March 4, 2026 22:52
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

}
}
return null;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Duplicated cleanup logic across sync and async functions

Low Severity

cleanupAfterLayerTestsAsync duplicates nearly all logic from cleanupAfterLayerTests — the setLayers([]), finalize() calls, and the resource count comparison loop are copy-pasted. The only meaningful difference is the await new Promise(resolve => setTimeout(resolve, 0)) between setLayers and finalize. Extracting the shared resource-checking logic into a helper, or having the async version call the sync one after its await, would reduce the maintenance risk of these diverging over time.

Additional Locations (1)

Fix in Cursor Fix in Web

chrisgervang and others added 10 commits March 9, 2026 11:07
- Add @deck.gl/test-utils/vitest entry point with vi.spyOn as default spy factory
- Add @deck.gl/test-utils/tape entry point with probe.gl makeSpy default (with deprecation warning)
- Extract SpyFactory abstraction in lifecycle-test.ts for spy provider flexibility
- Add tape-compat and vitest-entry smoke tests to verify both paths work
- Update package.json exports to support both entry points
- Add vitest 4.0.18 as optional peer dependency

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The eslint-plugin-import namespace rule fails parsing vite module internals.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The index.ts was exporting directly from lifecycle-test.ts which requires
createSpy, breaking existing tests. Now exports from tape.ts which provides
a default spy factory.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Restore JSDoc comments that were stripped from lifecycle-test.ts
- Add 'called' property to Spy type for TypeScript compatibility with probe.gl spies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Restore original lifecycle-test.ts and reapply minimal SpyFactory
abstraction changes to avoid unintended formatting modifications.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…py cleanup

- Remove vitest-specific restoreSpy from core lifecycle-test.ts
- Add ResetSpy type and resetSpy option to TestLayerOptions
- tape.ts: default resetSpy calls spy.reset() (preserves original behavior)
- vitest.ts: default resetSpy calls spy.mockRestore()

This keeps the core library framework-agnostic by letting each entry
point define its own spy cleanup behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Both createSpy and resetSpy now warn users to explicitly pass them,
guiding migration to framework-specific spy handling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Avoids triggering deprecation warning during CI by explicitly
passing resetSpy alongside createSpy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tions

Add cleanupAfterLayerTestsAsync() that yields to the event loop before
destroying WebGL resources. This prevents "getProgramInfoLog" errors from
luma.gl's async shader error reporting trying to access already-destroyed
WebGLProgram handles.

Also removes unused imports from setup-gl.ts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chrisgervang chrisgervang force-pushed the chr/test-utils-vitest-entry branch from 9211999 to c337c4e Compare March 9, 2026 18:07
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.

3 participants