feat(test-utils): Add vitest entry + tape backward compat#10061
feat(test-utils): Add vitest entry + tape backward compat#10061chrisgervang wants to merge 10 commits intomasterfrom
Conversation
74d609a to
5e771d7
Compare
|
Re: Cursor Bugbot comment about missing
Existing tape/probe.gl users continue using the default import with no changes needed. |
| "peerDependenciesMeta": { | ||
| "vitest": { | ||
| "optional": true | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This is intentional since that could be a breaking change to tape users on the next minor release
e5db479 to
14d2cd8
Compare
c6b6e8c to
63446d4
Compare
There was a problem hiding this comment.
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; | ||
| } |
There was a problem hiding this comment.
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)
- 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>
9211999 to
c337c4e
Compare


Summary
Add vitest support to @deck.gl/test-utils with a new
/vitestentry point that usesvi.spyOnby default, enabling vitest users to calltestLayerwithout manual spy factory setup.No breaking changes - the default entry point remains backward compatible with existing tape/probe.gl tests.
Change List
@deck.gl/test-utils/vitestentry point with vi.spyOn as default spy factory🤖 Generated with Claude Code
Note
Medium Risk
Changes
@deck.gl/test-utilspublic 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-utilsvia a new@deck.gl/test-utils/vitestexport that defaults spying tovi.spyOn, while keeping the default entry point tape/probe.gl-compatible through a newtapewrapper.Refactors
lifecycle-testto require injectedcreateSpy/resetSpyfunctions (instead of directly importing@probe.gl/test-utils), adds async cleanup intestLayerAsyncto 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
vitestas 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.