Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .github/workflows/test-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
pnpm lint
pnpm publint

- name: Run Typecheck
run: pnpm typecheck

- uses: ./.github/actions/setup-playwright

# Needed for additional browsers that Vitest unit tests use.
Expand Down
12 changes: 12 additions & 0 deletions oxlint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@ export default defineConfig({
typeAware: true,
},

plugins: [
"import",

// Defaults:
"eslint",
"typescript",
"unicorn",
"oxc",
],

rules: {
"unicorn/prefer-node-protocol": "error",
"typescript/consistent-type-imports": ["error", { fixStyle: "inline-type-imports" }],
"import/no-duplicates": "error",
},

overrides: [
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"dev:server": "node test-server/server",
"lint": "oxlint",
"fmt": "oxfmt",
"publint": "pnpm -r --parallel --filter !@chromatic-com/shared-e2e exec publint",
"publint": "pnpm -r --parallel --no-bail --filter !@chromatic-com/shared-e2e exec publint",
"typecheck": "pnpm -r --parallel --no-bail run typecheck",
"prepare": "husky install",
"release": "pnpm build && pnpm changeset publish",
"test:unit": "vitest run --configLoader=runner",
Expand Down
4 changes: 3 additions & 1 deletion packages/cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
},
"scripts": {
"build": "tsdown",
"typecheck": "tsc --noEmit",
"test:cypress": "start-server-and-test 'pnpm --filter @chromaui/chromatic-e2e dev:server' 3000 'pnpm test:do-cypress'",
"test:do-cypress": "ELECTRON_EXTRA_LAUNCH_ARGS=--remote-debugging-port=8192 cypress run --project tests",
"test:unit": "pnpm --filter @chromaui/chromatic-e2e run test:unit --project Cypress"
Expand All @@ -56,7 +57,8 @@
"@storybook/server-webpack5": "10.2.13",
"cypress": "15.18.0",
"start-server-and-test": "^2.0.3",
"tsdown": "^0.22.14"
"tsdown": "^0.22.14",
"typescript": "^5.9.3"
},
"peerDependencies": {
"cypress": ">=15.10.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress/src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { takeSnapshot as takeChromaticSnapshot } from "./takeSnapshot";
import { CypressSnapshot } from "./types";
import { type CypressSnapshot } from "./types";

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
Expand Down
8 changes: 4 additions & 4 deletions packages/cypress/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
ResourceArchiver,
writeTestResult,
ChromaticStorybookParameters,
ResourceArchive,
Viewport,
type ChromaticStorybookParameters,
type ResourceArchive,
type Viewport,
} from "@chromatic-com/shared-e2e";
import CDP, { Version } from "chrome-remote-interface";

import { CypressSnapshot } from "./types";
import { type CypressSnapshot } from "./types";

interface WriteParams {
testTitlePath: string[];
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress/src/support.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./commands";
import { takeSnapshot } from "./takeSnapshot";
import { CypressSnapshot } from "./types";
import { type CypressSnapshot } from "./types";

const buildChromaticParams = (expose: Cypress.Cypress["expose"]) => ({
...(expose("diffThreshold") && {
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress/src/takeSnapshot.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createMirror, snapshot } from "@chromaui/rrweb-snapshot";
import type { serializedNodeWithId } from "@rrweb/types";

import { CypressSnapshot } from "./types";
import { type CypressSnapshot } from "./types";

export const takeSnapshot = (
doc: Document,
Expand Down
4 changes: 2 additions & 2 deletions packages/cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"compilerOptions": {
"types": ["node", "cypress"]
},
"include": ["src", "scripts", "vitest.config.ts"],
"exclude": ["node_modules", "dist"]
"include": ["src", "scripts", "tests", "embedded.test.ts", "vitest.config.ts"],
"exclude": ["node_modules", "dist", "tests/cypress/test-downloads"]
}
4 changes: 3 additions & 1 deletion packages/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
"scripts": {
"build": "tsdown",
"typecheck": "tsc --noEmit",
"test:playwright": "playwright test",
"test:unit": "pnpm --filter @chromaui/chromatic-e2e run test:unit --project Playwright"
},
Expand All @@ -54,7 +55,8 @@
"playwright": "^1.46.1",
"playwright-core": "^1.46.1",
"ts-dedent": "^2.2.0",
"tsdown": "^0.22.14"
"tsdown": "^0.22.14",
"typescript": "^5.9.3"
},
"peerDependencies": {
"@playwright/test": "^1.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright/src/createResourceArchive.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Server } from "node:http";
import { type Server } from "node:http";

import { logger } from "@chromatic-com/shared-e2e";
import express, { type Request } from "express";
import { Browser, chromium, Page } from "playwright";
import { type Browser, chromium, type Page } from "playwright";
import { dedent } from "ts-dedent";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

Expand Down
4 changes: 2 additions & 2 deletions packages/playwright/src/createResourceArchive.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
ResourceArchiver,
ResourceArchive,
type ResourceArchive,
DEFAULT_GLOBAL_RESOURCE_ARCHIVE_TIMEOUT_MS,
logger,
HttpCredentials,
type HttpCredentials,
} from "@chromatic-com/shared-e2e";
import type { Page } from "@playwright/test";

Expand Down
4 changes: 2 additions & 2 deletions packages/playwright/src/makeTest.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Browser, chromium, Page } from "playwright";
import { TestInfo } from "playwright/test";
import { type Browser, chromium, type Page } from "playwright";
import { type TestInfo } from "playwright/test";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

import { performChromaticSnapshot } from "./makeTest";
Expand Down
6 changes: 3 additions & 3 deletions packages/playwright/src/takeSnapshot.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NodeType, serializedElementNodeWithId } from "@rrweb/types";
import { Page } from "playwright";
import { TestInfo } from "playwright/test";
import { NodeType, type serializedElementNodeWithId } from "@rrweb/types";
import { type Page } from "playwright";
import { type TestInfo } from "playwright/test";
import { beforeEach, describe, expect, it } from "vitest";

import { chromaticSnapshots, takeSnapshot } from "./takeSnapshot";
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/src/types.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Page, TestInfo } from "@playwright/test";
import { type Page, type TestInfo } from "@playwright/test";
import { expectTypeOf, test } from "vitest";

import * as publicAPI from "../dist/index.mjs";
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src", "vitest.config.ts"]
"include": ["src", "tests", "embedded.test.ts", "playwright.config.ts", "vitest.config.ts"]
}
5 changes: 3 additions & 2 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"./test-utils": "./src/test-utils"
},
"scripts": {
"test:unit": "pnpm --filter @chromaui/chromatic-e2e run test:unit --project Shared"
"test:unit": "pnpm --filter @chromaui/chromatic-e2e run test:unit --project Shared",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@chromaui/rrweb-snapshot": "2.0.0-alpha.19-noAbsolute",
Expand All @@ -32,7 +33,7 @@
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.2.1",
"@types/node-fetch": "^2.6.6",
"mime": "^3.0.0",
"mime": "^4.0.0",
"node-fetch": "2",
"playwright": "^1.46.1",
"playwright-core": "^1.46.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NodeType, serializedNodeWithId } from "@rrweb/types";
import { type NodeType, type serializedNodeWithId } from "@rrweb/types";

import { Viewport } from "./utils/viewport";
import { type Viewport } from "./utils/viewport";

export interface ChromaticConfig {
/** https://www.chromatic.com/docs/delay/ */
Expand Down
10 changes: 8 additions & 2 deletions packages/shared/src/utils/filePaths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ import fsPromises from "node:fs/promises";

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

import { archivesDir, ensureDir, outputFile, outputJSONFile, truncateFileName } from "./filePaths";
import { removeLocalhostFromBaseUrl } from "./filePaths";
import {
archivesDir,
ensureDir,
outputFile,
outputJSONFile,
truncateFileName,
removeLocalhostFromBaseUrl,
} from "./filePaths";

vi.mock("fs");
vi.mock("fs/promises");
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/utils/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodeType, serializedNodeWithId } from "@rrweb/types";
import { NodeType, type serializedNodeWithId } from "@rrweb/types";

import type { SerializedIframeNode } from "../types";

Expand Down
6 changes: 3 additions & 3 deletions packages/shared/src/write-archive/dom-snapshot.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { serializedNodeWithId } from "@rrweb/types";
import { type serializedNodeWithId } from "@rrweb/types";
import { describe, expect, it } from "vitest";

import { DOMSnapshot } from "./dom-snapshot";
Expand Down Expand Up @@ -432,13 +432,13 @@ describe("DOMSnapshot", () => {
it("maps pseudoClassIds", async () => {
const domSnapshot = new DOMSnapshot({
snapshot,
pseudoClassIds: { hover: [2, 3, 4], focus: [5, 6, 7], active: [8, 9, 10] },
pseudoClassIds: { ":hover": [2, 3, 4], ":focus": [5, 6, 7], ":active": [8, 9, 10] },
});

const mappedSnapshot = await domSnapshot.mapAssetPaths(sourceMap);

expect(mappedSnapshot).toEqual(
`{"snapshot":${expectedMappedSnapshot},"pseudoClassIds":{"hover":[2,3,4],"focus":[5,6,7],"active":[8,9,10]}}`,
`{"snapshot":${expectedMappedSnapshot},"pseudoClassIds":{":hover":[2,3,4],":focus":[5,6,7],":active":[8,9,10]}}`,
);
});
});
Expand Down
Loading
Loading