mirror of
https://github.com/ChainSafe/lodestar.git
synced 2026-01-08 23:28:10 -05:00
test: use vitest workspace to run all tests (#7610)
**Motivation** Vitest workspaces is feature to mimic the package manager workspaces for the tests only. It provides following benefits: 1. Minimize the need the bunch of config files at every package root 2. Consolidate vitest configuration in project groups 3. Use consistent test configuration for all projects in the monorepo 4. Providing consistent test environment for all packages 5. Speed up visual interaction with tests in the IDEs (e.g. Visual Studio Code) **Description** - Remove all unnecessary config files - Update package json scripts to use `--project` flag Closes #7603 Now we have following test directories. | Directory | Description | CurrentPreset | Old Preset | |---|---|---|---| | test/unit | Unit tests | minimal | Default export from `params` package | | test/unit-mainnet | Unit tests | mainnet | mainnet | | test/e2e | End-to-End Tests | minimal | Default export from `params` package | | test/e2e-mainnet | End-to-End Tests | mainnet | Never existed before, mixed up pattern in different packages | | test/spec | Spec tests | minimal | Default export from `params` package, but common perception among team was that it's running with `minimal` | | test/spec-mainnet` | Spec tests | mainnet | Never existed as directory, but mixed up among packages | | test/browser | Symlink to `unit` for packages which supports browsers | minimal | Default export from `params` package | | test/types | Types test | minimal | Default export from `params` package | **Steps to test or reproduce** Run all tests
This commit is contained in:
93
vitest.config.ts
Normal file
93
vitest.config.ts
Normal file
@@ -0,0 +1,93 @@
|
||||
import path from "node:path";
|
||||
import {defineConfig} from "vitest/config";
|
||||
import {browserTestProject} from "./configs/vitest.config.browser.js";
|
||||
import {e2eMainnetProject, e2eProject} from "./configs/vitest.config.e2e.js";
|
||||
import {specProjectMainnet, specProjectMinimal} from "./configs/vitest.config.spec.js";
|
||||
import {typesTestProject} from "./configs/vitest.config.types.js";
|
||||
import {unitTestMainnetProject, unitTestProject} from "./configs/vitest.config.unit.js";
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
workspace: [
|
||||
{
|
||||
extends: true,
|
||||
...unitTestProject,
|
||||
},
|
||||
{
|
||||
extends: true,
|
||||
...unitTestMainnetProject,
|
||||
},
|
||||
{
|
||||
extends: true,
|
||||
...browserTestProject,
|
||||
},
|
||||
{
|
||||
extends: true,
|
||||
...e2eProject,
|
||||
},
|
||||
{
|
||||
extends: true,
|
||||
...e2eMainnetProject,
|
||||
},
|
||||
{
|
||||
extends: true,
|
||||
...specProjectMinimal,
|
||||
},
|
||||
{
|
||||
extends: true,
|
||||
...specProjectMainnet,
|
||||
},
|
||||
{
|
||||
extends: true,
|
||||
...typesTestProject,
|
||||
},
|
||||
],
|
||||
exclude: [
|
||||
"**/spec-tests/**",
|
||||
"**/spec-tests-bls/**",
|
||||
"**/*.browser.test.ts",
|
||||
"**/node_modules/**",
|
||||
"**/dist/**",
|
||||
"**/cypress/**",
|
||||
"**/.{idea,git,cache,output,temp}/**",
|
||||
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*",
|
||||
],
|
||||
env: {
|
||||
NODE_ENV: "test",
|
||||
},
|
||||
clearMocks: true,
|
||||
// Some test files allocate a lot of data, which could cause more time for teardown
|
||||
teardownTimeout: 5_000,
|
||||
// We have a few spec tests suits (specially spec tests) which don't have individual tests
|
||||
passWithNoTests: true,
|
||||
reporters: process.env.GITHUB_ACTIONS
|
||||
? ["verbose", "hanging-process", "github-actions"]
|
||||
: [process.env.TEST_COMPACT_OUTPUT ? "basic" : "verbose", "hanging-process"],
|
||||
diff: process.env.TEST_COMPACT_DIFF
|
||||
? path.join(import.meta.dirname, "../scripts/vitest/vitest.diff.ts")
|
||||
: undefined,
|
||||
onConsoleLog: () => !process.env.TEST_QUIET_CONSOLE,
|
||||
coverage: {
|
||||
enabled: false,
|
||||
clean: true,
|
||||
all: false,
|
||||
extension: [".ts"],
|
||||
provider: "v8",
|
||||
reporter: [["lcovonly", {file: "lcov.info"}], ["text"]],
|
||||
reportsDirectory: "./coverage",
|
||||
exclude: [
|
||||
"**/*.d.ts",
|
||||
"**/*.js",
|
||||
"**/lib/**",
|
||||
"**/coverage/**",
|
||||
"**/scripts/**",
|
||||
"**/test/**",
|
||||
"**/types/**",
|
||||
"**/bin/**",
|
||||
"**/node_modules/**",
|
||||
"**/spec-tests/**",
|
||||
"**/spec-tests-bls/**",
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user