Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
roots: ['<rootDir>/test'],
roots: ['<rootDir>/test/unit'],
testMatch: ['**/*.test.ts'],
moduleFileExtensions: ['ts', 'js', 'json'],
transform: {
'^.+\\.ts$': ['ts-jest', {
tsconfig: 'test/tsconfig.json',
}],
},
setupFilesAfterEnv: ['<rootDir>/test/jest.setup.ts'],
setupFilesAfterEnv: ['<rootDir>/test/unit/jest.setup.ts'],
// Allow per-file @jest-environment docblock overrides
// (use @jest-environment node for Worker-context tests)
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"build:concatBundleFunc": "concat-cli -f tools/spector.ext.header.js dist/spector.bundle.js tools/spector.ext.footer.js -o extensions/spector.bundle.func.js",
"build:tslint": "tslint -c ./tslint.json -p ./src/tsconfig.json",
"build": "run-s build:tslint build:bundle build:types build:copybuild:copy:bundle build:copy:worker:bundle build:concatBundleFunc -n",
"test": "jest --config jest.config.js",
"test": "jest --config jest.config.js && npx playwright test && npx playwright test --config test/integration/playwright.config.ts",
"test:unit": "jest --config jest.config.js",
"test:e2e": "npx playwright test",
"test:visual": "npx playwright test --config test/playwright.config.ts",
"test:visual:update": "npx playwright test --config test/playwright.config.ts --update-snapshots"
"test:visual": "npx playwright test --config test/integration/playwright.config.ts",
"test:visual:update": "npx playwright test --config test/integration/playwright.config.ts --update-snapshots"
},
"dependencies": {
"@shaderfrog/glsl-parser": "^7.0.1",
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from '@playwright/test';

export default defineConfig({
testDir: './e2e',
testDir: './test/e2e',
timeout: 60000,
expect: {
timeout: 15000,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@
"commands": [
{
"id": 0,
"startTime": 1774015140680.3,
"commandEndTime": 1774015140680.3,
"endTime": 1774015140682.1,
"startTime": 647.1999999992549,
"commandEndTime": 647.3000000007451,
"endTime": 648.8000000007451,
"name": "clearColor",
"commandArguments": [
0.1,
Expand All @@ -169,23 +169,23 @@
1
],
"stackTrace": [
"render (http://localhost:7777/test/fixtures/test-scene.html:105:16)"
"render (http://localhost:7777/test/integration/fixtures/test-scene.html:105:16)"
],
"status": 30,
"text": "clearColor: 0.1, 0.1, 0.18, 1",
"consumeCommandId": 1
},
{
"id": 1,
"startTime": 1774015140682.1,
"commandEndTime": 1774015140682.1,
"endTime": 1774015140687,
"startTime": 648.8000000007451,
"commandEndTime": 648.8000000007451,
"endTime": 654,
"name": "clear",
"commandArguments": [
16384
],
"stackTrace": [
"render (http://localhost:7777/test/fixtures/test-scene.html:106:16)"
"render (http://localhost:7777/test/integration/fixtures/test-scene.html:106:16)"
],
"status": 0,
"text": "clear: COLOR_BUFFER_BIT",
Expand Down Expand Up @@ -225,17 +225,17 @@
},
{
"id": 2,
"startTime": 1774015140687,
"commandEndTime": 1774015140687,
"endTime": 1774015140701.2,
"startTime": 654,
"commandEndTime": 654.1000000014901,
"endTime": 672.6000000014901,
"name": "drawArrays",
"commandArguments": [
4,
0,
3
],
"stackTrace": [
"render (http://localhost:7777/test/fixtures/test-scene.html:107:16)"
"render (http://localhost:7777/test/integration/fixtures/test-scene.html:107:16)"
],
"status": 0,
"text": "drawArrays: TRIANGLES, 0 indices, 3",
Expand Down Expand Up @@ -682,10 +682,10 @@
"FrameBuffer": null
}
},
"startTime": 1774015140666.1,
"listenCommandsStartTime": 1774015140680.3,
"listenCommandsEndTime": 1774015140701.3,
"endTime": 1774015140711.4,
"startTime": 630.8000000007451,
"listenCommandsStartTime": 647.1999999992549,
"listenCommandsEndTime": 672.6999999992549,
"endTime": 682.5,
"analyses": [
{
"analyserName": "Commands",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* One-time capture generation script.
*
* Run with: npx playwright test generate-capture --config test/playwright.config.ts
* Run with: npx playwright test generate-capture --config test/integration/playwright.config.ts
*
* This navigates to the test scene, triggers a Spector capture, and saves
* the resulting JSON to test/fixtures/captured-frame.json.
Expand All @@ -15,7 +15,7 @@ const FIXTURE_DIR = path.join(__dirname);
const FIXTURE_PATH = path.join(FIXTURE_DIR, "captured-frame.json");

test("generate captured-frame.json fixture", async ({ page }) => {
await page.goto("/test/fixtures/test-scene.html", {
await page.goto("/test/integration/fixtures/test-scene.html", {
waitUntil: "domcontentloaded",
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<body>
<canvas id="renderCanvas" width="800" height="600"></canvas>

<script src="../../dist/spector.bundle.js"></script>
<script src="../../../dist/spector.bundle.js"></script>
<script>
(function () {
"use strict";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface SpectorPage {
export const test = base.extend<{ spectorPage: SpectorPage }>({
spectorPage: async ({ page }, use) => {
// Navigate to the test scene and wait for the canvas + Spector global.
await page.goto("/test/fixtures/test-scene.html", {
await page.goto("/test/integration/fixtures/test-scene.html", {
waitUntil: "domcontentloaded",
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default defineConfig({
},
],
webServer: {
command: `npx http-server "${path.join(__dirname, "..")}" -p ${PORT} --silent -c-1`,
command: `npx http-server "${path.join(__dirname, "..", "..")}" -p ${PORT} --silent -c-1`,
port: PORT,
reuseExistingServer: !process.env.CI,
timeout: 10_000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@ test.describe("Responsive viewports", () => {
);
});

test("laptop 1366x768", async ({ spectorPage }) => {
const { page } = spectorPage;
await page.setViewportSize({ width: 1366, height: 768 });
await spectorPage.injectStabilizationCSS();
await loadCapturedFrame(page);
await page.waitForTimeout(200);

await expect(page.locator(".resultViewComponent")).toHaveScreenshot(
"responsive-1366x768.png",
{ maxDiffPixels: 150 },
);
});

test("below breakpoint 1023x600", async ({ spectorPage }) => {
const { page } = spectorPage;
// Below the 1024px media query — triggers responsive/hamburger layout.
Expand Down
File renamed without changes.
Diff not rendered.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isSpectorMessage, SPECTOR_MESSAGE_PREFIX, PROTOCOL_VERSION } from "../../../src/backend/bridge/messageProtocol";
import { isSpectorMessage, SPECTOR_MESSAGE_PREFIX, PROTOCOL_VERSION } from "../../../../src/backend/bridge/messageProtocol";

// const enum values are inlined at compile time, so we reference the string literals directly.
const MESSAGE_TYPES = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WorkerBridge } from "../../../src/backend/bridge/workerBridge";
import { PROTOCOL_VERSION } from "../../../src/backend/bridge/messageProtocol";
import { ICapture } from "../../../src/shared/capture/capture";
import { WorkerBridge } from "../../../../src/backend/bridge/workerBridge";
import { PROTOCOL_VERSION } from "../../../../src/backend/bridge/messageProtocol";
import { ICapture } from "../../../../src/shared/capture/capture";

class MockWorker {
private listeners: Map<string, Function[]> = new Map();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WorkerMessageSender } from "../../../src/backend/bridge/workerMessageSender";
import { PROTOCOL_VERSION } from "../../../src/backend/bridge/messageProtocol";
import { ICapture } from "../../../src/shared/capture/capture";
import { WorkerMessageSender } from "../../../../src/backend/bridge/workerMessageSender";
import { PROTOCOL_VERSION } from "../../../../src/backend/bridge/messageProtocol";
import { ICapture } from "../../../../src/shared/capture/capture";

class MockScope {
public messages: any[] = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WorkerSpy } from "../../../src/backend/spies/workerSpy";
import { WorkerSpy } from "../../../../src/backend/spies/workerSpy";

describe("WorkerSpy", () => {
// jsdom does not provide a real Worker, so we install a minimal stub
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CanvasFactory } from "../../../src/backend/utils/canvasFactory";
import { CanvasFactory } from "../../../../src/backend/utils/canvasFactory";

/**
* Helper: decode base64 data URI to Uint8Array.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseWebGlObject } from "../../../src/backend/webGlObjects/baseWebGlObject";
import { BaseWebGlObject } from "../../../../src/backend/webGlObjects/baseWebGlObject";

class ConcreteWebGlObject extends BaseWebGlObject {
get typeName(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// Load the module injector — it attaches to window.__SPECTOR_ModuleInjector
require("../../extensions/moduleWorkerInjector");
require("../../../extensions/moduleWorkerInjector");

const injector = (window as any).__SPECTOR_ModuleInjector;

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions test/mocks/captureMock.ts → test/unit/mocks/captureMock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ICapture } from '../../src/shared/capture/capture';
import { CommandCaptureStatus } from '../../src/shared/capture/commandCapture';
import { ICapture } from '../../../src/shared/capture/capture';
import { CommandCaptureStatus } from '../../../src/shared/capture/commandCapture';

/**
* Creates a mock ICapture for testing.
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Time } from "../../../src/shared/utils/time";
import { Time } from "../../../../src/shared/utils/time";

describe('Time', () => {
it('Time.now returns a number', () => {
Expand Down
Loading