oof
This commit is contained in:
92
web/test/setup.ts
Normal file
92
web/test/setup.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
import { vi } from "vitest";
|
||||
|
||||
// Mock ws module - ESM interop issue with WebSocket named export
|
||||
vi.mock("ws", () => {
|
||||
class MockWebSocketServer {
|
||||
clients = new Set();
|
||||
on() {}
|
||||
close(cb) { cb?.(); }
|
||||
}
|
||||
|
||||
const WebSocket = {
|
||||
OPEN: 1,
|
||||
CONNECTING: 0,
|
||||
CLOSING: 2,
|
||||
CLOSED: 3,
|
||||
};
|
||||
|
||||
return {
|
||||
WebSocketServer: MockWebSocketServer,
|
||||
WebSocket,
|
||||
};
|
||||
});
|
||||
|
||||
// Mock three module - WebGL not available in jsdom
|
||||
vi.mock("three", () => {
|
||||
class MockWebGLRenderer {
|
||||
domElement = document.createElement("canvas");
|
||||
setSize() {}
|
||||
setPixelRatio() {}
|
||||
setClearColor() {}
|
||||
render() {}
|
||||
dispose() {}
|
||||
}
|
||||
|
||||
class MockScene {
|
||||
add() {}
|
||||
}
|
||||
|
||||
class MockPerspectiveCamera {
|
||||
position = { z: 0 };
|
||||
updateProjectionMatrix() {}
|
||||
}
|
||||
|
||||
class MockPlaneGeometry {
|
||||
attributes = { position: { count: 1 } };
|
||||
computeVertexNormals() {}
|
||||
dispose() {}
|
||||
setAttribute() {}
|
||||
}
|
||||
|
||||
class MockBufferAttribute {
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
class MockShaderMaterial {
|
||||
dispose() {}
|
||||
}
|
||||
|
||||
class MockMesh {
|
||||
rotation = { set() {} };
|
||||
scale = { set() {}, multiplyScalar() {} };
|
||||
position = { y: 0 };
|
||||
}
|
||||
|
||||
class MockVector3 {
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
class MockVector4 {
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
class MockTimer {
|
||||
update() {}
|
||||
getDelta() { return 0.016; }
|
||||
getElapsed() { return 0; }
|
||||
}
|
||||
|
||||
return {
|
||||
WebGLRenderer: MockWebGLRenderer,
|
||||
Scene: MockScene,
|
||||
PerspectiveCamera: MockPerspectiveCamera,
|
||||
PlaneGeometry: MockPlaneGeometry,
|
||||
BufferAttribute: MockBufferAttribute,
|
||||
ShaderMaterial: MockShaderMaterial,
|
||||
Mesh: MockMesh,
|
||||
Vector3: MockVector3,
|
||||
Vector4: MockVector4,
|
||||
Timer: MockTimer,
|
||||
DoubleSide: 2,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user