Vitest setup for testLayer #10223
|
Hi, I wrote a custom layer using However, the documentation doesn't really mention much about how to set it up. Can testLayer run in jsdom, or does it have to run in the browser via Vitest Browser Mode? What would be the instructions for the correct setup, whether using the former or the latter? If I attempt to run in jsdom, I see this error: I also see the following error when running in jsdom: I tried to run the test in Vitest Browser Mode by copying the setup from https://github.com/visgl/deck.gl/blob/master/test/setup/vitest-browser-setup.ts, but then I get a whole plethora of errors: Any help would be greatly appreciated. |
Replies: 2 comments 3 replies
|
FYI, the test I'm trying to run is pretty simple and just checks that a certain prop is set in the state, e.g.: describe('MyLayer', () => {
it('deck.gl layer conformance tests', () => {
testLayer({
Layer: MyLayer,
testCases: [
{
title: 'Default Props',
props: defaultProps,
onAfterUpdate({ layer }) {
expect(layer.state.someProp).toBeDefined();
},
},
],
});
});
}); |
|
There is 2 ways, import { testLayer } from '@deck.gl/test-utils/vitest';testing the layer rendered WebGL image in Vitest Browser test with Playright using a custom harness exemple here and browser-render code here |
There is 2 ways,
testing layers props in JSDom with deck.gl >=9.3 using Vitest :
exemple here
testing the layer rendered WebGL image in Vitest Browser test with Playright using a custom harness exemple here and browser-render code here