Consolidate vitest CI & coverage (#33808)

* Consolidate modules vitest coverage

* Use vite-common as base for modules vitest config

* Make knip happier

* Fix coverage paths

* Place modules unit tests alongside src

* Switch to defineProject for better type safety

* Consolidate vitest CI & coverage

Kills off vite-common

* Update comment

* Update lockfile

* Fix shared-components vitest config

* Soften eslint config for tests in modules

* Run eslint on modules/playwright dir too

* Make tsc happy
This commit is contained in:
Michael Telatynski
2026-06-10 17:00:34 +01:00
committed by GitHub
parent 042ded86c7
commit e9a89d9872
34 changed files with 252 additions and 301 deletions
+3 -7
View File
@@ -97,15 +97,12 @@ jobs:
!apps/web/coverage/lcov-report
vitest:
name: Vitest
name: Vitest${{ case(matrix.path == '.', '', format(' {0}', matrix.path)) }}
strategy:
matrix:
path:
- apps/desktop
- packages/shared-components
- packages/module-api
- modules/widget-lifecycle
- modules/widget-toggles
- "."
runs-on: ubuntu-24.04
steps:
# Dump the disk usage before we start: this job frequently flakes with "No space left on device"
@@ -139,7 +136,6 @@ jobs:
- name: Setup playwright
uses: ./.github/actions/setup-playwright
if: matrix.path == 'packages/shared-components' || matrix.path == 'modules/widget-toggles'
with:
write-cache: ${{ github.event_name != 'merge_group' }}
@@ -159,7 +155,7 @@ jobs:
NAME=$(basename "$MATRIX_PATH")
echo "name=$NAME" >> $GITHUB_OUTPUT
env:
MATRIX_PATH: ${{ matrix.path }}
MATRIX_PATH: ${{ case(matrix.path == '.', 'vite', format(' {0}', matrix.path)) }}
- name: Upload Artifact
if: env.ENABLE_COVERAGE == 'true'
-2
View File
@@ -74,7 +74,6 @@
"@babel/preset-typescript": "^7.18.6",
"@electron/asar": "4.2.0",
"@electron/fuses": "^2.1.1",
"@element-hq/vite-common": "workspace:*",
"@playwright/test": "catalog:",
"@stylistic/eslint-plugin": "^5.0.0",
"@types/auto-launch": "^5.0.1",
@@ -84,7 +83,6 @@
"@types/pacote": "^11.1.1",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"@vitest/coverage-v8": "catalog:",
"app-builder-lib": "26.15.1",
"chokidar": "^5.0.0",
"detect-libc": "^2.0.0",
+14 -7
View File
@@ -7,9 +7,13 @@ Please see LICENSE files in the repository root for full details.
import { expect, describe, it, beforeEach, vi } from "vitest";
import { fs as memfs, vol } from "memfs";
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { getBuildConfig } from "./build-config.js";
const __dirname = dirname(fileURLToPath(import.meta.url));
vi.mock("node:fs", () => ({ default: memfs }));
beforeEach(() => {
@@ -19,13 +23,16 @@ beforeEach(() => {
describe("getBuildConfig", () => {
it("should read fields from package.json correctly", () => {
vol.fromJSON({
"package.json": JSON.stringify({
electron_appId: "app.id",
electron_protocol: "proto",
electron_windows_cert_sn: "subject.name",
}),
});
vol.fromJSON(
{
"../package.json": JSON.stringify({
electron_appId: "app.id",
electron_protocol: "proto",
electron_windows_cert_sn: "subject.name",
}),
},
__dirname,
);
const config = getBuildConfig();
expect(config.appId).toBe("app.id");
+8 -5
View File
@@ -7,10 +7,13 @@ Please see LICENSE files in the repository root for full details.
import { expect, describe, it, beforeEach, vi } from "vitest";
import { fs as memfs, vol } from "memfs";
import path from "node:path";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { getIconPath } from "./icon.js";
const __dirname = dirname(fileURLToPath(import.meta.url));
vi.mock("node:fs/promises", () => ({ default: memfs.promises }));
beforeEach(() => {
@@ -25,20 +28,20 @@ describe("getIconPath", () => {
"build/icon.png": "png",
"build/icon.ico": "ico",
},
"../webapp",
resolve(__dirname, "../webapp"),
);
});
it("should use .ico on Windows", async () => {
vi.spyOn(process, "platform", "get").mockReturnValue("win32");
await expect(getIconPath()).resolves.toEqual(path.resolve("../build/icon.ico"));
await expect(getIconPath()).resolves.toEqual(resolve(__dirname, "../build/icon.ico"));
});
it("should use .png on macOS", async () => {
vi.spyOn(process, "platform", "get").mockReturnValue("darwin");
await expect(getIconPath()).resolves.toEqual(path.resolve("../build/icon.png"));
await expect(getIconPath()).resolves.toEqual(resolve(__dirname, "../build/icon.png"));
});
it("should use .png on Linux", async () => {
vi.spyOn(process, "platform", "get").mockReturnValue("linux");
await expect(getIconPath()).resolves.toEqual(path.resolve("../build/icon.png"));
await expect(getIconPath()).resolves.toEqual(resolve(__dirname, "../build/icon.png"));
});
});
+9 -15
View File
@@ -5,19 +5,13 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { defineConfig, mergeConfig } from "vitest/config";
import baseConfig from "@element-hq/vite-common/vite.config.js";
import { defineProject } from "vitest/config";
export default mergeConfig(
baseConfig,
defineConfig({
test: {
coverage: {
// The coverage report currently chokes on this file as it doesn't process it as TypeScript
exclude: ["src/preload.cts"],
},
include: ["src/**/*.test.ts"],
},
}),
true,
);
export default defineProject({
test: {
include: ["src/**/*.test.ts"],
environment: "node",
pool: "threads",
globals: false,
},
});
+1
View File
@@ -65,6 +65,7 @@ export default {
"lipo",
],
},
"modules": {},
"modules/*": {
entry: "src/index.ts{x,}",
},
+2 -2
View File
@@ -42,7 +42,7 @@ module.exports = {
},
overrides: [
{
files: ["playwright/**/*.ts", "modules/*/e2e/**/*.{ts,tsx}"],
files: ["playwright/**/*.ts", "*/e2e/**/*.{ts,tsx}", "*/src/**/*.test.{ts,tsx}"],
rules: {
// This is necessary for Playwright fixtures
"no-empty-pattern": "off",
@@ -55,7 +55,7 @@ module.exports = {
],
settings: {
react: {
version: "detect",
version: "19",
},
},
};
+1 -1
View File
@@ -3,7 +3,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"lint:js": "eslint --max-warnings 0 */src -c ./.eslintrc.cjs",
"lint:js": "eslint --max-warnings 0 playwright */src -c ./.eslintrc.cjs",
"lint:ts": "tsc --noEmit",
"test:playwright": "nx test:playwright --",
"test:playwright:open": "nx test:playwright -- --ui",
+1 -1
View File
@@ -45,7 +45,7 @@ playwright project.
const projects: Project<Options>[] = [];
// Get all the directories that hold playwright tests
const moduleTestDirectories = globSync("*/e2e", { cwd: __dirname });
const moduleTestDirectories = globSync("*/e2e", { cwd: __dirname }).map((d) => path.join(__dirname, d));
// Process each directory
for (const testDirectory of moduleTestDirectories) {
-1
View File
@@ -13,7 +13,6 @@
"devDependencies": {
"@element-hq/element-web-module-api": "workspace:*",
"@types/node": "^22.10.7",
"@vitest/coverage-v8": "catalog:",
"typescript": "catalog:",
"vite": "catalog:",
"vitest": "catalog:"
@@ -7,12 +7,13 @@ Please see LICENSE files in the repository root for full details.
import { describe, expect, it } from "vitest";
import WidgetLifecycleModule, { type WidgetLifecycleApiAdapter } from "../src/WidgetLifecycleModule";
import WidgetLifecycleModule, { type WidgetLifecycleApiAdapter } from "./WidgetLifecycleModule";
import type {
CapabilitiesApprover,
IdentityApprover,
PreloadApprover,
WidgetDescriptor,
Api,
} from "@element-hq/element-web-module-api";
const createApi = (config: unknown = {}) => {
@@ -40,7 +41,7 @@ const createApi = (config: unknown = {}) => {
get: () => config,
},
widgetLifecycle,
},
} as Api,
handlers,
};
};
@@ -49,7 +50,8 @@ const widget: WidgetDescriptor = {
id: "widget-id",
templateUrl: "https://example.com/",
creatorUserId: "@user-id",
kind: "room",
type: "com.example.custom",
origin: "example.com",
};
describe("WidgetLifecycleModule", () => {
@@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
import { describe, expect, it } from "vitest";
import { parseWidgetLifecycleConfig } from "../src/config";
import { parseWidgetLifecycleConfig } from "./config";
describe("parseWidgetLifecycleConfig", () => {
it("accepts missing configuration", () => {
@@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.
import { describe, expect, it } from "vitest";
import { constructWidgetPermissions, sortLongestMatchLast } from "../src/utils/constructWidgetPermissions";
import { constructWidgetPermissions, sortLongestMatchLast } from "./constructWidgetPermissions";
describe("constructWidgetPermissions", () => {
it("finds exact match", () => {
@@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.
import { describe, expect, it } from "vitest";
import { matchPattern } from "../src/utils/matchPattern";
import { matchPattern } from "./matchPattern";
describe("matchPattern", () => {
it.each([
+2 -9
View File
@@ -5,17 +5,10 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { defineConfig } from "vitest/config";
import { defineProject } from "vitest/config";
export default defineConfig({
export default defineProject({
test: {
include: ["tests/**/*.test.ts"],
exclude: ["./e2e/**/*", "./node_modules/**/*"],
reporters: ["default"],
coverage: {
provider: "v8",
include: ["src/**/*.ts"],
reporter: [["lcov", { projectRoot: "../../" }], "text"],
},
},
});
-1
View File
@@ -20,7 +20,6 @@
"@types/react": "^19",
"@vitejs/plugin-react": "catalog:",
"@vitest/browser-playwright": "catalog:",
"@vitest/coverage-v8": "catalog:",
"react": "catalog:",
"typescript": "catalog:",
"vite": "catalog:",
@@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
import { describe, expect, test } from "vitest";
import { WidgetTogglesConfig } from "../src/config";
import { WidgetTogglesConfig } from "./config";
describe("WidgetTogglesConfig", () => {
test("parses a valid config with an array of widget types", () => {
@@ -10,9 +10,9 @@ import { render, type RenderResult, screen } from "@testing-library/react";
import { type Api } from "@element-hq/element-web-module-api";
import { type IWidget } from "matrix-widget-api";
import WidgetToggleModule from "../src/index";
import { CONFIG_KEY, WidgetTogglesConfig } from "../src/config";
import { mockWidget, mockWidgetApi } from "./mocks";
import WidgetToggleModule from "./index";
import { CONFIG_KEY, WidgetTogglesConfig } from "./config";
import { mockWidget, mockWidgetApi } from "./tests/mocks";
const makeApi = (widgets: IWidget[] = []): Api => {
const addRoomHeaderButtonCallback = vi.fn();
@@ -13,8 +13,8 @@ import { type PropsWithChildren } from "react";
import { TooltipProvider } from "@vector-im/compound-web";
import userEvent from "@testing-library/user-event";
import { WidgetToggle } from "../src/toggle";
import { mockI18nApi, mockWidget, mockWidgetApi } from "./mocks";
import { WidgetToggle } from "./toggle";
import { mockI18nApi, mockWidget, mockWidgetApi } from "./tests/mocks";
const roomId = "!room:example.com";
@@ -1,7 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"jsx": "react-jsx"
},
"include": ["."]
}
+3 -10
View File
@@ -5,25 +5,18 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { defineConfig } from "vitest/config";
import { defineProject } from "vitest/config";
import { playwright } from "@vitest/browser-playwright";
export default defineConfig({
export default defineProject({
test: {
include: ["tests/**/*.test.{ts,tsx}"],
exclude: ["./e2e/**/*", "./node_modules/**/*"],
reporters: ["default"],
coverage: {
provider: "v8",
include: ["src/**/*.ts"],
reporter: [["lcov", { projectRoot: "../../" }], "text"],
},
browser: {
enabled: true,
headless: true,
provider: playwright({}),
instances: [{ browser: "chromium" }],
},
setupFiles: ["tests/setupTests.ts"],
setupFiles: ["src/tests/setupTests.ts"],
},
});
+4 -1
View File
@@ -23,7 +23,8 @@
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
"coverage:diff": "diff-cover --config-file diff-cover.toml apps/*/coverage/lcov.info packages/*/coverage/lcov.info"
"test:unit": "vitest run",
"coverage:diff": "diff-cover --config-file diff-cover.toml apps/web/coverage/lcov.info packages/shared-components/coverage/lcov.info coverage/lcov.info"
},
"devDependencies": {
"@action-validator/cli": "^0.6.0",
@@ -31,6 +32,7 @@
"@nx-tools/nx-container": "^7.2.1",
"@playwright/test": "catalog:",
"@types/node": "22",
"@vitest/coverage-v8": "catalog:",
"cronstrue": "^3.0.0",
"eslint-plugin-matrix-org": "^3.0.0",
"husky": "^9.0.0",
@@ -42,6 +44,7 @@
"nx": "22.7.5",
"prettier": "3.8.3",
"typescript": "catalog:",
"vitest": "catalog:",
"vitepress": "^1.6.4",
"vitepress-plugin-mermaid": "^2.0.17",
"yaml": "^2.3.3"
-2
View File
@@ -37,14 +37,12 @@
"coverage:diff": "diff-cover --config-file ../../diff-cover.toml coverage/lcov.info"
},
"devDependencies": {
"@element-hq/vite-common": "workspace:*",
"@matrix-org/react-sdk-module-api": "^2.5.0",
"@microsoft/api-extractor": "^7.49.1",
"@types/node": "^22.10.7",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@types/semver": "^7.5.8",
"@vitest/coverage-v8": "catalog:",
"matrix-widget-api": "^1.17.0",
"rollup-plugin-external-globals": "^0.13.0",
"semver": "^7.6.3",
+27 -32
View File
@@ -7,43 +7,38 @@ Please see LICENSE files in the repository root for full details.
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig, mergeConfig } from "vitest/config";
import { defineConfig } from "vitest/config";
import dts from "unplugin-dts/vite";
import externalGlobals from "rollup-plugin-external-globals";
import baseConfig from "@element-hq/vite-common/vite.config";
import packageJson from "./package.json" with { type: "json" };
const __dirname = dirname(fileURLToPath(import.meta.url));
export default mergeConfig(
baseConfig,
defineConfig({
build: {
lib: {
entry: resolve(__dirname, "src/index.ts"),
name: "element-web-plugin-engine",
fileName: "element-web-plugin-engine",
},
outDir: "lib",
target: "esnext",
sourcemap: true,
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, "src/index.ts"),
name: "element-web-plugin-engine",
fileName: "element-web-plugin-engine",
},
plugins: [
dts(),
externalGlobals({
// Reuse React from the host app
react: "window.React",
}),
],
define: {
// We cannot use `process.env.npm_package_version` as when building element-web with module-api set to `workspace`
// this would contain the version of element-web rather than that of the module-api.
__VERSION__: JSON.stringify(packageJson.version),
// Use production mode for the build as it is tested against production builds of Element Web,
// this is required for React JSX versions to be compatible.
process: { env: { NODE_ENV: "production" } },
},
}),
true,
);
outDir: "lib",
target: "esnext",
sourcemap: true,
},
plugins: [
dts(),
externalGlobals({
// Reuse React from the host app
react: "window.React",
}),
],
define: {
// We cannot use `process.env.npm_package_version` as when building element-web with module-api set to `workspace`
// this would contain the version of element-web rather than that of the module-api.
__VERSION__: JSON.stringify(packageJson.version),
// Use production mode for the build as it is tested against production builds of Element Web,
// this is required for React JSX versions to be compatible.
process: { env: { NODE_ENV: "production" } },
},
});
+20
View File
@@ -0,0 +1,20 @@
/*
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { defineProject } from "vitest/config";
import viteConfig from "./vite.config";
export default defineProject({
test: {
environment: "node",
pool: "threads",
globals: false,
include: ["src/**/*.test.{ts,tsx}"],
},
define: viteConfig.define,
});
-2
View File
@@ -87,7 +87,6 @@
},
"devDependencies": {
"@element-hq/element-web-playwright-common": "workspace:*",
"@element-hq/vite-common": "workspace:*",
"@fetch-mock/vitest": "^0.2.18",
"@fontsource/inter": "catalog:",
"@matrix-org/react-sdk-module-api": "^2.5.0",
@@ -111,7 +110,6 @@
"@typescript-eslint/parser": "^8.53.1",
"@vector-im/compound-web": "catalog:",
"@vitest/browser-playwright": "catalog:",
"@vitest/coverage-v8": "catalog:",
"eslint": "8",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^10.1.8",
@@ -9,5 +9,5 @@
"types": [],
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts", "vitest.config.ts"]
"include": ["vite.config.ts", "vitest.config.ts", "../../vitest.config.ts"]
}
+91 -88
View File
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { defineConfig, mergeConfig } from "vitest/config";
import { defineConfig } from "vitest/config";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";
@@ -13,7 +13,7 @@ import { storybookVis } from "storybook-addon-vis/vitest-plugin";
import { playwright, PlaywrightProviderOptions } from "@vitest/browser-playwright";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import baseConfig from "@element-hq/vite-common/vite.config";
import rootConfig from "../../vitest.config";
const dirname = typeof __dirname !== "undefined" ? __dirname : path.dirname(fileURLToPath(import.meta.url));
@@ -30,94 +30,97 @@ const commonLaunchOptions = {
args: ["--font-render-hinting=none", "--disable-font-subpixel-positioning", "--disable-lcd-text"],
};
export default mergeConfig(
baseConfig,
defineConfig({
test: {
coverage: {
exclude: ["src/**/*.stories.tsx"],
},
projects: [
{
extends: true,
plugins: [
// The plugin will run tests for the stories defined in your Storybook config
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
storybookTest({
configDir: path.join(dirname, ".storybook"),
storybookScript: "storybook --ci",
tags: {
exclude: ["skip-test"],
},
}),
storybookVis({
// 3px of difference allowed before marking as failed
failureThreshold: 3,
// When running in CI=1 mode, set the platform to `linux` as that is the platform where the browser-in-docker is running
snapshotRootDir: ({ ci, platform }) => `__vis__/${ci ? "linux" : platform}`,
}),
],
test: {
name: "storybook",
browser: {
enabled: true,
headless: true,
provider: playwright({
contextOptions: commonContextOptions,
launchOptions: commonLaunchOptions,
connectOptions: process.env.PW_TEST_CONNECT_WS_ENDPOINT
? {
wsEndpoint: process.env.PW_TEST_CONNECT_WS_ENDPOINT,
exposeNetwork: "<loopback>",
}
: undefined,
}),
instances: [{ browser: "chromium" }],
export default defineConfig({
test: {
coverage: {
exclude: ["src/**/*.stories.tsx"],
provider: "v8",
include: ["src/**/*.{ts,tsx}"],
reporter: [["lcov", { projectRoot: "../../" }]],
},
reporters: rootConfig.test?.reporters,
environment: "node",
pool: "threads",
globals: false,
projects: [
{
extends: true,
plugins: [
// The plugin will run tests for the stories defined in your Storybook config
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
storybookTest({
configDir: path.join(dirname, ".storybook"),
storybookScript: "storybook --ci",
tags: {
exclude: ["skip-test"],
},
setupFiles: [".storybook/vitest.setup.ts"],
}),
storybookVis({
// 3px of difference allowed before marking as failed
failureThreshold: 3,
// When running in CI=1 mode, set the platform to `linux` as that is the platform where the browser-in-docker is running
snapshotRootDir: ({ ci, platform }) => `__vis__/${ci ? "linux" : platform}`,
}),
],
test: {
name: "storybook",
browser: {
enabled: true,
headless: true,
provider: playwright({
contextOptions: commonContextOptions,
launchOptions: commonLaunchOptions,
connectOptions: process.env.PW_TEST_CONNECT_WS_ENDPOINT
? {
wsEndpoint: process.env.PW_TEST_CONNECT_WS_ENDPOINT,
exposeNetwork: "<loopback>",
}
: undefined,
}),
instances: [{ browser: "chromium" }],
},
setupFiles: [".storybook/vitest.setup.ts"],
},
},
{
extends: true,
// as any is workaround for https://github.com/davidmyersdev/vite-plugin-node-polyfills/issues/150
plugins: [nodePolyfills({ include: ["util"], globals: { global: false } }) as any],
test: {
name: "unit",
browser: {
enabled: true,
headless: true,
provider: playwright({
// These tests don't actually take screenshots (at least at time of writing)
// but let's pass these options everywhere for consistency
contextOptions: commonContextOptions,
launchOptions: commonLaunchOptions,
}),
instances: [{ browser: "chromium" }],
},
setupFiles: ["src/test/setupTests.ts"],
},
css: {
modules: {
// Stabilise snapshots while keeping names distinct across CSS modules.
generateScopedName: "[name]_[local]",
},
},
{
extends: true,
// as any is workaround for https://github.com/davidmyersdev/vite-plugin-node-polyfills/issues/150
plugins: [nodePolyfills({ include: ["util"], globals: { global: false } }) as any],
test: {
name: "unit",
browser: {
enabled: true,
headless: true,
provider: playwright({
// These tests don't actually take screenshots (at least at time of writing)
// but let's pass these options everywhere for consistency
contextOptions: commonContextOptions,
launchOptions: commonLaunchOptions,
}),
instances: [{ browser: "chromium" }],
},
setupFiles: ["src/test/setupTests.ts"],
},
css: {
modules: {
// Stabilise snapshots while keeping names distinct across CSS modules.
generateScopedName: "[name]_[local]",
},
},
},
],
},
optimizeDeps: {
include: [
"vite-plugin-node-polyfills/shims/buffer",
"vite-plugin-node-polyfills/shims/process",
"@vector-im/compound-design-tokens/assets/web/icons",
"storybook/preview-api",
],
},
resolve: {
alias: {
"@test-utils": path.resolve(__dirname, "./src/test/utils/index.tsx"),
},
],
},
optimizeDeps: {
include: [
"vite-plugin-node-polyfills/shims/buffer",
"vite-plugin-node-polyfills/shims/process",
"@vector-im/compound-design-tokens/assets/web/icons",
"storybook/preview-api",
],
},
resolve: {
alias: {
"@test-utils": path.resolve(__dirname, "./src/test/utils/index.tsx"),
},
}),
true,
);
},
});
-18
View File
@@ -1,18 +0,0 @@
{
"name": "@element-hq/vite-common",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"lint:types": "tsc --noEmit"
},
"dependencies": {
"vitest": "catalog:"
},
"devDependencies": {
"typescript": "catalog:"
},
"peerDependencies": {
"@vitest/coverage-v8": "catalog:"
}
}
-9
View File
@@ -1,9 +0,0 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "esnext",
"moduleResolution": "bundler",
"strict": true
},
"include": ["vite.config.ts"]
}
+33 -62
View File
@@ -318,6 +318,9 @@ importers:
'@types/node':
specifier: 22.13.14
version: 22.13.14
'@vitest/coverage-v8':
specifier: 'catalog:'
version: 4.1.8(@vitest/browser@4.1.8)(vitest@4.1.8)
cronstrue:
specifier: ^3.0.0
version: 3.14.0
@@ -357,6 +360,9 @@ importers:
vitepress-plugin-mermaid:
specifier: ^2.0.17
version: 2.0.17(mermaid@11.15.0)(vitepress@1.6.4(@algolia/client-search@5.50.0)(@types/node@22.13.14)(@types/react@19.2.14)(axios@1.16.1)(jwt-decode@4.0.0)(lightningcss@1.32.0)(postcss@8.5.15)(qrcode@1.5.4)(search-insights@2.17.3)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(typescript@6.0.3))
vitest:
specifier: 'catalog:'
version: 4.1.8(@opentelemetry/api@1.9.1)(@types/node@22.13.14)(@vitest/browser-playwright@4.1.8)(@vitest/coverage-v8@4.1.8)(jsdom@26.1.0(patch_hash=040623e87b1c8b676c2a705513c0276c0704dd1b23fc3a1bb77cde8128b64b5f))(vite@8.0.16(@types/node@22.13.14)(esbuild@0.27.4)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.8.4))
yaml:
specifier: 2.8.4
version: 2.8.4
@@ -403,9 +409,6 @@ importers:
'@electron/fuses':
specifier: ^2.1.1
version: 2.1.1
'@element-hq/vite-common':
specifier: workspace:*
version: link:../../packages/vite-common
'@playwright/test':
specifier: 'catalog:'
version: 1.60.0
@@ -433,9 +436,6 @@ importers:
'@typescript-eslint/parser':
specifier: ^8.0.0
version: 8.59.4(eslint@8.57.1)(typescript@6.0.3)
'@vitest/coverage-v8':
specifier: 'catalog:'
version: 4.1.8(@vitest/browser@4.1.8)(vitest@4.1.8)
app-builder-lib:
specifier: 26.15.1
version: 26.15.1(dmg-builder@26.15.1)(electron-builder-squirrel-windows@26.15.1)
@@ -913,7 +913,7 @@ importers:
version: 7.1.4(webpack@5.107.1)
css-minimizer-webpack-plugin:
specifier: ^8.0.0
version: 8.0.0(lightningcss@1.32.0)(webpack@5.107.1)
version: 8.0.0(esbuild@0.27.4)(lightningcss@1.32.0)(webpack@5.107.1)
dotenv:
specifier: ^17.0.0
version: 17.4.2
@@ -1060,7 +1060,7 @@ importers:
version: 6.1.1(stylelint@17.12.0(typescript@6.0.3))
terser-webpack-plugin:
specifier: ^5.3.9
version: 5.6.0(lightningcss@1.32.0)(postcss@8.5.15)(webpack@5.107.1)
version: 5.6.0(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack@5.107.1)
testcontainers:
specifier: ^12.0.0
version: 12.0.1
@@ -1075,7 +1075,7 @@ importers:
version: 4.3.0
webpack:
specifier: ^5.89.0
version: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
version: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack-bundle-analyzer:
specifier: ^5.0.0
version: 5.3.0
@@ -1244,9 +1244,6 @@ importers:
'@types/node':
specifier: 22.13.14
version: 22.13.14
'@vitest/coverage-v8':
specifier: 'catalog:'
version: 4.1.8(@vitest/browser@4.1.8)(vitest@4.1.8)
typescript:
specifier: 'catalog:'
version: 6.0.3
@@ -1302,9 +1299,6 @@ importers:
'@vitest/browser-playwright':
specifier: 'catalog:'
version: 4.1.8(playwright@1.60.0)(vite@8.0.16(@types/node@22.13.14)(esbuild@0.27.4)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.8.4))(vitest@4.1.8)
'@vitest/coverage-v8':
specifier: 'catalog:'
version: 4.1.8(@vitest/browser@4.1.8)(vitest@4.1.8)
react:
specifier: 'catalog:'
version: 19.2.6
@@ -1333,9 +1327,6 @@ importers:
specifier: ^19
version: 19.2.6
devDependencies:
'@element-hq/vite-common':
specifier: workspace:*
version: link:../vite-common
'@matrix-org/react-sdk-module-api':
specifier: ^2.5.0
version: 2.5.0(patch_hash=016146c9cc96e6363609d2b2ac0896ccef567882eb1d73b75a77b8a30929de96)(react@19.2.6)
@@ -1354,9 +1345,6 @@ importers:
'@types/semver':
specifier: ^7.5.8
version: 7.7.1
'@vitest/coverage-v8':
specifier: 'catalog:'
version: 4.1.8(@vitest/browser@4.1.8)(vitest@4.1.8)
matrix-widget-api:
specifier: ^1.17.0
version: 1.17.0
@@ -1497,9 +1485,6 @@ importers:
'@element-hq/element-web-playwright-common':
specifier: workspace:*
version: link:../playwright-common
'@element-hq/vite-common':
specifier: workspace:*
version: link:../vite-common
'@fetch-mock/vitest':
specifier: ^0.2.18
version: 0.2.18(vitest@4.1.8)
@@ -1569,9 +1554,6 @@ importers:
'@vitest/browser-playwright':
specifier: 'catalog:'
version: 4.1.8(playwright@1.60.0)(vite@8.0.16(@types/node@22.13.14)(esbuild@0.27.4)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.8.4))(vitest@4.1.8)
'@vitest/coverage-v8':
specifier: 'catalog:'
version: 4.1.8(@vitest/browser@4.1.8)(vitest@4.1.8)
eslint:
specifier: '8'
version: 8.57.1
@@ -1642,19 +1624,6 @@ importers:
specifier: 'catalog:'
version: 4.1.8(@opentelemetry/api@1.9.1)(@types/node@22.13.14)(@vitest/browser-playwright@4.1.8)(@vitest/coverage-v8@4.1.8)(jsdom@26.1.0(patch_hash=040623e87b1c8b676c2a705513c0276c0704dd1b23fc3a1bb77cde8128b64b5f))(vite@8.0.16(@types/node@22.13.14)(esbuild@0.27.4)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.8.4))
packages/vite-common:
dependencies:
'@vitest/coverage-v8':
specifier: 'catalog:'
version: 4.1.8(@vitest/browser@4.1.8)(vitest@4.1.8)
vitest:
specifier: 'catalog:'
version: 4.1.8(@opentelemetry/api@1.9.1)(@types/node@22.13.14)(@vitest/browser-playwright@4.1.8)(@vitest/coverage-v8@4.1.8)(jsdom@26.1.0(patch_hash=040623e87b1c8b676c2a705513c0276c0704dd1b23fc3a1bb77cde8128b64b5f))(vite@8.0.16(@types/node@22.13.14)(esbuild@0.27.4)(jiti@2.7.0)(sugarss@5.0.1(postcss@8.5.15))(terser@5.48.0)(yaml@2.8.4))
devDependencies:
typescript:
specifier: 'catalog:'
version: 6.0.3
packages:
'@action-validator/cli@0.6.0':
@@ -17266,7 +17235,7 @@ snapshots:
'@principalstudio/html-webpack-inject-preload@1.2.7(html-webpack-plugin@5.6.7(webpack@5.107.1))(webpack@5.107.1)':
dependencies:
html-webpack-plugin: 5.6.7(webpack@5.107.1)
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
'@prisma/instrumentation@7.6.0(@opentelemetry/api@1.9.1)':
dependencies:
@@ -18008,7 +17977,7 @@ snapshots:
'@sentry/webpack-plugin@5.3.0(webpack@5.107.1)':
dependencies:
'@sentry/bundler-plugin-core': 5.3.0
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
transitivePeerDependencies:
- encoding
- supports-color
@@ -19884,7 +19853,7 @@ snapshots:
'@babel/core': 7.29.0
find-up: 5.0.0
optionalDependencies:
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
babel-plugin-const-enum@1.2.0(@babel/core@7.29.0):
dependencies:
@@ -20572,7 +20541,7 @@ snapshots:
schema-utils: 4.3.3
serialize-javascript: 7.0.5
tinyglobby: 0.2.17
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
core-js-compat@3.49.0:
dependencies:
@@ -20722,9 +20691,9 @@ snapshots:
postcss-value-parser: 4.2.0
semver: 7.8.1
optionalDependencies:
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
css-minimizer-webpack-plugin@8.0.0(lightningcss@1.32.0)(webpack@5.107.1):
css-minimizer-webpack-plugin@8.0.0(esbuild@0.27.4)(lightningcss@1.32.0)(webpack@5.107.1):
dependencies:
'@jridgewell/trace-mapping': 0.3.31
cssnano: 7.1.2(postcss@8.5.15)
@@ -20732,8 +20701,9 @@ snapshots:
postcss: 8.5.15
schema-utils: 4.3.3
serialize-javascript: 7.0.5
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
optionalDependencies:
esbuild: 0.27.4
lightningcss: 1.32.0
css-prefers-color-scheme@11.0.0(postcss@8.5.15):
@@ -22158,7 +22128,7 @@ snapshots:
dependencies:
loader-utils: 2.0.4
schema-utils: 3.3.0
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
file-saver@2.0.5: {}
@@ -22668,7 +22638,7 @@ snapshots:
pretty-error: 4.0.0
tapable: 2.3.3
optionalDependencies:
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
htmlparser2@10.1.0:
dependencies:
@@ -24110,7 +24080,7 @@ snapshots:
dependencies:
schema-utils: 4.3.3
tapable: 2.3.3
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
minimalistic-assert@1.0.1: {}
@@ -25177,7 +25147,7 @@ snapshots:
postcss: 8.5.15
semver: 7.8.1
optionalDependencies:
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
transitivePeerDependencies:
- typescript
@@ -25680,7 +25650,7 @@ snapshots:
dependencies:
loader-utils: 2.0.4
schema-utils: 3.3.0
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
re-resizable@6.11.2(react-dom@19.2.6(react@19.2.6))(react@19.2.6):
dependencies:
@@ -26492,7 +26462,7 @@ snapshots:
dependencies:
iconv-lite: 0.6.3
source-map-js: 1.2.1
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
source-map-support@0.5.13:
dependencies:
@@ -27061,14 +27031,15 @@ snapshots:
postcss: 8.5.15
optional: true
terser-webpack-plugin@5.6.0(lightningcss@1.32.0)(postcss@8.5.15)(webpack@5.107.1):
terser-webpack-plugin@5.6.0(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack@5.107.1):
dependencies:
'@jridgewell/trace-mapping': 0.3.31
jest-worker: 27.5.1
schema-utils: 4.3.3
terser: 5.48.0
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
optionalDependencies:
esbuild: 0.27.4
lightningcss: 1.32.0
postcss: 8.5.15
@@ -27840,7 +27811,7 @@ snapshots:
import-local: 3.2.0
interpret: 3.1.1
rechoir: 0.8.0
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack-merge: 6.0.1
optionalDependencies:
webpack-bundle-analyzer: 5.3.0
@@ -27855,7 +27826,7 @@ snapshots:
range-parser: 1.2.1
schema-utils: 4.3.3
optionalDependencies:
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
transitivePeerDependencies:
- tslib
@@ -27890,7 +27861,7 @@ snapshots:
webpack-dev-middleware: 7.4.5(tslib@2.8.1)(webpack@5.107.1)
ws: 8.21.0
optionalDependencies:
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack-cli: 7.0.2(webpack-bundle-analyzer@5.3.0)(webpack-dev-server@5.2.4)(webpack@5.107.1)
transitivePeerDependencies:
- bufferutil
@@ -27908,7 +27879,7 @@ snapshots:
webpack-retry-chunk-load-plugin@3.1.1(webpack@5.107.1):
dependencies:
prettier: 2.8.8
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack-sources@3.5.0: {}
@@ -27917,7 +27888,7 @@ snapshots:
ejs: 3.1.10
fs: 0.0.1-security
underscore: 1.13.8
webpack: 5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack: 5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2)
webpack-virtual-modules@0.6.2: {}
@@ -27961,7 +27932,7 @@ snapshots:
- uglify-js
optional: true
webpack@5.107.1(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2):
webpack@5.107.1(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack-cli@7.0.2):
dependencies:
'@types/estree': 1.0.9
'@types/json-schema': 7.0.15
@@ -27983,7 +27954,7 @@ snapshots:
neo-async: 2.6.2
schema-utils: 4.3.3
tapable: 2.3.3
terser-webpack-plugin: 5.6.0(lightningcss@1.32.0)(postcss@8.5.15)(webpack@5.107.1)
terser-webpack-plugin: 5.6.0(esbuild@0.27.4)(lightningcss@1.32.0)(postcss@8.5.15)(webpack@5.107.1)
watchpack: 2.5.1
webpack-sources: 3.5.0
optionalDependencies:
@@ -39,16 +39,28 @@ if (env["GITHUB_ACTIONS"] !== undefined) {
}
export default defineConfig({
oxc: {
// Configure the ts loader to handle all the files we may throw at it
include: /\.[cm]?tsx?$/,
},
test: {
projects: [
"{apps,modules,packages}/*/vitest.config.ts",
// We run shared-components separately for now as vitest lacks support for nested projects
// https://github.com/vitest-dev/vitest/issues/8544
"!packages/shared-components",
],
coverage: {
provider: "v8",
include: ["src/**/*.{ts,tsx}"],
reporter: [["lcov", { projectRoot: "../../" }]],
include: ["{apps,modules,packages}/*/src/**/*.{cts,ts,tsx}"],
exclude: [
// Exclude test files
"**/*.{stories,test}.tsx",
// Exclude type definition files
"**/*.d.ts",
],
reporter: [["lcov"]],
},
environment: "node",
reporters,
pool: "threads",
globals: false,
include: ["src/**/*.test.{ts,tsx}"],
},
});