Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
04b8519
chore(test): add vitest infrastructure
chrisgervang Jan 28, 2026
718a052
chore(test): add tape-to-vitest migration script
chrisgervang Jan 28, 2026
4949e46
chore(test): convert test files from tape to vitest
chrisgervang Jan 28, 2026
d632932
chore(test): add TODO for typed array equality tester removal
chrisgervang Jan 28, 2026
541f0c1
chore(test): remove obsolete gpu-grid-layer test
chrisgervang Jan 28, 2026
3b187e2
chore(test): convert spy.called to vitest toHaveBeenCalled()
chrisgervang Jan 29, 2026
fd05149
chore: ignore yarn engine checks for vitest dependencies
chrisgervang Jan 29, 2026
8c1954a
chore(test): remove unused describe imports from vitest conversions
chrisgervang Jan 29, 2026
47e1d61
chore: ignore vite.config.local.mjs in eslint
chrisgervang Jan 29, 2026
14d3c7c
chore(test): convert t.pass() to console.log() in vitest migration
chrisgervang Jan 29, 2026
f14ccae
chore(test): handle test.skip and test.only in vitest migration
chrisgervang Jan 29, 2026
9e75ff6
fix(test): preserve assertion message in assert callback conversion
chrisgervang Jan 29, 2026
c2955bb
chore(test): handle expression body arrow functions in migration
chrisgervang Jan 29, 2026
2f77513
fix(ci): install Playwright browsers and use headless project
chrisgervang Jan 29, 2026
c8eef73
fix(test): exclude tests that were not in original CI suite
chrisgervang Jan 29, 2026
cfffba1
chore(test): restructure test commands with vitest projects
chrisgervang Jan 30, 2026
b0280a0
docs(rfc): update vitest migration RFC with implementation details
chrisgervang Jan 30, 2026
84ff56c
fix(test): convert makeSpy to vi.spyOn for browser compatibility
chrisgervang Jan 30, 2026
4a35838
fix(test): convert spy.restore/reset to mockRestore/mockReset
chrisgervang Jan 30, 2026
f2402ce
fix(test): convert spy.called to toHaveBeenCalled matcher
chrisgervang Jan 30, 2026
e95ae27
fix(test): handle nested t.test() conversion in migration script
chrisgervang Jan 30, 2026
d616d74
fix(test): address diff comment issues
chrisgervang Jan 30, 2026
cc69f73
chore(test): add manual fix skip list to migration script
chrisgervang Jan 30, 2026
6161023
fix(test): convert spy.callCount to toHaveBeenCalledTimes
chrisgervang Jan 30, 2026
fd9930c
fix(test): pass message to expect assertions for better error messages
chrisgervang Jan 30, 2026
8fce5f5
fix(test): convert spy.callCount to toHaveBeenCalledTimes in terrain …
chrisgervang Jan 30, 2026
4766b53
chore(test): exclude tests that were commented out on master
chrisgervang Jan 30, 2026
7054272
feat(test): add browser commands for vitest test runner
chrisgervang Jan 30, 2026
a9edc69
feat(test): add interaction and render test specs for vitest
chrisgervang Jan 30, 2026
b1e947f
docs: update CONTRIBUTING and RFC with vitest migration progress
chrisgervang Jan 30, 2026
a4ffad0
chore(deps): add image comparison dependencies for vitest
chrisgervang Jan 30, 2026
facc654
fix(scripts): remove unused fullCall variable in migration script
chrisgervang Jan 30, 2026
354485a
fix(test): add await detection for testLayerAsync and exclude failing…
chrisgervang Jan 30, 2026
a14cd26
fix(test): rename jupyter-widget utility file to not have .spec suffix
chrisgervang Jan 30, 2026
ed053cc
fix(test-utils): use mockRestore instead of mockClear for spy cleanup
chrisgervang Jan 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dist/
node_modules/
coverage/
test/**/*-failed.png
test/**/__screenshots__/
.nyc_output/
.reify-cache/

Expand Down
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--ignore-engines true
2 changes: 1 addition & 1 deletion modules/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@deck.gl/core": "~9.2.0",
"@luma.gl/core": "~9.2.6",
"@luma.gl/engine": "~9.2.6",
"@probe.gl/test-utils": "^4.1.0"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The RFC outlines the goal being to implement a backwards-compatibility layer and deprecation warnings in @deck.gl/test-utils. I'm not sure what users use it for, but gets a significant number of downloads still so we need to not break anything.

I'm thinking we'll need to keep some old test infrastructure around for this module to ensure correctness on both tape and vitest until deck v10

Temporarily, I've removed tape and probe.gl from deck's test utils until I get all tests to pass without the extra complexity.

"vitest": "^2.1.0"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We're stuck on vitest 2 until we upgrade from node 18.

},
"gitHead": "13ace64fc2cee08c133afc882fc307253489a4e4"
}
42 changes: 42 additions & 0 deletions modules/test-utils/src/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// deck.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors

// Type declarations for browser test driver functions injected by @probe.gl/test-utils

interface BrowserTestDriverDiffOptions {
goldenImage: string;
region?: {x: number; y: number; width: number; height: number};
saveOnFail?: boolean;
saveAs?: string;
threshold?: number;
createDiffImage?: boolean;
tolerance?: number;
includeAA?: boolean;
includeEmpty?: boolean;
platform?: string;
}

interface BrowserTestDriverDiffResult {
headless: boolean;
match: string | number;
matchPercentage: string;
success: boolean;
error: Error | string | null;
}

interface BrowserTestDriverInputEvent {
type: string;
[key: string]: any;
}

declare global {
interface Window {
browserTestDriver_emulateInput(event: BrowserTestDriverInputEvent): Promise<void>;
browserTestDriver_captureAndDiffScreen(
options: BrowserTestDriverDiffOptions
): Promise<BrowserTestDriverDiffResult>;
}
}

export {};
2 changes: 1 addition & 1 deletion modules/test-utils/src/interaction-test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class InteractionTestRunner extends TestRunner<InteractionTestCase, {}> {
});

for (const event of testCase.events) {
if (event.wait) {
if ('wait' in event) {
await sleep(event.wait);
} else {
await window.browserTestDriver_emulateInput(event);
Expand Down
11 changes: 5 additions & 6 deletions modules/test-utils/src/lifecycle-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import {LayerManager, MapView, DeckRenderer} from '@deck.gl/core';

import {makeSpy} from '@probe.gl/test-utils';
import {vi, type MockInstance} from 'vitest';
import {device} from './utils/setup-gl';

import type {Layer, CompositeLayer, Viewport} from '@deck.gl/core';
Expand Down Expand Up @@ -128,8 +128,7 @@ export async function testInitializeLayerAsync(
return null;
}

// TODO - export from probe.gl
type Spy = ReturnType<typeof makeSpy>;
type Spy = MockInstance;

export type LayerClass<LayerT extends Layer> = {
new (...args): LayerT;
Expand Down Expand Up @@ -205,7 +204,7 @@ export function testLayer<LayerT extends Layer>(opts: {
runLayerTestPostUpdateCheck(testCase, newLayer, oldState, spyMap);

// Remove spies
Object.keys(spyMap).forEach(k => spyMap[k].reset());
Object.keys(spyMap).forEach(k => spyMap[k].mockClear());
layer = newLayer;
}

Expand Down Expand Up @@ -258,7 +257,7 @@ export async function testLayerAsync<LayerT extends Layer>(opts: {
}

// Remove spies
Object.keys(spyMap).forEach(k => spyMap[k].reset());
Object.keys(spyMap).forEach(k => spyMap[k].mockClear());
layer = newLayer;
}

Expand Down Expand Up @@ -330,7 +329,7 @@ function injectSpies(layer: Layer, spies: string[]): Record<string, Spy> {
const spyMap: Record<string, Spy> = {};
if (spies) {
for (const functionName of spies) {
spyMap[functionName] = makeSpy(Object.getPrototypeOf(layer), functionName);
spyMap[functionName] = vi.spyOn(Object.getPrototypeOf(layer), functionName);
}
}
return spyMap;
Expand Down
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
"clean": "ocular-clean",
"build": "npm run clean && ocular-build && lerna run build",
"lint": "ocular-lint",
"cover": "ocular-test cover",
"cover": "vitest run --coverage",
"publish-beta": "ocular-publish version-only-beta",
"publish-prod": "ocular-publish version-only-prod",
"start": "open https://deck.gl/docs/get-started/getting-started",
"test": "ocular-test",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think we need ocular-test anymore. Vitest seems to offer everything you need to run tests.

Please let me know if ocular-test did something internally that we lose because we're removing it

"test-fast": "ocular-lint && ocular-test node",
"test": "vitest run",
"test-node": "vitest run --project node",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Trying to run all of the tests in the node environment resulted in a lot of failures (which is not a surprise), so I'm going to instead implement the same test config for node that we have on master, which is basically a smoke-test.

I'll keep test-fast but remove test-node

"test-browser": "vitest run --project browser",
"test-headless": "vitest run --project headless",
"test-fast": "ocular-lint && vitest run --project node",
"test-website": "cd website && yarn && yarn test-build && cd ..",
"metrics": "ocular-metrics",
"link-luma": "yarn && (cd node_modules && mv luma.gl luma.orig && ln -s ../../luma.gl/modules/core)",
Expand All @@ -42,18 +45,20 @@
"@loaders.gl/csv": "^4.2.0",
"@loaders.gl/polyfills": "^4.2.0",
"@luma.gl/core": "^9.2.6",
"@luma.gl/webgpu": "^9.2.6",
"@luma.gl/effects": "^9.2.6",
"@luma.gl/webgpu": "^9.2.6",
"@math.gl/proj4": "^4.1.0",
"@probe.gl/bench": "^4.1.0",
"@vis.gl/dev-tools": "1.0.0-alpha.21",
"@vis.gl/ts-plugins": "1.0.0-alpha.21",
"@vitest/browser": "^2.1.9",
"@vitest/coverage-v8": "^2.1.9",
"jsdom": "^20.0.0",
"playwright": "^1.58.0",
"pre-commit": "^1.2.2",
"puppeteer": "^24.26.1",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hoping to remove puppeteer after all tests pass

"s2-geometry": "^1.2.10",
"tap-spec": "^5.0.0",
"tape-catch": "^1.0.6"
"vitest": "^2.1.9"
},
"resolutions": {
"wgsl_reflect": "^1.2.0"
Expand Down
Loading
Loading