vitest-webgl-canvas-mock
Version:
Mock both 2D and WebGL contexts in Vitest.
21 lines (16 loc) • 330 B
JavaScript
import { vi } from "vitest";
export default class ImageBitmap {
width = 0;
height = 0;
_closed = false;
constructor(width, height) {
this.width = width;
this.height = height;
this.close = vi.fn(this.close.bind(this));
}
close() {
this.width = 0;
this.height = 0;
this._closed = true;
}
}