The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Use affected-test plans to narrow frontend unit tests (#82049)
Fraser53f48ed3bec5
diff --git a/.dependency-cruiser.cjs b/.dependency-cruiser.cjsindex 19eb74796f3..f2ffdfc9949 100644--- a/.dependency-cruiser.cjs+++ b/.dependency-cruiser.cjs@@ -14,6 +14,9 @@ module.exports = {doNotFollow: { path: "node_modules" },+ // No rules here, so the cycle and orphan analysis has no consumer and only costs time.+ skipAnalysisNotInRules: true,+// Resolve the `"*": ["./frontend/src/*", ...]` aliases so bare imports like// `metabase/lib/foo` map back to a real file.tsConfig: { fileName: "tsconfig.json" },diff --git a/.github/actions/create-test-plan/action.yml b/.github/actions/create-test-plan/action.ymlindex 66971d7fcd0..b8009362668 100644--- a/.github/actions/create-test-plan/action.yml+++ b/.github/actions/create-test-plan/action.yml@@ -1,5 +1,5 @@name: Create test plan-description: Cruise the frontend import graph and compute the affected-tests plan.+description: Compute the affected-tests plan for the changed files.inputs:changed-files:@@ -28,21 +28,15 @@ outputs:stats:description: FE Affected Tests stats row (JSON).value: ${{ steps.compute.outputs.stats }}- fe_unit_specs_to_run:- description: Unit specs to run (JSON array).- value: ${{ steps.compute.outputs.fe_unit_specs_to_run }}- loki_stories_to_run:- description: Loki stories to run (JSON array).- value: ${{ steps.compute.outputs.loki_stories_to_run }}- e2e_specs_to_run:- description: E2E specs to run (JSON array).- value: ${{ steps.compute.outputs.e2e_specs_to_run }}+ artifact-id:+ description: Artifact containing test-plan.json for this run.+ value: ${{ steps.upload.outputs.artifact-id }}runs:using: compositesteps:- - name: Prepare Node + Bun- uses: ./.github/actions/prepare-node-bun+ - name: Prepare front-end environment+ uses: ./.github/actions/prepare-frontend- name: Resolve closest-ancestor e2e coverage manifestid: manifestuses: actions/github-script@v9@@ -61,16 +55,6 @@ runs:headSha: context.payload.pull_request?.head?.sha ?? context.sha,});core.setOutput("path", result?.path ?? "");- - name: Build dependency graph- shell: bash- run: |- # Quiet on success; surface output only if install fails.- bun install --frozen-lockfile > /tmp/bun-install.log 2>&1 \- || { echo "bun install issues (continuing):"; tail -20 /tmp/bun-install.log; }- bunx depcruise frontend/src enterprise/frontend/src \- --config .dependency-cruiser.cjs \- --output-type json > dependency-graph.json || true-- name: Create test planid: computeshell: bash@@ -82,15 +66,20 @@ runs:LOKI_INFRA_TOUCHED: ${{ inputs.loki-infra-touched }}E2E_INFRA_TOUCHED: ${{ inputs.e2e-infra-touched }}SHARED_SOURCES_TOUCHED: ${{ inputs.shared-sources-touched }}- DEP_GRAPH_JSON: dependency-graph.jsonE2E_SPEC_MANIFEST: ${{ steps.manifest.outputs.path }}run: |# stdout is the plan JSON; the planner's own info logs go to stderr.+ # The planner writes this step's GITHUB_OUTPUT entries.bun .github/scripts/create-test-plan.ts > test-plan.json- echo "stats=$(jq -c '.stats' test-plan.json)" >> "$GITHUB_OUTPUT"- echo "fe_unit_specs_to_run=$(jq -c '.fe_unit_specs_to_run' test-plan.json)" >> "$GITHUB_OUTPUT"- echo "loki_stories_to_run=$(jq -c '.loki_stories_to_run' test-plan.json)" >> "$GITHUB_OUTPUT"- echo "e2e_specs_to_run=$(jq -c '.e2e_specs_to_run' test-plan.json)" >> "$GITHUB_OUTPUT"++ - name: Upload test plan+ id: upload+ uses: actions/upload-artifact@v7+ with:+ name: test-plan-${{ github.run_id }}-${{ github.run_attempt }}+ path: test-plan.json+ if-no-files-found: error+ retention-days: 7- name: Report test planshell: bashdiff --git a/.github/file-paths.yaml b/.github/file-paths.yamlindex 2c58d13926a..6424003df5a 100644--- a/.github/file-paths.yaml+++ b/.github/file-paths.yaml@@ -63,12 +63,10 @@ frontend_specs: &frontend_specs- "frontend/**/tests/**"- "frontend/**/*.unit.*"- "enterprise/frontend/**/*.unit.*"- - ".github/**/*.unit.spec.*"- # file-paths.unit.spec.ts asserts what this file's own patterns match, so a change to it has to- # run the specs that guard it.- - ".github/file-paths.yaml"- "jest.config.js"- - "jest.tz.unit.conf.json"+ - "jest.base.conf.js"+ - "jest.esm-packages.js"+ - "jest.tz.unit.conf.js"release_source: &release_sources- "release/**"@@ -87,15 +85,38 @@ frontend_unit_infra: &frontend_unit_infra- *frontend_configs- *frontend_ci- "jest.config.js"- - "jest.tz.unit.conf.json"+ - "jest.base.conf.js"+ - "jest.esm-packages.js"+ - "jest.tz.unit.conf.js"- "frontend/test/**"- "frontend/**/__mocks__/**"+ - "frontend/src/embedding-sdk-shared/jest/**"frontend_loki_infra: &frontend_loki_infra- *frontend_configs- *shared_ci- *frontend_loki_ci+# Everything the ci-scripts jest project runs or depends on.+# test-unit ignores that project, so this filter is the only thing that reruns it.+ci_scripts:+ - *frontend_ci+ - ".nvmrc"+ # file-paths.unit.spec.ts asserts what this file's own patterns match, so a change to it has to+ # run the specs that guard it.+ - ".github/file-paths.yaml"+ - ".github/scripts/**"+ - ".github/actions/**"+ - "frontend/lint/module-boundaries.mjs"+ - "frontend/lint/shared-tiers.mjs"+ - "frontend/test/jest-test-paths-filter.ts"+ - ".dependency-cruiser.cjs"+ - "jest.config.js"+ - "jest.base.conf.js"+ - "jest.esm-packages.js"+ - "package.json"+ - "bun.lock"+# e2e harness/support code (commands, support file, runner). Not in the# instrumented bundle, so it maps to no covered module — a change here forces a# full e2e run (see create-test-plan / e2eInfraTouched).diff --git a/.github/scripts/affected-tests.ts b/.github/scripts/affected-tests.tsindex 1101e456ff9..f9f36e0d41f 100644--- a/.github/scripts/affected-tests.ts+++ b/.github/scripts/affected-tests.ts@@ -48,8 +48,9 @@ export type CreateTestPlanInput = {elements: ModuleDef[];rules: Rule[];changedFiles: string[];- // Parsed dependency-cruiser edges, or null to fall back to the rules graph.- fileDependencies: FileDependency[] | null;+ // Loads the dependency-cruiser edges, called only when some suite can be narrowed.+ // Null falls back to the rules graph.+ loadFileDependencies: () => FileDependency[] | null;testFilesBySuite: { unit: string[]; loki: string[]; e2e: string[] };e2eSpecFiles: Record<string, string[]> | null;unitInfraTouched: boolean;@@ -63,6 +64,7 @@ export type CreateTestPlanInput = {};// Tests whose owning module is affected.+// A spec outside the module tree always runs, because the graph cannot scope it.export function filterAffectedTests(nodes: ModuleNode[],affected: Set<string>,@@ -70,7 +72,7 @@ export function filterAffectedTests(): string[] {return testFiles.filter((file) => {const module = mapFileToModule(nodes, file);- return module !== null && affected.has(module);+ return module === null || affected.has(module);});}@@ -130,7 +132,7 @@ export function createTestPlan({elements,rules,changedFiles,- fileDependencies,+ loadFileDependencies,testFilesBySuite,e2eSpecFiles,unitInfraTouched,@@ -143,16 +145,11 @@ export function createTestPlan({beFilesTotal,}: CreateTestPlanInput): TestPlan {const rulesGraph = buildModuleGraph(elements, rules);- const usageGraph = fileDependencies- ? buildUsageModuleGraph(elements, fileDependencies)- : rulesGraph;-const nodes = rulesGraph.nodes;// Distinct module types (an element type can span several patterns).const totalModules = new Set(elements.map((el) => el.type)).size;const changedModules = getChangedModules(nodes, changedFiles);const rulesAffected = getAffectedModules(rulesGraph, changedFiles);- const usageAffected = getAffectedModules(usageGraph, changedFiles);// The coarse "feature" tier is the only set the e2e manifest is ever// collapsed to (see filterAffectedE2eSpecs).@@ -172,6 +169,14 @@ export function createTestPlan({beFilesChanged > 0 ||e2eSpecFiles === null;+ // The cruise takes seconds, so it is skipped when every suite runs in full anyway.+ const edges =+ unitForceAll && lokiForceAll && e2eForceAll ? null : loadFileDependencies();+ const usageGraph = edges+ ? buildUsageModuleGraph(elements, edges)+ : rulesGraph;+ const usageAffected = getAffectedModules(usageGraph, changedFiles);+const select = (forceAll: boolean, affected: Set<string>, files: string[]) =>forceAll ? files : filterAffectedTests(nodes, affected, files);diff --git a/.github/scripts/affected-tests.unit.spec.ts b/.github/scripts/affected-tests.unit.spec.tsindex a09d8ca3b0e..64a89e72bd2 100644--- a/.github/scripts/affected-tests.unit.spec.ts+++ b/.github/scripts/affected-tests.unit.spec.ts@@ -26,7 +26,7 @@ const E2E_FILES = ["e2e/test/scenarios/a.cy.spec.ts"];const baseInput = {elements: ELEMENTS,rules: RULES,- fileDependencies: null,+ loadFileDependencies: () => null,testFilesBySuite: { unit: UNIT_FILES, loki: LOKI_FILES, e2e: E2E_FILES },e2eSpecFiles: null,unitInfraTouched: false,@@ -60,7 +60,7 @@ describe("createTestPlan", () => {...baseInput,changedFiles: ["src/utils/colors.ts"],// Only feature/foo actually imports lib/utils.- fileDependencies: [+ loadFileDependencies: () => [{ source: "src/foo/foo.tsx", dependencies: ["src/utils/colors.ts"] },],});@@ -229,21 +229,53 @@ describe("createTestPlan", () => {expect(plan.stats.fe_files_changed).toBe(5);expect(plan.stats.be_files_changed).toBe(3);});++ it("does not build the usage graph when every suite runs in full", () => {+ const loadFileDependencies = jest.fn(() => null);+ createTestPlan({+ ...baseInput,+ changedFiles: ["src/foo/x.ts"],+ sharedSourcesTouched: true,+ loadFileDependencies,+ });++ expect(loadFileDependencies).not.toHaveBeenCalled();+ });++ it("builds the usage graph when any suite can be narrowed", () => {+ const loadFileDependencies = jest.fn(() => null);+ createTestPlan({+ ...baseInput,+ changedFiles: ["src/foo/x.ts"],+ unitInfraTouched: true, // loki can still be narrowed+ loadFileDependencies,+ });++ expect(loadFileDependencies).toHaveBeenCalledTimes(1);+ });});describe("filterAffectedTests", () => {- it("keeps only tests inside affected modules", () => {+ it("keeps tests inside affected modules, drops tests in unaffected ones", () => {const nodes = buildNodes(ELEMENTS);const affected = new Set(["feature/foo", "lib/utils"]);const tests = ["src/foo/foo.unit.spec.ts","src/utils/colors.unit.spec.ts","src/bar/bar.unit.spec.ts",- "docs/unrelated.unit.spec.ts",];expect(filterAffectedTests(nodes, affected, tests)).toEqual(["src/foo/foo.unit.spec.ts","src/utils/colors.unit.spec.ts",]);});++ it("keeps a test that maps to no module (unknown scope)", () => {+ const nodes = buildNodes(ELEMENTS);+ const affected = new Set(["feature/foo"]);+ const tests = ["docs/unrelated.unit.spec.ts", "src/bar/bar.unit.spec.ts"];+ expect(filterAffectedTests(nodes, affected, tests)).toEqual([+ "docs/unrelated.unit.spec.ts",+ ]);+ });});diff --git a/.github/scripts/check-unit-test-results.ts b/.github/scripts/check-unit-test-results.tsnew file mode 100644index 00000000000..6a537a7a8ed--- /dev/null+++ b/.github/scripts/check-unit-test-results.ts@@ -0,0 +1,182 @@+import { spawnSync } from "node:child_process";+import { readFileSync, statSync } from "node:fs";+import { join } from "node:path";++const TEST_UNIT_COMMAND = ["bun", "run", "test-unit-keep-cljs"];++type SuiteResult = {+ name: string;+ status: string;+ assertionResults: unknown[];+};++type JestResults = {+ wasInterrupted: boolean;+ testResults: SuiteResult[];+};++function isSuiteResult(value: unknown): value is SuiteResult {+ return (+ typeof value === "object" &&+ value !== null &&+ "name" in value &&+ typeof value.name === "string" &&+ "status" in value &&+ typeof value.status === "string" &&+ "assertionResults" in value &&+ Array.isArray(value.assertionResults)+ );+}++function readResults(file: string): JestResults | null {+ const value = readJson(file);+ if (+ typeof value === "object" &&+ value !== null &&+ "wasInterrupted" in value &&+ typeof value.wasInterrupted === "boolean" &&+ "testResults" in value &&+ Array.isArray(value.testResults) &&+ value.testResults.every(isSuiteResult)+ ) {+ return {+ wasInterrupted: value.wasInterrupted,+ testResults: value.testResults,+ };+ }+ return null;+}++function parseJson(text: string): unknown {+ try {+ return JSON.parse(text);+ } catch {+ return null;+ }+}++function readJson(file: string): unknown {+ try {+ return parseJson(readFileSync(file, "utf8"));+ } catch {+ return null;+ }+}++function isStringArray(value: unknown): value is string[] {+ return (+ Array.isArray(value) && value.every((item) => typeof item === "string")+ );+}++function hasContent(file: string): boolean {+ try {+ return statSync(file).size > 0;+ } catch {+ return false;+ }+}++export function findRunnerFailure(env: NodeJS.ProcessEnv): string | null {+ const {+ UNIT_TEST_RESULTS_FILE,+ JEST_JUNIT_OUTPUT_DIR,+ JEST_JUNIT_OUTPUT_NAME,+ } = env;+ if (+ !UNIT_TEST_RESULTS_FILE ||+ !JEST_JUNIT_OUTPUT_DIR ||+ !JEST_JUNIT_OUTPUT_NAME+ ) {+ throw new Error(+ "UNIT_TEST_RESULTS_FILE, JEST_JUNIT_OUTPUT_DIR and JEST_JUNIT_OUTPUT_NAME are required",+ );+ }++ const results = readResults(UNIT_TEST_RESULTS_FILE);+ if (results === null || results.wasInterrupted) {+ return "Jest did not finish the run.";+ }+ if (!hasContent(join(JEST_JUNIT_OUTPUT_DIR, JEST_JUNIT_OUTPUT_NAME))) {+ return "Jest did not write a JUnit report.";+ }++ const failedSuites = results.testResults.filter(+ (suite) => suite.status === "failed",+ );+ // jest-junit leaves out suites with no test results, so the quarantine gate never sees them.+ const suitesWithoutResults = failedSuites.filter(+ (suite) => suite.assertionResults.length === 0,+ );+ if (suitesWithoutResults.length > 0) {+ const names = suitesWithoutResults.map((suite) => suite.name).join(", ");+ return `Test suites failed to run: ${names}`;+ }+ if (failedSuites.length === 0) {+ return "Jest failed without a failing test suite.";+ }+ return null;+}++function listTests(+ command: readonly string[],+ env: NodeJS.ProcessEnv,+): string[] | null {+ const [program, ...args] = command;+ const result = spawnSync(program, [...args, "--listTests", "--json"], {+ env,+ encoding: "utf8",+ stdio: ["ignore", "pipe", "inherit"],+ });+ if (result.status !== 0) {+ return null;+ }+ const listed = parseJson(result.stdout);+ return isStringArray(listed) ? listed : null;+}++// --passWithNoTests lets every shard pass when the selection matches nothing Jest discovers.+// A single empty shard is normal, so only an unsharded listing that is also empty warns.+export function findEmptySelection(+ env: NodeJS.ProcessEnv,+ command: readonly string[] = TEST_UNIT_COMMAND,+): string | null {+ const { UNIT_TEST_RESULTS_FILE, JEST_TEST_PATHS_FILE } = env;+ if (!UNIT_TEST_RESULTS_FILE || !JEST_TEST_PATHS_FILE) {+ return null;+ }+ const results = readResults(UNIT_TEST_RESULTS_FILE);+ const selection = readJson(JEST_TEST_PATHS_FILE);+ if (+ results === null ||+ results.testResults.length > 0 ||+ !isStringArray(selection) ||+ selection.length === 0+ ) {+ return null;+ }++ const listed = listTests(command, env);+ if (listed === null) {+ return "Could not list Jest's unit tests to check the selection.";+ }+ if (listed.length > 0) {+ return null;+ }+ return `None of the ${selection.length} selected unit specs match a test Jest discovers, so no unit tests ran.`;+}++if (require.main === module) {+ if (process.env.TEST_OUTCOME === "failure") {+ const failure = findRunnerFailure(process.env);+ if (failure !== null) {+ console.error(`::error::${failure}`);+ process.exitCode = 1;+ }+ } else {+ const warning = findEmptySelection(process.env);+ if (warning !== null) {+ console.warn(`::warning::${warning}`);+ }+ }+}diff --git a/.github/scripts/create-test-plan.ts b/.github/scripts/create-test-plan.tsindex b6894ae6697..c300b7833ac 100644--- a/.github/scripts/create-test-plan.ts+++ b/.github/scripts/create-test-plan.ts@@ -1,8 +1,8 @@-// I/O entrypoint: gather inputs (env vars, the cruise graph, the test-file-// lists) and hand them to createTestPlan, which does the computing.+// I/O entrypoint: gather inputs (env vars, the test-file lists, the cruise graph on request),+// hand them to createTestPlan, which does the computing, and publish its small stats output.-import { execFileSync } from "node:child_process";-import { existsSync, readFileSync } from "node:fs";+import { execFileSync, spawnSync } from "node:child_process";+import { appendFileSync, existsSync, readFileSync } from "node:fs";import micromatch from "micromatch";@@ -12,10 +12,14 @@ import { type FileDependency, parseCruiseModules } from "./affected-modules";import { createTestPlan } from "./affected-tests";import { listSpecFiles } from "./e2e-spec-globs.mjs";-const UNIT_ROOTS = ["frontend/src", "enterprise/frontend/src"];+// The specs `bun run test-unit` runs.+const UNIT_ROOTS = ["."];const UNIT_GLOBS = [- "frontend/src/**/*.unit.spec.{js,jsx,ts,tsx}",- "enterprise/frontend/src/**/*.unit.spec.{js,jsx,ts,tsx}",+ "**/*.unit.spec.{js,jsx,ts,tsx}",+ "!.github/**", // the ci-scripts project, which test-unit ignores+ "!release/**", // has its own jest config+ "!enterprise/frontend/src/custom-viz/**", // modulePathIgnorePatterns in jest.config.js+ "!**/*.leak.unit.spec.{js,jsx,ts,tsx}", // run only by jest.memory.conf.js];const STORY_ROOTS = ["frontend", "enterprise/frontend"];@@ -32,12 +36,11 @@ const LS_FILES_MAX_BUFFER = 64 * 1024 * 1024;// Returns the tracked files under `roots` that match `globs`. The `dot: true`// option means files inside dot-directories such as `.storybook` are included.function listFiles(roots: string[], globs: string[]): string[] {- const tracked = execFileSync("git", ["ls-files", "--", ...roots], {+ const tracked = execFileSync("git", ["ls-files", "-z", "--", ...roots], {encoding: "utf8",maxBuffer: LS_FILES_MAX_BUFFER,})- .split("\n")- .map((line) => line.trim())+ .split("\0").filter(Boolean);return micromatch(tracked, globs, { dot: true });}@@ -49,26 +52,42 @@ const csvToList = (csv: string | undefined) =>.map((s) => s.trim()).filter(Boolean);-// Reads the dependency-cruiser graph (DEP_GRAPH_JSON). Null falls back to the-// rules graph, so a missing or unparseable file never breaks the plan.-function readFileDependencies(): FileDependency[] | null {- const path = process.env.DEP_GRAPH_JSON;- if (path && existsSync(path)) {- try {- const { modules } = JSON.parse(readFileSync(path, "utf8"));- process.stderr.write(`Using usage graph from ${path}.\n`);- return parseCruiseModules(modules);- } catch (error) {- process.stderr.write(- `Failed to read ${path}; falling back to rules graph: ${error}\n`,- );+// Runs dependency-cruiser over the frontend sources and parses its edges.+// Null falls back to the rules graph, so a failed cruise never breaks the plan.+function loadFileDependencies(): FileDependency[] | null {+ const output = "dependency-graph.json";+ process.stderr.write("Building usage graph with dependency-cruiser.\n");+ try {+ // stdout is the plan JSON, so the cruise's own output goes to stderr.+ const result = spawnSync(+ "bunx",+ [+ "depcruise",+ "frontend/src",+ "enterprise/frontend/src",+ "--config",+ ".dependency-cruiser.cjs",+ "--output-type",+ "json",+ "--output-to",+ output,+ ],+ { stdio: ["ignore", 2, 2] },+ );+ if (result.error) {+ throw result.error;}- } else {+ if (result.status !== 0) {+ throw new Error(`depcruise exited with status ${result.status}`);+ }+ const { modules } = JSON.parse(readFileSync(output, "utf8"));+ return parseCruiseModules(modules);+ } catch (error) {process.stderr.write(- "No DEP_GRAPH_JSON found; falling back to rules graph.\n",+ `Failed to build usage graph; falling back to rules graph: ${error}\n`,);+ return null;}- return null;}// Reads the nightly coverage manifest (E2E_SPEC_MANIFEST): { builtAt, specs:@@ -98,7 +117,7 @@ const testPlan = createTestPlan({elements,rules,changedFiles: csvToList(process.env.CHANGED_FILES),- fileDependencies: readFileDependencies(),+ loadFileDependencies,testFilesBySuite: {unit: listFiles(UNIT_ROOTS, UNIT_GLOBS),loki: listFiles(STORY_ROOTS, STORY_GLOBS),@@ -116,3 +135,10 @@ const testPlan = createTestPlan({});process.stdout.write(JSON.stringify(testPlan) + "\n");++if (process.env.GITHUB_OUTPUT) {+ appendFileSync(+ process.env.GITHUB_OUTPUT,+ `stats=${JSON.stringify(testPlan.stats)}\n`,+ );+}diff --git a/.github/scripts/file-paths.unit.spec.ts b/.github/scripts/file-paths.unit.spec.tsindex 5db31531eaf..42df4da3756 100644--- a/.github/scripts/file-paths.unit.spec.ts+++ b/.github/scripts/file-paths.unit.spec.ts@@ -11,12 +11,17 @@ type Filter = string | Filter[] | { [changeType: string]: Filter };// A filter is a list of patterns, and an entry may name the change types it applies to as// { "added|modified": pattern }. Either way the patterns are what matters here.const patterns = (value: Filter): string[] => {- if (typeof value === "string") return [value];- if (Array.isArray(value)) return value.flatMap(patterns);+ if (typeof value === "string") {+ return [value];+ }+ if (Array.isArray(value)) {+ return value.flatMap(patterns);+ }return Object.values(value).flatMap(patterns);};describe("file-paths.yaml", () => {+ // js-yaml returns an untyped value, and this repository file defines named path filters.const filters = load(readFileSync(FILTERS, "utf8")) as Record<string, Filter>;// dorny/paths-filter matches with picomatch, which micromatch wraps, so this asks the same@@ -52,6 +57,36 @@ describe("file-paths.yaml", () => {},);+ it("runs CI script tests when the Node version changes", () => {+ expect(matches("ci_scripts", ".nvmrc")).toBe(true);+ });++ it.each([+ "jest.config.js",+ "jest.base.conf.js",+ "jest.esm-packages.js",+ "jest.tz.unit.conf.js",+ ])("runs every frontend unit test when %s changes", (path) => {+ expect(matches("frontend_specs", path)).toBe(true);+ expect(matches("frontend_unit_infra", path)).toBe(true);+ });++ it("runs every frontend unit test when an SDK jest setup file changes", () => {+ expect(+ matches(+ "frontend_unit_infra",+ "frontend/src/embedding-sdk-shared/jest/setup-env.ts",+ ),+ ).toBe(true);+ });++ it.each(["jest.config.js", "jest.base.conf.js", "jest.esm-packages.js"])(+ "runs CI script tests when %s changes",+ (path) => {+ expect(matches("ci_scripts", path)).toBe(true);+ },+ );+it("runs the ratchet check on the ratchets file", () => {expect(matches("project_ratchet_checks", ".clj-kondo/ratchets.edn")).toBe(true,diff --git a/.github/scripts/frontend-test-plan.unit.spec.ts b/.github/scripts/frontend-test-plan.unit.spec.tsnew file mode 100644index 00000000000..ee34be24938--- /dev/null+++ b/.github/scripts/frontend-test-plan.unit.spec.ts@@ -0,0 +1,310 @@+import { spawnSync } from "node:child_process";+import {+ mkdirSync,+ mkdtempSync,+ readFileSync,+ realpathSync,+ rmSync,+ writeFileSync,+} from "node:fs";+import { tmpdir } from "node:os";+import { join, resolve } from "node:path";++import { load } from "js-yaml";++import {+ findEmptySelection,+ findRunnerFailure,+} from "./check-unit-test-results";+import { prepareUnitTestSelection } from "./prepare-unit-test-selection";++type Step = { name: string; run?: string; "continue-on-error"?: boolean };+// js-yaml returns an untyped value, and this repository workflow defines the job's steps.+const workflow = load(+ readFileSync(resolve(__dirname, "../workflows/frontend.yml"), "utf8"),+) as { jobs: { "fe-tests-unit": { steps: Step[] } } };+const steps = workflow.jobs["fe-tests-unit"].steps;+const checkScript = resolve(__dirname, "check-unit-test-results.ts");+const filter = resolve(+ __dirname,+ "../../frontend/test/jest-test-paths-filter.ts",+);++describe("frontend test plan handoff", () => {+ let dir: string;+ let env: NodeJS.ProcessEnv;++ beforeEach(() => {+ jest.spyOn(console, "warn").mockImplementation(() => {});+ // Jest reports real paths, and macOS's temporary directory is behind a symlink.+ dir = realpathSync(mkdtempSync(join(tmpdir(), "frontend-test-plan-")));+ mkdirSync(join(dir, "test-plan"));+ writeFileSync(join(dir, "output"), "");+ env = {+ ...process.env,+ NODE_OPTIONS: "",+ JEST_TEST_PATHS_FILE: "",+ RUNNER_TEMP: dir,+ GITHUB_OUTPUT: join(dir, "output"),+ PLAN_DOWNLOADED: "success",+ JEST_JUNIT_OUTPUT_DIR: dir,+ JEST_JUNIT_OUTPUT_NAME: "junit.xml",+ UNIT_TEST_RESULTS_FILE: join(dir, "unit-test-results.json"),+ };+ });++ afterEach(() => {+ jest.restoreAllMocks();+ rmSync(dir, { recursive: true, force: true });+ });++ function plan(files: string[], total = 2) {+ return {+ fe_unit_specs_to_run: files,+ stats: { unit_specs_all: total, unit_specs_to_run_usage: files.length },+ };+ }++ function writePlan(value: unknown) {+ writeFileSync(join(dir, "test-plan/test-plan.json"), JSON.stringify(value));+ }++ it.each([{ files: ["one.spec.cjs"] }, { files: [] }])(+ "preserves an explicit selection: $files",+ ({ files }) => {+ writePlan(plan(files));+ prepareUnitTestSelection(env);+ expect(readFileSync(join(dir, "output"), "utf8")).toContain(+ "paths-file=",+ );+ expect(+ JSON.parse(readFileSync(join(dir, "unit-specs.json"), "utf8")),+ ).toEqual(files);+ },+ );++ it("writes the selection when invoked through Bun in CI", () => {+ writePlan(plan(["one.spec.cjs"]));+ const result = spawnSync(+ "bun",+ [resolve(__dirname, "prepare-unit-test-selection.ts")],+ { env, encoding: "utf8" },+ );+ expect(result.status === 0 ? "" : result.stderr).toBe("");+ expect(result.status).toBe(0);+ expect(readFileSync(join(dir, "output"), "utf8")).toBe(+ `paths-file=${join(dir, "unit-specs.json")}\n`,+ );+ expect(+ JSON.parse(readFileSync(join(dir, "unit-specs.json"), "utf8")),+ ).toEqual(["one.spec.cjs"]);+ });++ it("bypasses the filter for a full selection", () => {+ writePlan(plan(["one.spec.cjs", "two.spec.cjs"]));+ prepareUnitTestSelection(env);+ expect(readFileSync(join(dir, "output"), "utf8")).toBe("");+ });++ it.each([+ null,+ {},+ { ...plan([]), fe_unit_specs_to_run: "[]" },+ { ...plan([]), fe_unit_specs_to_run: [null] },+ { ...plan([]), fe_unit_specs_to_run: ["one.spec.cjs"] },+ plan(["one.spec.cjs"], 0),+ ])("runs in full for an invalid plan: %j", (value) => {+ writePlan(value);+ prepareUnitTestSelection(env);+ expect(console.warn).toHaveBeenCalledWith(+ expect.stringContaining("::warning::"),+ );+ expect(readFileSync(join(dir, "output"), "utf8")).toBe("");+ });++ it.each(["missing", "truncated", "download failed"])(+ "runs in full when the artifact is %s",+ (scenario) => {+ if (scenario === "truncated") {+ writeFileSync(+ join(dir, "test-plan/test-plan.json"),+ '{"fe_unit_specs_to_run":[',+ );+ } else if (scenario === "download failed") {+ writePlan(plan([])); // Even a partial download must not be trusted.+ env.PLAN_DOWNLOADED = "failure";+ }+ prepareUnitTestSelection(env);+ expect(console.warn).toHaveBeenCalledWith(+ expect.stringContaining("::warning::"),+ );+ expect(readFileSync(join(dir, "output"), "utf8")).toBe("");+ },+ );++ function jestCommand(useFilter: boolean) {+ return [+ process.execPath,+ require.resolve("jest/bin/jest"),+ "--config",+ JSON.stringify({+ rootDir: dir,+ testMatch: ["**/*.spec.cjs"],+ reporters: ["default", require.resolve("jest-junit")],+ ...(useFilter && { filter }),+ }),+ ];+ }++ function runJest(+ files: Record<string, string>,+ useFilter = false,+ args: string[] = [],+ ) {+ for (const [name, source] of Object.entries(files)) {+ writeFileSync(join(dir, name), source);+ }+ const [program, ...commandArgs] = jestCommand(useFilter);+ return spawnSync(+ program,+ [+ ...commandArgs,+ "--runInBand",+ "--watch=false",+ "--json",+ `--outputFile=${env.UNIT_TEST_RESULTS_FILE}`,+ ...(useFilter ? ["--passWithNoTests"] : []),+ ...args,+ ],+ { cwd: dir, env, encoding: "utf8" },+ );+ }++ function readResults() {+ return JSON.parse(+ readFileSync(join(dir, "unit-test-results.json"), "utf8"),+ );+ }++ function writeSelection(files: string[]) {+ env.JEST_TEST_PATHS_FILE = join(dir, "unit-specs.json");+ writeFileSync(env.JEST_TEST_PATHS_FILE, JSON.stringify(files));+ }++ it("lets ordinary assertion failures reach quarantine", () => {+ expect(+ runJest({ "fail.spec.cjs": "test('fails', () => expect(1).toBe(2));" })+ .status,+ ).toBe(1);+ expect(findRunnerFailure(env)).toBeNull();+ });++ it("lets suite hook failures reach quarantine", () => {+ expect(+ runJest({+ "hook.spec.cjs":+ "test('passes', () => {}); afterAll(() => { throw new Error('hook'); });",+ }).status,+ ).toBe(1);+ expect(readFileSync(join(dir, "junit.xml"), "utf8")).toContain(+ "Test execution failure",+ );+ expect(findRunnerFailure(env)).toBeNull();+ });++ it("fails a filter crash even though the test step permits errors", () => {+ env.JEST_TEST_PATHS_FILE = join(dir, "broken.json");+ writeFileSync(env.JEST_TEST_PATHS_FILE, "[");+ expect(+ runJest({ "pass.spec.cjs": "test('passes', () => {});" }, true).status,+ ).toBe(1);+ env.TEST_OUTCOME = "failure";+ const result = spawnSync("bun", [checkScript], { env, encoding: "utf8" });+ expect(result.status).toBe(1);+ expect(result.stderr).toContain("::error::");+ const step = steps.find((step) =>+ step.run?.includes("check-unit-test-results.ts"),+ );+ expect(step?.["continue-on-error"]).toBeUndefined();+ });++ it("fails suite startup errors even alongside ordinary assertion failures", () => {+ expect(+ runJest({+ "crash.spec.cjs": "throw new Error('startup crash');",+ "fail.spec.cjs": "test('fails', () => expect(1).toBe(2));",+ }).status,+ ).toBe(1);+ expect(readFileSync(join(dir, "junit.xml"), "utf8")).not.toContain(+ "crash.spec.cjs",+ );+ expect(findRunnerFailure(env)).toContain("crash.spec.cjs");+ });++ it("fails when JUnit results are missing", () => {+ runJest({ "fail.spec.cjs": "test('fails', () => expect(1).toBe(2));" });+ rmSync(join(dir, "junit.xml"));+ expect(findRunnerFailure(env)).not.toBeNull();+ });++ it.each([true, false])(+ "loads the TypeScript filter natively with an empty selection: %s",+ (empty) => {+ writePlan(plan(empty ? [] : [join(dir, "pass.spec.cjs")]));+ prepareUnitTestSelection(env);+ env.JEST_TEST_PATHS_FILE = join(dir, "unit-specs.json");+ const result = runJest(+ {+ "pass.spec.cjs": "test('passes', () => {});",+ "fail.spec.cjs":+ "test('excluded', () => { throw new Error('must not run'); });",+ },+ true,+ );+ expect(result.status === 0 ? "" : result.stderr).toBe("");+ expect(result.status).toBe(0);+ expect(readResults()).toMatchObject({+ numTotalTestSuites: empty ? 0 : 1,+ });+ },+ );++ it("warns when a narrowed run matches none of Jest's test paths", () => {+ writeSelection([join(dir, "renamed.spec.cjs")]);+ expect(+ runJest({ "pass.spec.cjs": "test('passes', () => {});" }, true).status,+ ).toBe(0);+ expect(findEmptySelection(env, jestCommand(true))).toContain(+ "None of the 1 selected unit specs",+ );+ });++ it("warns through Bun when the unit test step passed", () => {+ writeSelection([join(dir, "renamed.spec.cjs")]);+ runJest({ "pass.spec.cjs": "test('passes', () => {});" }, true);+ env.TEST_OUTCOME = "success";+ const result = spawnSync("bun", [checkScript], { env, encoding: "utf8" });+ expect(result.status).toBe(0);+ expect(result.stderr).toContain(+ "::warning::None of the 1 selected unit specs",+ );+ });++ it("does not warn for a shard the selection leaves empty", () => {+ writeSelection([join(dir, "pass.spec.cjs")]);+ const result = runJest(+ { "pass.spec.cjs": "test('passes', () => {});" },+ true,+ ["--shard=2/2"],+ );+ expect(result.status).toBe(0);+ expect(readResults()).toMatchObject({ numTotalTestSuites: 0 });+ expect(findEmptySelection(env, jestCommand(true))).toBeNull();+ });++ it("does not list tests for an empty selection", () => {+ writeSelection([]);+ runJest({ "pass.spec.cjs": "test('passes', () => {});" }, true);+ expect(findEmptySelection(env, ["false"])).toBeNull();+ });+});diff --git a/.github/scripts/jest-test-paths-filter.unit.spec.ts b/.github/scripts/jest-test-paths-filter.unit.spec.tsnew file mode 100644index 00000000000..b64ab1f2c09--- /dev/null+++ b/.github/scripts/jest-test-paths-filter.unit.spec.ts@@ -0,0 +1,44 @@+import fs from "node:fs";+import os from "node:os";+import path from "node:path";++// eslint-disable-next-line @typescript-eslint/no-require-imports -- Match Jest's direct CommonJS loading contract.+const filter = require("../../frontend/test/jest-test-paths-filter");++describe("jest-test-paths-filter", () => {+ const originalPathsFile = process.env.JEST_TEST_PATHS_FILE;+ let tempDir: string;+ let pathsFile: string;++ beforeEach(() => {+ tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "jest-test-paths-"));+ pathsFile = path.join(tempDir, "paths.json");+ process.env.JEST_TEST_PATHS_FILE = pathsFile;+ });++ afterEach(() => {+ fs.rmSync(tempDir, { recursive: true, force: true });+ if (originalPathsFile === undefined) {+ delete process.env.JEST_TEST_PATHS_FILE;+ } else {+ process.env.JEST_TEST_PATHS_FILE = originalPathsFile;+ }+ });++ it("should keep the listed paths and drop the rest", () => {+ const one = path.resolve("frontend/one.unit.spec.ts");+ const two = path.resolve("frontend/two.unit.spec.ts");+ const three = path.resolve("frontend/three.unit.spec.ts");+ fs.writeFileSync(pathsFile, JSON.stringify([one, two]));++ expect(filter([one, three, two])).toEqual({ filtered: [one, two] });+ });++ it("should resolve relative paths against the working directory", () => {+ fs.writeFileSync(pathsFile, JSON.stringify(["frontend/one.unit.spec.ts"]));+ const one = path.resolve("frontend/one.unit.spec.ts");+ const two = path.resolve("frontend/two.unit.spec.ts");++ expect(filter([one, two])).toEqual({ filtered: [one] });+ });+});diff --git a/.github/scripts/prepare-unit-test-selection.ts b/.github/scripts/prepare-unit-test-selection.tsnew file mode 100644index 00000000000..74873d2e7d6--- /dev/null+++ b/.github/scripts/prepare-unit-test-selection.ts@@ -0,0 +1,53 @@+import { appendFileSync, readFileSync, writeFileSync } from "node:fs";+import { join } from "node:path";++// null means a full run, and [] is an explicit selection of no tests.+function readSelection(planFile: string): string[] | null {+ const { fe_unit_specs_to_run: files, stats } = JSON.parse(+ readFileSync(planFile, "utf8"),+ );+ if (+ !Array.isArray(files) ||+ !files.every((file) => typeof file === "string" && file.length > 0) ||+ !Number.isInteger(stats?.unit_specs_all) ||+ stats.unit_specs_all < 0 ||+ files.length !== stats.unit_specs_to_run_usage ||+ files.length > stats.unit_specs_all+ ) {+ throw new Error("Invalid unit test selection");+ }+ return files.length === stats.unit_specs_all ? null : files;+}++export function prepareUnitTestSelection(env: NodeJS.ProcessEnv = process.env) {+ const { RUNNER_TEMP, GITHUB_OUTPUT, PLAN_DOWNLOADED } = env;+ if (!RUNNER_TEMP || !GITHUB_OUTPUT) {+ throw new Error("RUNNER_TEMP and GITHUB_OUTPUT are required");+ }++ let files: string[] | null;+ try {+ if (PLAN_DOWNLOADED !== "success") {+ throw new Error("Test plan download failed");+ }+ files = readSelection(join(RUNNER_TEMP, "test-plan/test-plan.json"));+ } catch {+ console.warn(+ "::warning::Test plan unavailable or invalid; running the full unit suite.",+ );+ return;+ }++ // Full selections use Jest's normal discovery, without the filter.+ if (files === null) {+ return;+ }++ const pathsFile = join(RUNNER_TEMP, "unit-specs.json");+ writeFileSync(pathsFile, JSON.stringify(files));+ appendFileSync(GITHUB_OUTPUT, `paths-file=${pathsFile}\n`);+}++if (require.main === module) {+ prepareUnitTestSelection();+}diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.ymlindex c5ac4212070..7e81ed45b62 100644--- a/.github/workflows/frontend.yml+++ b/.github/workflows/frontend.yml@@ -12,6 +12,13 @@ on:skip-custom-viz:type: booleandefault: false+ # ID of this run's test-plan.json artifact, or '' to run the full suite.+ test-plan-artifact-id:+ type: string+ default: ""+ skip-ci-scripts:+ type: boolean+ default: falseworkflow_dispatch:inputs:skip:@@ -100,6 +107,7 @@ jobs:SHARDS: 2 # should match matrix aboveJEST_JUNIT_OUTPUT_DIR: ./target/junitJEST_JUNIT_OUTPUT_NAME: test-report-frontend-unit.xml+ UNIT_TEST_RESULTS_FILE: unit-test-results.jsonsteps:- uses: actions/checkout@v6- name: Prepare front-end environment@@ -110,11 +118,36 @@ jobs:# Resolve JOB_ID before the long test step so the ci-conductor reporter# below can link failures to this exact job. Best-effort.uses: ./.github/actions/resolve-job-id+ - name: Download test plan+ id: test-plan+ if: ${{ inputs.test-plan-artifact-id != '' }}+ continue-on-error: true+ uses: actions/download-artifact@v8+ with:+ artifact-ids: ${{ inputs.test-plan-artifact-id }}+ path: ${{ runner.temp }}/test-plan+ - name: Prepare unit test selection+ id: unit-selection+ if: ${{ inputs.test-plan-artifact-id != '' }}+ env:+ PLAN_DOWNLOADED: ${{ steps.test-plan.outcome }}+ run: bun .github/scripts/prepare-unit-test-selection.ts- name: Run frontend unit testsid: fe-tests- run: bun run test-unit --silent --shard=${{ matrix.shard }}/${{ env.SHARDS }}- # Keep this step continue-on-error because the quarantine logic controls whether it ultimately fails.+ env:+ JEST_TEST_PATHS_FILE: ${{ steps.unit-selection.outputs.paths-file }}+ # Jest exits non-zero on a shard with no files unless --passWithNoTests is set.+ run: |+ rm -f "$UNIT_TEST_RESULTS_FILE" "$JEST_JUNIT_OUTPUT_DIR/$JEST_JUNIT_OUTPUT_NAME"+ bun run test-unit --silent --shard=${{ matrix.shard }}/${{ env.SHARDS }} --json --outputFile="$UNIT_TEST_RESULTS_FILE" ${{ steps.unit-selection.outputs.paths-file && '--passWithNoTests' || '' }}+ # Ordinary assertion failures can be quarantined, but runner failures cannot.continue-on-error: true+ - name: Check unit test results+ if: ${{ !cancelled() && (steps.fe-tests.outcome == 'failure' || steps.unit-selection.outputs.paths-file) }}+ env:+ TEST_OUTCOME: ${{ steps.fe-tests.outcome }}+ JEST_TEST_PATHS_FILE: ${{ steps.unit-selection.outputs.paths-file }}+ run: bun .github/scripts/check-unit-test-results.ts- name: Report failed tests to ci-conductorif: ${{ !cancelled() && ( steps.fe-tests.outcome == 'failure' || github.run_attempt != '1' ) }}# This step should NEVER fail the job!@@ -144,6 +177,18 @@ jobs:- name: Run frontend timezones testsrun: bun run test-timezones+ # No CLJS compile: the CI-script specs don't import app code.+ fe-tests-ci-scripts:+ if: ${{ !inputs.skip-ci-scripts }}+ runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}+ timeout-minutes: 10+ steps:+ - uses: actions/checkout@v6+ - name: Prepare front-end environment+ uses: ./.github/actions/prepare-frontend+ - name: Run CI script tests+ run: bun run test-ci-scripts+# The custom-viz package is an isolated Bun workspace under# enterprise/frontend/src/custom-vizfe-custom-viz:@@ -174,6 +219,7 @@ jobs:- fe-type-check- fe-tests-unit- fe-tests-timezones+ - fe-tests-ci-scripts- fe-custom-vizif: always() && !cancelled()runs-on: ${{ vars.SLIM_RUNNER_KEY }}diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.ymlindex a220e6bb4ec..7d33f553258 100644--- a/.github/workflows/run-tests.yml+++ b/.github/workflows/run-tests.yml@@ -69,6 +69,7 @@ jobs:embedding_sdk_host_sample_apps: ${{ steps.changes.outputs.embedding_sdk_host_sample_apps }}embedding_sdk_ci: ${{ steps.changes.outputs.embedding_sdk_ci }}custom_viz_all: ${{ steps.changes.outputs.custom_viz_all }}+ ci_scripts: ${{ steps.changes.outputs.ci_scripts }}project_backend_checks: ${{ steps.changes.outputs.project_backend_checks }}project_migration_checks: ${{ steps.changes.outputs.project_migration_checks }}project_ratchet_checks: ${{ steps.changes.outputs.project_ratchet_checks }}@@ -97,16 +98,14 @@ jobs:filters: .github/file-paths.yamlcreate-test-plan:- needs: files-changed+ needs: [should-run, files-changed]name: Create test plan- if: ${{ github.event_name == 'pull_request' }}+ if: ${{ github.event_name == 'pull_request' && needs.should-run.outputs.verdict == 'defer' }}runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}timeout-minutes: 10outputs:stats: ${{ steps.compute.outputs.stats }}- fe_unit_specs_to_run: ${{ steps.compute.outputs.fe_unit_specs_to_run }}- loki_stories_to_run: ${{ steps.compute.outputs.loki_stories_to_run }}- e2e_specs_to_run: ${{ steps.compute.outputs.e2e_specs_to_run }}+ artifact-id: ${{ steps.compute.outputs.artifact-id }}steps:- uses: actions/checkout@v6- name: Create test plan@@ -292,7 +291,7 @@ jobs:force-run: ${{ needs.should-run.outputs.verdict == 'force-run' }}frontend-tests:- needs: [should-run, files-changed]+ needs: [should-run, files-changed, create-test-plan]if: |!cancelled() &&(needs.should-run.outputs.verdict == 'force-run' ||@@ -303,6 +302,8 @@ jobs:skip: >-${{ needs.should-run.outputs.verdict != 'force-run' &&needs.files-changed.outputs.frontend_all != 'true' }}+ # A skipped/failed planner supplies no artifact, so the suite runs in full.+ test-plan-artifact-id: ${{ needs.create-test-plan.result == 'success' && needs.create-test-plan.outputs.artifact-id || '' }}skip-lint: >-${{ needs.should-run.outputs.verdict != 'force-run' &&needs.files-changed.outputs.frontend_all != 'true' &&@@ -310,6 +311,9 @@ jobs:skip-custom-viz: >-${{ needs.should-run.outputs.verdict != 'force-run' &&needs.files-changed.outputs.custom_viz_all != 'true' }}+ skip-ci-scripts: >-+ ${{ needs.should-run.outputs.verdict != 'force-run' &&+ needs.files-changed.outputs.ci_scripts != 'true' }}loki-tests:needs: [should-run, files-changed]diff --git a/frontend/test/jest-test-paths-filter.ts b/frontend/test/jest-test-paths-filter.tsnew file mode 100644index 00000000000..b7e4fd83bb9--- /dev/null+++ b/frontend/test/jest-test-paths-filter.ts@@ -0,0 +1,13 @@+/* eslint-disable @typescript-eslint/no-require-imports -- Jest requires this module as a CommonJS function. */+const fs = require("node:fs");+const path = require("node:path");++// Jest requires the filter directly, without transforms or default-export interop.+// CI's Node version strips the TypeScript annotations when loading this file.+module.exports = (testPaths: string[]) => {+ const listed: string[] = JSON.parse(+ fs.readFileSync(process.env.JEST_TEST_PATHS_FILE, "utf8"),+ );+ const keep = new Set(listed.map((p) => path.resolve(p)));+ return { filtered: testPaths.filter((p) => keep.has(p)) };+};diff --git a/jest.config.js b/jest.config.jsindex abf875435d1..cdba88d577b 100644--- a/jest.config.js+++ b/jest.config.js@@ -5,6 +5,12 @@ const baseConfig = require("./jest.base.conf.js");// default sharded run, because they need --expose-gc and a quiet heap.const MEMORY_TEST_PATTERN = "\\.leak\\.unit\\.spec\\.";+const nodeProject = {+ testEnvironment: "node",+ transform: baseConfig.transform,+ transformIgnorePatterns: baseConfig.transformIgnorePatterns,+};+/** @type {import('jest').Config} */const config = {// `addFileAttribute` makes jest-junit emit the source path as a `file`@@ -17,6 +23,10 @@ const config = {"jest-watch-typeahead/testname",],testTimeout: 30000,+ // CI narrows a run to the plan's spec files by pointing this at a JSON list.+ ...(process.env.JEST_TEST_PATHS_FILE && {+ filter: "<rootDir>/frontend/test/jest-test-paths-filter.ts",+ }),projects: [{...baseConfig,@@ -59,15 +69,19 @@ const config = {"<rootDir>/enterprise/frontend/src/embedding-sdk-ee","<rootDir>/enterprise/frontend/src/custom-viz","<rootDir>/frontend/lint/tests",+ "<rootDir>/.github",MEMORY_TEST_PATTERN,],},{+ ...nodeProject,displayName: "lint-rules",testMatch: ["<rootDir>/frontend/lint/tests/**/*.unit.spec.js"],- testEnvironment: "node",- transform: baseConfig.transform,- transformIgnorePatterns: baseConfig.transformIgnorePatterns,+ },+ {+ ...nodeProject,+ displayName: "ci-scripts",+ testMatch: ["<rootDir>/.github/**/*.unit.spec.{js,jsx,ts,tsx}"],},],};diff --git a/package.json b/package.jsonindex a5479a3391f..c5fbcacbd58 100644--- a/package.json+++ b/package.json@@ -488,6 +488,7 @@"storybook-pure": "storybook dev -p 6006","storybook-embedding-sdk": "IS_EMBEDDING_SDK=true storybook dev -c frontend/src/embedding-sdk-shared/.storybook -p 6006","test": "bun run test-unit && bun run test-timezones && bun run test-cypress",+ "test-ci-scripts": "jest --selectProjects ci-scripts --maxWorkers=4","test-cljs": "bun install && shadow-cljs compile test && node target/node-tests.js","test-cypress": "tsx ./e2e/runner/run_cypress_local.ts","test-cypress-host-sample-apps": "tsx ./e2e/runner/run_cypress_host_sample_apps.ts",@@ -495,8 +496,8 @@"test-timezones": "bun install && ./frontend/test/__runner__/run_timezone_tests","test-memory": "node --expose-gc ./node_modules/.bin/jest --runInBand --config jest.memory.conf.js","test-timezones-unit": "jest --silent --maxWorkers=4 --config jest.tz.unit.conf.js",- "test-unit": "bun run build:cljs && jest --maxWorkers=4",- "test-unit-keep-cljs": "jest --maxWorkers=4",+ "test-unit": "bun run build:cljs && jest --ignoreProjects ci-scripts --maxWorkers=4",+ "test-unit-keep-cljs": "jest --ignoreProjects ci-scripts --maxWorkers=4","test-unit-watch": "bun run test-unit --watch","test-unit-watch:cljs": "bun run concurrently -n 'cljs,tests' 'bun run build-watch:cljs' 'bun run test-unit-keep-cljs --watch'","test-visual:loki": "NODE_ENV=development loki test --chromeFlags='--headless --disable-gpu' ",