chore: update the test runner (#7404)

**Motivation**

Update vitest and browser engine.

**Description**

- Move root level shared configs to `configs` directory
- Update to vitest 3.x
- Migrate from `webdriverio` to `playwright` which is more stable and
recommended by Vitest.

**NOTE**
Reverted the `playwright` upgrade. See the comments. 


d2a7af0308/configs/vitest.config.base.browser.ts (L41-L43)

**Steps to test or reproduce**

Run all tests
This commit is contained in:
Nazar Hussain
2025-02-27 16:27:43 +01:00
committed by GitHub
parent 2fc54906b3
commit 51efa3d604
76 changed files with 1603 additions and 1552 deletions

View File

@@ -71,7 +71,7 @@ If you observe following error running any of the test files that means you are
- Before running the tests, make sure to switch to the package directory (e.g. `packages/beacon-node`) to speed up test execution
```sh
LODESTAR_PRESET=minimal yarn vitest --run --bail 1 --config vitest.spec.config.ts test/spec/presets/sanity.test.ts -t attester_slashing
LODESTAR_PRESET=minimal yarn vitest run --bail 1 --config vitest.spec.config.ts test/spec/presets/sanity.test.ts -t attester_slashing
```
## Docker

View File

@@ -6,7 +6,7 @@
"useIgnoreFile": true
},
"files": {
"include": ["packages/*/src/**/*.ts", "packages/*/test/**/*.ts"]
"include": ["packages/*/src/**/*.ts", "packages/*/test/**/*.ts", "configs/**/*.ts"]
},
"formatter": {
"enabled": true,

View File

@@ -1,8 +1,8 @@
import {visualizer} from "rollup-plugin-visualizer";
import {UserConfig, defineConfig} from "vite";
import {nodePolyfills} from "vite-plugin-node-polyfills";
import {visualizer} from "rollup-plugin-visualizer";
import topLevelAwait from "vite-plugin-top-level-await";
import {blsBrowserPlugin} from "./scripts/vite/plugins/blsBrowserPlugin.js";
import {blsBrowserPlugin} from "../scripts/vite/plugins/blsBrowserPlugin.js";
export function getBaseViteConfig(
pkgInfo: {
@@ -41,10 +41,12 @@ export function getBaseViteConfig(
banner,
legalComments: "none",
sourcemap: "inline",
supported: {
"top-level-await": true,
},
},
build: {
// "modules" refer to ['es2020', 'edge88', 'firefox78', 'chrome87', 'safari14']
target: "modules",
target: "es2022",
outDir: "dist",
sourcemap: true,
minify: true,
@@ -57,13 +59,10 @@ export function getBaseViteConfig(
formats: ["es"],
name: libName,
fileName: (format) => {
if (format === "esm" || format === "es") {
return `${libName.toLowerCase()}.min.mjs`;
} else if (format === "cjs") {
return `${libName.toLowerCase()}.min.cjs`;
} else {
return `${libName.toLowerCase()}.min.${format}.js`;
}
if (format === "esm" || format === "es") return `${libName.toLowerCase()}.min.mjs`;
if (format === "cjs") return `${libName.toLowerCase()}.min.cjs`;
return `${libName.toLowerCase()}.min.${format}.js`;
},
},
rollupOptions: {

View File

@@ -0,0 +1,79 @@
/// <reference types="@vitest/browser/providers/webdriverio" />
import path from "node:path";
import {defineConfig} from "vitest/config";
const __dirname = new URL(".", import.meta.url).pathname;
import {nodePolyfills} from "vite-plugin-node-polyfills";
import topLevelAwait from "vite-plugin-top-level-await";
import {blsBrowserPlugin} from "../scripts/vite/plugins/blsBrowserPlugin.js";
export default defineConfig({
plugins: [
topLevelAwait(),
blsBrowserPlugin(),
nodePolyfills({
include: ["buffer", "process", "util", "string_decoder", "url", "querystring", "events"],
globals: {Buffer: true, process: true},
protocolImports: true,
}),
],
test: {
include: ["**/*.test.ts"],
exclude: [
"**/*.node.test.ts",
"**/node_modules/**",
"**/dist/**",
"**/lib/**",
"**/cypress/**",
"**/.{idea,git,cache,output,temp}/**",
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*",
],
setupFiles: [path.join(__dirname, "../scripts/vitest/setupFiles/customMatchers.ts")],
reporters: ["default", "hanging-process"],
coverage: {
enabled: false,
},
browser: {
enabled: true,
headless: true,
ui: false,
screenshotFailures: false,
// Recommended provider is `playwright` but it's causing following error on CI
// Error: Failed to connect to the browser session "af5be85a-7f29-4299-b680-b07f0cfc2520" within the timeout.
// TODO: Debug the issue in later versions of playwright and vitest
provider: "webdriverio",
connectTimeout: 90_0000,
instances: [
// TODO: Add support for webkit when available
// Invalid types from webdriverio for capabilities
{
browser: "firefox",
maxConcurrency: 1,
capabilities: {
browserVersion: "stable",
},
} as never,
// Invalid types from webdriverio for capabilities
{
browser: "chrome",
maxConcurrency: 1,
capabilities: {
browserVersion: "stable",
},
} as never,
],
},
},
resolve: {
alias: {
"node:perf_hooks": path.join(__dirname, "../scripts/vitest/polyfills/perf_hooks.js"),
},
},
optimizeDeps: {
include: [
"vite-plugin-node-polyfills/shims/buffer",
"vite-plugin-node-polyfills/shims/global",
"vite-plugin-node-polyfills/shims/process",
],
},
});

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "./vitest.base.unit.config.js";
import vitestConfig from "./vitest.config.base.unit.js";
export default mergeConfig(
vitestConfig,

View File

@@ -0,0 +1,25 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "./vitest.config.base.unit.js";
export default mergeConfig(
vitestConfig,
defineConfig({
test: {
coverage: {
enabled: false,
},
// There are tests which is taking over 10 minutes.
// ✓ test/spec/presets/epoch_processing.test.ts > electra/epoch_processing/rewards_and_penalties/pyspec_tests > electra/epoch_processing/rewards_and_penalties/pyspec_tests/full_attestations_one_validaor_one_gwei 572377ms
// So I have to increase these values to such extreme
testTimeout: 1000 * 60 * 15,
hookTimeout: 1000 * 60 * 15,
passWithNoTests: true,
pool: "threads",
poolOptions: {
threads: {
isolate: false,
},
},
},
})
);

View File

@@ -17,35 +17,18 @@ export default defineConfig({
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*",
],
setupFiles: [
path.join(__dirname, "./scripts/vitest/setupFiles/customMatchers.ts"),
path.join(__dirname, "./scripts/vitest/setupFiles/dotenv.ts"),
path.join(__dirname, "../scripts/vitest/setupFiles/customMatchers.ts"),
path.join(__dirname, "../scripts/vitest/setupFiles/dotenv.ts"),
],
reporters: process.env.GITHUB_ACTIONS
? ["verbose", "hanging-process", "github-actions"]
: [process.env.TEST_COMPACT_OUTPUT ? "basic" : "verbose", "hanging-process"],
coverage: {
enabled: process.env.CI === "true",
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/**",
],
enabled: false,
},
diff: process.env.TEST_COMPACT_DIFF ? path.join(import.meta.dirname, "./scripts/vitest/vitest.diff.ts") : undefined,
diff: process.env.TEST_COMPACT_DIFF
? path.join(import.meta.dirname, "../scripts/vitest/vitest.diff.ts")
: undefined,
onConsoleLog: () => !process.env.TEST_QUIET_CONSOLE,
},
});

View File

@@ -0,0 +1,39 @@
import path from "node:path";
import {defineConfig, mergeConfig} from "vitest/config";
const __dirname = new URL(".", import.meta.url).pathname;
import sharedConfig from "./vitest.config.base.js";
export default mergeConfig(
sharedConfig,
defineConfig({
test: {
coverage: {
enabled: process.env.CI === "true",
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/**",
],
},
// There are some tests which are taking huge time
// test/unit/chain/rewards/blockRewards.test.ts > chain / rewards / blockRewards > Normal case 73869ms
// for now I tried to identify such tests an increase the limit a bit higher
testTimeout: 20_000,
hookTimeout: 20_000,
},
})
);

View File

@@ -29,16 +29,11 @@
"docs:lint:fix": "prettier '**/*.md' --write",
"test": "lerna run test --concurrency 1",
"test:unit": "lerna run test:unit --concurrency 1",
"test:browsers": "lerna run test:browsers",
"test:browsers": "lerna run test:browsers --concurrency 1",
"test:e2e": "lerna run test:e2e --concurrency 1",
"test:e2e:sim": "lerna run test:e2e:sim",
"download-spec-tests": "lerna run download-spec-tests",
"test:spec": "lerna run test:spec",
"test-coverage:unit": "c8 --config .c8rc.json --report-dir coverage/unit/ --all npm run test:unit",
"test-coverage:browsers": "c8 --config .c8rc.json --report-dir coverage/browsers/ --all npm run test:browsers",
"test-coverage:e2e": "c8 --config .c8rc.json --report-dir coverage/e2e/ --all npm run test:e2e",
"test-coverage:e2e-sim": "c8 --config .c8rc.json --report-dir coverage/e2e-sim/ --all npm run test:e2e:sim",
"test-coverage:spec": "c8 --config .c8rc.json --report-dir coverage/spec/ --all npm run test:spec",
"benchmark": "yarn benchmark:files 'packages/*/test/perf/**/*.test.ts'",
"benchmark:files": "NODE_OPTIONS='--max-old-space-size=4096 --loader=ts-node/esm' benchmark --config .benchrc.yaml --defaultBranch unstable",
"release:create-rc": "node scripts/release/create_rc.mjs",
@@ -51,8 +46,8 @@
"@chainsafe/benchmark": "^1.2.3",
"@biomejs/biome": "^1.9.3",
"@types/node": "^20.12.8",
"@vitest/browser": "^2.0.4",
"@vitest/coverage-v8": "^2.0.4",
"@vitest/browser": "^3.0.6",
"@vitest/coverage-v8": "^3.0.6",
"crypto-browserify": "^3.12.0",
"dotenv": "^16.4.5",
"electron": "^26.2.2",
@@ -72,20 +67,18 @@
"ts-node": "^10.9.2",
"typescript": "^5.7.3",
"typescript-docs-verifier": "^2.5.3",
"vite": "^5.3.4",
"vite-plugin-dts": "^3.9.1",
"vite-plugin-node-polyfills": "^0.22.0",
"vite-plugin-top-level-await": "^1.4.2",
"vitest": "^2.0.4",
"vitest-when": "^0.4.1",
"vite": "^6.0.11",
"vite-plugin-dts": "^4.5.0",
"vite-plugin-node-polyfills": "^0.23.0",
"vite-plugin-top-level-await": "^1.5.0",
"vitest": "^3.0.6",
"vitest-when": "^0.6.0",
"wait-port": "^1.1.0",
"webdriverio": "^8.36.1"
"webdriverio": "^9.7.2"
},
"resolutions": {
"@puppeteer/browsers": "^2.1.0",
"dns-over-http-resolver": "^2.1.1",
"loupe": "^2.3.6",
"vite": "^5.3.4",
"testcontainers/**/nan": "^2.19.0"
}
}

View File

@@ -66,7 +66,7 @@
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit",
"test:unit": "vitest --run --dir test/unit/",
"test:unit": "vitest run --dir test/unit/",
"check-readme": "typescript-docs-verifier"
},
"dependencies": {

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -78,18 +78,18 @@
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit && yarn test:e2e",
"test:unit:minimal": "LODESTAR_PRESET=minimal vitest --run --dir test/unit/",
"test:unit:mainnet": "LODESTAR_PRESET=mainnet vitest --run --dir test/unit-mainnet",
"test:unit:minimal": "LODESTAR_PRESET=minimal vitest run --dir test/unit/",
"test:unit:mainnet": "LODESTAR_PRESET=mainnet vitest run --dir test/unit-mainnet",
"test:unit": "wrapper() { yarn test:unit:minimal $@ && yarn test:unit:mainnet $@; }; wrapper",
"test:e2e": "LODESTAR_PRESET=minimal vitest --run --config vitest.e2e.config.ts --dir test/e2e",
"test:sim": "vitest --run test/sim/**/*.test.ts",
"test:sim:mergemock": "vitest --run test/sim/mergemock.test.ts",
"test:sim:blobs": "vitest --run test/sim/4844-interop.test.ts",
"test:e2e": "LODESTAR_PRESET=minimal vitest run --config vitest.e2e.config.ts --dir test/e2e",
"test:sim": "vitest run test/sim/**/*.test.ts",
"test:sim:mergemock": "vitest run test/sim/mergemock.test.ts",
"test:sim:blobs": "vitest run test/sim/4844-interop.test.ts",
"download-spec-tests": "node --loader=ts-node/esm test/spec/downloadTests.ts",
"test:spec:bls": "vitest --run --config vitest.spec.config.ts --dir test/spec/bls/",
"test:spec:general": "vitest --run --config vitest.spec.config.ts --dir test/spec/general/",
"test:spec:minimal": "LODESTAR_PRESET=minimal vitest --run --config vitest.spec.config.ts --dir test/spec/presets/",
"test:spec:mainnet": "LODESTAR_PRESET=mainnet vitest --run --config vitest.spec.config.ts --dir test/spec/presets/",
"test:spec:bls": "vitest run --config vitest.spec.config.ts --dir test/spec/bls/",
"test:spec:general": "vitest run --config vitest.spec.config.ts --dir test/spec/general/",
"test:spec:minimal": "LODESTAR_PRESET=minimal vitest run --config vitest.spec.config.ts --dir test/spec/presets/",
"test:spec:mainnet": "LODESTAR_PRESET=mainnet vitest run --config vitest.spec.config.ts --dir test/spec/presets/",
"test:spec": "yarn test:spec:bls && yarn test:spec:general && yarn test:spec:minimal && yarn test:spec:mainnet",
"check-readme": "typescript-docs-verifier"
},

View File

@@ -12,5 +12,5 @@ docker pull ethereum/client-go:latest
```bash
cd packages/lodestar
EL_BINARY_DIR=ethereum/client-go:latest EL_SCRIPT_DIR=gethdocker ETH_PORT=8545 ENGINE_PORT=8551 TX_SCENARIOS=simple yarn vitest --run test/sim/merge-interop.test.ts
EL_BINARY_DIR=ethereum/client-go:latest EL_SCRIPT_DIR=gethdocker ETH_PORT=8545 ENGINE_PORT=8551 TX_SCENARIOS=simple yarn vitest run test/sim/merge-interop.test.ts
```

View File

@@ -28,7 +28,7 @@ import {logFilesDir} from "./params.js";
import {shell} from "./shell.js";
// NOTE: How to run
// DEV_RUN=true EL_BINARY_DIR=ethpandaops/ethereumjs:master-0e06ddf EL_SCRIPT_DIR=ethereumjsdocker yarn vitest --run test/sim/electra-interop.test.ts
// DEV_RUN=true EL_BINARY_DIR=ethpandaops/ethereumjs:master-0e06ddf EL_SCRIPT_DIR=ethereumjsdocker yarn vitest run test/sim/electra-interop.test.ts
// ```
/* eslint-disable no-console, @typescript-eslint/naming-convention */

View File

@@ -22,7 +22,7 @@ import {logFilesDir} from "./params.js";
import {shell} from "./shell.js";
// NOTE: How to run
// EL_BINARY_DIR=g11tech/mergemock:latest EL_SCRIPT_DIR=mergemock LODESTAR_PRESET=mainnet ETH_PORT=8661 ENGINE_PORT=8551 yarn vitest --run test/sim/mergemock.test.ts
// EL_BINARY_DIR=g11tech/mergemock:latest EL_SCRIPT_DIR=mergemock LODESTAR_PRESET=mainnet ETH_PORT=8661 ENGINE_PORT=8551 yarn vitest run test/sim/mergemock.test.ts
// ```
/* eslint-disable no-console, @typescript-eslint/naming-convention */

View File

@@ -16,8 +16,7 @@ export function expectEqualBeaconState(
const stateType = ssz[fork].BeaconState as SSZTypesFor<ForkAll, "BeaconState">;
if (!stateType.equals(actual, expected)) {
expect(stateType.toJson(actual)).to.deep.equal(stateType.toJson(expected));
throw Error("Wrong state");
expect(stateType.toJson(actual)).toEqualWithMessage(stateType.toJson(expected), "Wrong state");
}
}

View File

@@ -103,7 +103,7 @@ export function runValidSszTest(type: Type<unknown>, testData: ValidTestCaseData
// To print a tree a single test you are debugging do
//
// $ RENDER_TREE=true ONLY_ID="4 arrays" ../../node_modules/.bin/vitest --run test/unit/byType/vector/valid.test.ts
// $ RENDER_TREE=true ONLY_ID="4 arrays" ../../node_modules/.bin/vitest run test/unit/byType/vector/valid.test.ts
//
// '1000' => '0x0000000000000000000000000000000000000000000000000000000000000000',
// '1001' => '0x0000000000000000000000000000000000000000000000000000000000000000',

View File

@@ -6,7 +6,7 @@ import {
stateTransition,
} from "@lodestar/state-transition";
import {ssz} from "@lodestar/types";
import {describe, expect, it} from "vitest";
import {describe, expect, it, vi} from "vitest";
import {BlockAltairOpts, getBlockAltair} from "../../../../../state-transition/test/perf/block/util.js";
import {
cachedStateAltairPopulateCaches,
@@ -15,9 +15,10 @@ import {
import {computeBlockRewards} from "../../../../src/chain/rewards/blockRewards.js";
describe("chain / rewards / blockRewards", () => {
const testCases: {id: string; opts: BlockAltairOpts}[] = [
const testCases: {id: string; timeout?: number; opts: BlockAltairOpts}[] = [
{
id: "Normal case",
timeout: 90_000,
opts: {
proposerSlashingLen: 1,
attesterSlashingLen: 2,
@@ -78,7 +79,11 @@ describe("chain / rewards / blockRewards", () => {
},
];
for (const {id, opts} of testCases) {
for (const {id, timeout, opts} of testCases) {
if (timeout) {
vi.setConfig({testTimeout: timeout, hookTimeout: timeout});
}
it(`${id}`, async () => {
const state = generatePerfTestCachedStateAltair();
const block = getBlockAltair(state, opts);

View File

@@ -1,6 +1,6 @@
import {defineConfig, mergeConfig} from "vitest/config";
import {buildTargetPlugin} from "../../scripts/vite/plugins/buildTargetPlugin.js";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit.js";
export default mergeConfig(
vitestConfig,

View File

@@ -1,6 +1,6 @@
import {defineConfig, mergeConfig} from "vitest/config";
import {buildTargetPlugin} from "../../scripts/vite/plugins/buildTargetPlugin";
import vitestConfig from "../../vitest.base.e2e.config";
import vitestConfig from "../../configs/vitest.config.base.e2e";
export default mergeConfig(
vitestConfig,

View File

@@ -1,6 +1,6 @@
import {defineConfig, mergeConfig} from "vitest/config";
import {buildTargetPlugin} from "../../scripts/vite/plugins/buildTargetPlugin";
import vitestConfig from "../../vitest.base.spec.config";
import vitestConfig from "../../configs/vitest.config.base.spec";
export default mergeConfig(
vitestConfig,

View File

@@ -30,8 +30,8 @@
"docs:build": "node --loader ts-node/esm ./docsgen/index.ts",
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test:unit": "vitest --run --dir test/unit/",
"test:e2e": "vitest --run --config vitest.e2e.config.ts --dir test/e2e/",
"test:unit": "vitest run --dir test/unit/",
"test:e2e": "vitest run --config vitest.e2e.config.ts --dir test/e2e/",
"test:sim:multifork": "LODESTAR_PRESET=minimal DOTENV_CONFIG_PATH=../../.env.test node -r dotenv/config --loader ts-node/esm test/sim/multiFork.test.ts",
"test:sim:mixedclient": "LODESTAR_PRESET=minimal DOTENV_CONFIG_PATH=../../.env.test node -r dotenv/config --loader ts-node/esm test/sim/mixedClient.test.ts",
"test:sim:endpoints": "LODESTAR_PRESET=minimal DOTENV_CONFIG_PATH=../../.env.test node -r dotenv/config --loader ts-node/esm test/sim/endpoints.test.ts",

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.e2e.config";
import vitestConfig from "../../configs/vitest.config.base.e2e";
export default mergeConfig(
vitestConfig,

View File

@@ -50,7 +50,7 @@
"lint": "biome check src/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit",
"test:unit": "yarn vitest --run --dir test/unit/",
"test:unit": "yarn vitest run --dir test/unit/",
"check-readme": "typescript-docs-verifier"
},
"repository": {

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -31,7 +31,7 @@
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit",
"test:unit": "vitest --run --dir test/unit/",
"test:unit": "vitest run --dir test/unit/",
"check-readme": "typescript-docs-verifier"
},
"dependencies": {

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -44,7 +44,7 @@
"lint": "biome check src/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit",
"test:unit": "vitest --run --dir test/unit/",
"test:unit": "vitest run --dir test/unit/",
"check-readme": "typescript-docs-verifier"
},
"repository": {

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -32,7 +32,7 @@
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit",
"test:unit": "vitest --run --dir test/unit/",
"test:unit": "vitest run --dir test/unit/",
"check-readme": "typescript-docs-verifier"
},
"dependencies": {

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -65,11 +65,8 @@
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit",
"test:unit": "vitest --run --dir test/unit/",
"test:browsers": "yarn test:browsers:chrome && yarn test:browsers:firefox && yarn test:browsers:electron",
"test:browsers:chrome": "yarn run build:bundle && vitest --run --browser chrome --config ./vitest.browser.config.ts --dir test/unit",
"test:browsers:firefox": "yarn run build:bundle && vitest --run --browser firefox --config ./vitest.browser.config.ts --dir test/unit",
"test:browsers:electron": "echo 'Electron tests will be introduced back in the future as soon vitest supports electron.'",
"test:unit": "vitest run --dir test/unit/",
"test:browsers": "yarn run build:bundle && vitest run --config ./vitest.browser.config.ts --dir test/unit",
"check-readme": "typescript-docs-verifier"
},
"dependencies": {

View File

@@ -24,7 +24,7 @@ function getSyncCommittee(
describe("syncInMemory", () => {
// In browser test this process is taking more time than default 2000ms
vi.setConfig({testTimeout: 10000});
vi.setConfig({testTimeout: 20000, hookTimeout: 20000});
// Fixed params
const genValiRoot = Buffer.alloc(32, 9);

View File

@@ -2,7 +2,7 @@ import path from "node:path";
import fs from "node:fs";
import {defineConfig, mergeConfig} from "vite";
import dts from "vite-plugin-dts";
import {getBaseViteConfig} from "../../vite.base.config.js";
import {getBaseViteConfig} from "../../configs/vite.config.base.js";
import pkgJSON from "./package.json";

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.browser.config";
import vitestConfig from "../../configs/vitest.config.base.browser";
export default mergeConfig(
vitestConfig,

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -56,12 +56,9 @@
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit && yarn test:e2e",
"test:unit": "vitest --run --dir test/unit/",
"test:browsers": "yarn test:browsers:chrome && yarn test:browsers:firefox && yarn test:browsers:electron",
"test:browsers:chrome": "vitest --run --browser chrome --config ./vitest.browser.config.ts --dir test/unit",
"test:browsers:firefox": "vitest --run --browser firefox --config ./vitest.browser.config.ts --dir test/unit",
"test:browsers:electron": "echo 'Electron tests will be introduced back in the future as soon vitest supports electron.'",
"test:e2e": "vitest --run --config vitest.e2e.config.ts --dir test/e2e",
"test:unit": "vitest run --dir test/unit/",
"test:browsers": "vitest run --config ./vitest.browser.config.ts --dir test/unit",
"test:e2e": "vitest run --config vitest.e2e.config.ts --dir test/e2e",
"check-readme": "typescript-docs-verifier"
},
"types": "lib/index.d.ts",

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.browser.config";
import vitestConfig from "../../configs/vitest.config.base.browser";
export default mergeConfig(
vitestConfig,

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.e2e.config";
import vitestConfig from "../../configs/vitest.config.base.e2e";
export default mergeConfig(
vitestConfig,

View File

@@ -53,12 +53,9 @@
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit",
"test:unit": "vitest --run --dir test/unit/",
"test:browsers": "yarn test:browsers:chrome && yarn test:browsers:firefox && yarn test:browsers:electron",
"test:browsers:chrome": "vitest --run --browser chrome --config ./vitest.browser.config.ts --dir test/unit",
"test:browsers:firefox": "vitest --run --browser firefox --config ./vitest.browser.config.ts --dir test/unit",
"test:browsers:electron": "echo 'Electron tests will be introduced back in the future as soon vitest supports electron.'",
"test:e2e": "vitest --run --config vitest.e2e.config.ts --dir test/e2e/",
"test:unit": "vitest run --dir test/unit/",
"test:browsers": "vitest run --config ./vitest.browser.config.ts --dir test/unit",
"test:e2e": "vitest run --config vitest.e2e.config.ts --dir test/e2e/",
"check-readme": "typescript-docs-verifier"
},
"repository": {

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.browser.config";
import vitestConfig from "../../configs/vitest.config.base.browser";
export default mergeConfig(
vitestConfig,

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.e2e.config";
import vitestConfig from "../../configs/vitest.config.base.e2e";
export default mergeConfig(
vitestConfig,

View File

@@ -51,12 +51,9 @@
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit && yarn test:e2e",
"test:unit": "vitest --run --dir test/unit/",
"test:browsers": "yarn test:browsers:chrome && yarn test:browsers:firefox && yarn test:browsers:electron",
"test:browsers:chrome": "vitest --run --browser chrome --config ./vitest.browser.config.ts --dir test/unit",
"test:browsers:firefox": "vitest --run --browser firefox --config ./vitest.browser.config.ts --dir test/unit",
"test:browsers:electron": "echo 'Electron tests will be introduced back in the future as soon vitest supports electron.'",
"test:e2e": "LODESTAR_PRESET=minimal vitest --run --config vitest.e2e.config.ts --dir test/e2e",
"test:unit": "vitest run --dir test/unit/",
"test:browsers": "vitest run --config ./vitest.browser.config.ts --dir test/unit",
"test:e2e": "LODESTAR_PRESET=minimal vitest run --config vitest.e2e.config.ts --dir test/e2e",
"check-readme": "typescript-docs-verifier",
"generate-fixtures": "node --loader ts-node/esm scripts/generate_fixtures.ts"
},

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.browser.config";
import vitestConfig from "../../configs/vitest.config.base.browser";
export default mergeConfig(
vitestConfig,

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.e2e.config";
import vitestConfig from "../../configs/vitest.config.base.e2e";
export default mergeConfig(
vitestConfig,

View File

@@ -48,7 +48,7 @@
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit",
"test:unit": "vitest --run --dir test/unit/",
"test:unit": "vitest run --dir test/unit/",
"check-readme": "typescript-docs-verifier"
},
"dependencies": {

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -47,8 +47,8 @@
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit && yarn test:e2e",
"test:unit": "vitest --run --passWithNoTests --dir test/unit/",
"test:e2e": "vitest --run --config vitest.e2e.config.ts --dir test/e2e/",
"test:unit": "vitest run --passWithNoTests --dir test/unit/",
"test:e2e": "vitest run --config vitest.e2e.config.ts --dir test/e2e/",
"check-readme": "typescript-docs-verifier"
},
"repository": {
@@ -67,12 +67,12 @@
"rimraf": "^4.4.1",
"snappyjs": "^0.7.0",
"tar": "^6.1.13",
"vitest": "^2.0.4"
"vitest": "^3.0.6"
},
"devDependencies": {
"@types/tar": "^6.1.4"
},
"peerDependencies": {
"vitest": "^2.0.4"
"vitest": "^3.0.6"
}
}

View File

@@ -88,7 +88,7 @@ const defaultOptions: SpecTestOptions<any, any> = {
shouldError: () => false,
shouldSkip: () => false,
expectFunc: (_testCase, expected, actual) => expect(actual).toEqual(expected),
timeout: 10 * 60 * 1000,
timeout: 1000 * 60 * 15,
};
export function describeDirectorySpecTest<TestCase extends {meta?: any}, Result>(
@@ -103,8 +103,8 @@ export function describeDirectorySpecTest<TestCase extends {meta?: any}, Result>
}
describe(name, () => {
if (options.timeout !== undefined) {
vi.setConfig({testTimeout: options.timeout ?? 10 * 60 * 1000});
if (options.timeout) {
vi.setConfig({testTimeout: options.timeout, hookTimeout: options.timeout});
}
for (const testSubDirname of fs.readdirSync(testCaseDirectoryPath)) {

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.e2e.config";
import vitestConfig from "../../configs/vitest.config.base.e2e";
export default mergeConfig(
vitestConfig,

View File

@@ -53,7 +53,7 @@
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit",
"test:unit": "vitest --run --dir test/unit/",
"test:unit": "vitest run --dir test/unit/",
"check-readme": "typescript-docs-verifier"
},
"types": "lib/index.d.ts",

View File

@@ -4,13 +4,15 @@ import {createBeaconConfig, createChainForkConfig} from "@lodestar/config";
import {config as defaultConfig} from "@lodestar/config/default";
import {ssz} from "@lodestar/types";
import {toHexString} from "@lodestar/utils";
import {describe, expect, it} from "vitest";
import {describe, expect, it, vi} from "vitest";
import {createCachedBeaconState, loadCachedBeaconState} from "../../src/cache/stateCache.js";
import {modifyStateSameValidator, newStateWithValidators} from "../utils/capella.js";
import {interopPubkeysCached} from "../utils/interop.js";
import {createCachedBeaconStateTest} from "../utils/state.js";
describe("CachedBeaconState", () => {
vi.setConfig({testTimeout: 20_000, hookTimeout: 20_000});
it("Clone and mutate", () => {
const stateView = ssz.altair.BeaconState.defaultViewDU();
const state1 = createCachedBeaconStateTest(stateView);
@@ -78,6 +80,8 @@ describe("CachedBeaconState", () => {
});
describe("loadCachedBeaconState", () => {
vi.setConfig({testTimeout: 25_000, hookTimeout: 25_000});
const numValidator = 16;
const pubkeys = interopPubkeysCached(2 * numValidator);

View File

@@ -17,10 +17,10 @@ describe("getBlockRoot", () => {
});
it("should fail if slot is current slot", () => {
const state = generateState({slot: GENESIS_SLOT});
expect(() => getBlockRoot(state, GENESIS_SLOT)).toThrow("");
expect(() => getBlockRoot(state, GENESIS_SLOT)).toThrow();
});
it("should fail if slot is not within SLOTS_PER_HISTORICAL_ROOT of current slot", () => {
const state = generateState({slot: GENESIS_SLOT + SLOTS_PER_HISTORICAL_ROOT + 1});
expect(() => getBlockRoot(state, GENESIS_SLOT)).toThrow("");
expect(() => getBlockRoot(state, GENESIS_SLOT)).toThrow();
});
});

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -64,12 +64,12 @@
"axios": "^1.3.4",
"testcontainers": "^10.2.1",
"tmp": "^0.2.1",
"vitest": "^2.0.4"
"vitest": "^3.0.6"
},
"devDependencies": {
"@types/yargs": "^17.0.24"
},
"peerDependencies": {
"vitest": "^2.0.4"
"vitest": "^3.0.6"
}
}

View File

@@ -62,13 +62,10 @@
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test": "yarn test:unit",
"test:constants:minimal": "LODESTAR_PRESET=minimal vitest --run --dir test/constants/",
"test:constants:mainnet": "LODESTAR_PRESET=mainnet vitest --run --dir test/constants/",
"test:unit": "wrapper() { yarn test:constants:minimal $@ && yarn test:constants:mainnet $@ && LODESTAR_PRESET=mainnet vitest --run --dir test/unit/ $@; }; wrapper",
"test:browsers": "yarn test:browsers:chrome && yarn test:browsers:firefox && yarn test:browsers:electron",
"test:browsers:chrome": "vitest --run --browser chrome --config ./vitest.browser.config.ts --dir test/unit",
"test:browsers:firefox": "vitest --run --browser firefox --config ./vitest.browser.config.ts --dir test/unit",
"test:browsers:electron": "echo 'Electron tests will be introduced back in the future as soon vitest supports electron.'",
"test:constants:minimal": "LODESTAR_PRESET=minimal vitest run --dir test/constants/",
"test:constants:mainnet": "LODESTAR_PRESET=mainnet vitest run --dir test/constants/",
"test:unit": "wrapper() { yarn test:constants:minimal $@ && yarn test:constants:mainnet $@ && LODESTAR_PRESET=mainnet vitest run --dir test/unit/ $@; }; wrapper",
"test:browsers": "vitest run --config ./vitest.browser.config.ts --dir test/unit",
"check-readme": "typescript-docs-verifier"
},
"types": "lib/index.d.ts",

View File

@@ -1,14 +1,11 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.browser.config";
import vitestConfig from "../../configs/vitest.config.base.browser";
export default mergeConfig(
vitestConfig,
defineConfig({
test: {
globalSetup: ["./test/globalSetup.ts"],
},
optimizeDeps: {
exclude: ["@chainsafe/blst"],
},
}
})
);

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -27,14 +27,11 @@
"build:watch": "yarn run build --watch",
"build:release": "yarn clean && yarn build",
"check-build": "node -e \"(async function() { await import('./lib/index.js') })()\"",
"check-types": "tsc && vitest --run --typecheck --dir test/types/",
"check-types": "tsc && vitest run --typecheck --dir test/types/",
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test:unit": "vitest --run --dir test/unit",
"test:browsers": "yarn test:browsers:chrome && yarn test:browsers:firefox && yarn test:browsers:electron",
"test:browsers:chrome": "vitest --run --browser chrome --config ./vitest.browser.config.ts --dir test/unit",
"test:browsers:firefox": "vitest --run --browser firefox --config ./vitest.browser.config.ts --dir test/unit",
"test:browsers:electron": "echo 'Electron tests will be introduced back in the future as soon vitest supports electron.'",
"test:unit": "vitest run --dir test/unit",
"test:browsers": "vitest run --config ./vitest.browser.config.ts --dir test/unit",
"check-readme": "typescript-docs-verifier"
},
"types": "lib/index.d.ts",

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.browser.config";
import vitestConfig from "../../configs/vitest.config.base.browser";
export default mergeConfig(
vitestConfig,

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -27,10 +27,10 @@
"check-types": "tsc",
"lint": "biome check src/ test/",
"lint:fix": "yarn run lint --write",
"test:unit": "vitest --run --dir test/unit/",
"test:unit": "vitest run --dir test/unit/",
"test": "yarn test:unit && yarn test:e2e",
"test:spec": "vitest --run --config vitest.spec.config.ts --dir test/spec/",
"test:e2e": "vitest --run --config vitest.e2e.config.ts --dir test/e2e",
"test:spec": "vitest run --config vitest.spec.config.ts --dir test/spec/",
"test:e2e": "vitest run --config vitest.e2e.config.ts --dir test/e2e",
"download-spec-tests": "node --loader=ts-node/esm test/spec/downloadTests.ts",
"check-readme": "typescript-docs-verifier"
},

View File

@@ -80,6 +80,7 @@ describe("ValidatorStore", () => {
[valRegF10G200, "0x10", 200],
];
for (const [valReg, feeRecipient, gasLimit] of testCases) {
vi.clearAllMocks();
vi.spyOn(validatorStore, "signValidatorRegistration").mockResolvedValue(valReg);
const val1 = await validatorStore.getValidatorRegistration(pubkeys[0], {feeRecipient, gasLimit}, slot++);

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,

View File

@@ -1,5 +1,5 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.e2e.config";
import vitestConfig from "../../configs/vitest.config.base.e2e";
export default mergeConfig(
vitestConfig,

View File

@@ -1,12 +1,11 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "../../vitest.base.unit.config";
import vitestConfig from "../../configs/vitest.config.base.unit";
export default mergeConfig(
vitestConfig,
defineConfig({
test: {
globalSetup: ["./test/globalSetup.ts"],
testTimeout: 60_000,
passWithNoTests: true,
pool: "threads",
poolOptions: {

View File

@@ -1,14 +1,30 @@
#!/bin/bash
# run yarn install --check-files, capturing stderr
# Now modern packages support multiple runtimes
# while the Yarn 1 shows warnings for engines other than node
IGNORE_WARNINGS=(
'engine "deno" appears to be invalid'
'engine "bun" appears to be invalid'
'engine "bare" appears to be invalid'
)
# Run yarn install --check-files and capture output
OUTPUT=$(yarn install --check-files 2>&1)
echo "$OUTPUT"
echo $OUTPUT
# Build grep filter arguments dynamically
FILTER_ARGS=()
for pattern in "${IGNORE_WARNINGS[@]}"; do
FILTER_ARGS+=(-e "$pattern")
done
# grep the output for 'warning'
if echo "$OUTPUT" | grep -qi 'warning'; then
echo "There were warnings in yarn install --check-files"
# Filter out specified warnings
FILTERED_OUTPUT=$(echo "$OUTPUT" | grep -viF "${FILTER_ARGS[@]}")
# Check for remaining warnings
if echo "$FILTERED_OUTPUT" | grep -qi 'warning'; then
echo "There were unexpected warnings in yarn install --check-files"
exit 1
else
echo "No warnings in yarn install --check-files"
echo "No unexpected warnings in yarn install --check-files"
fi

View File

@@ -24,9 +24,8 @@
"declarationMap": true,
"incremental": true,
"preserveWatchOutput": true,
// Enable it when upgrade `vite-plugin-dts`
// "noUncheckedSideEffectImports": true,
// "noCheck": true,
"noUncheckedSideEffectImports": true,
"noCheck": true,
// TODO: Investigate following errors:
// - Cannot find module 'rollup/parseAst' or its corresponding type declarations

View File

@@ -1,64 +0,0 @@
import path from "node:path";
import {defineConfig} from "vitest/config";
const __dirname = new URL(".", import.meta.url).pathname;
import {nodePolyfills} from "vite-plugin-node-polyfills";
import topLevelAwait from "vite-plugin-top-level-await";
import {blsBrowserPlugin} from "./scripts/vite/plugins/blsBrowserPlugin.js";
export default defineConfig({
plugins: [
topLevelAwait(),
blsBrowserPlugin(),
nodePolyfills({
include: ["buffer", "process", "util", "string_decoder", "url", "querystring", "events"],
globals: {Buffer: true, process: true},
protocolImports: true,
}),
// TODO: Should be removed when the vite issue is fixed
// https://github.com/vitest-dev/vitest/issues/6203#issuecomment-2245836028
{
name: "defineArgv",
config() {
return {
define: {
"process.argv": "[]",
"process.nextTick": "function noop(){}",
},
};
},
},
],
test: {
include: ["**/*.test.ts"],
exclude: [
"**/*.node.test.ts",
"**/node_modules/**",
"**/dist/**",
"**/lib/**",
"**/cypress/**",
"**/.{idea,git,cache,output,temp}/**",
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*",
],
setupFiles: [path.join(__dirname, "./scripts/vitest/setupFiles/customMatchers.ts")],
reporters: ["default", "hanging-process"],
coverage: {
enabled: false,
},
browser: {
name: "chrome",
headless: true,
provider: "webdriverio",
screenshotFailures: false,
providerOptions: {
capabilities: {
browserVersion: "stable",
},
},
},
},
resolve: {
alias: {
"node:perf_hooks": path.join(__dirname, "scripts/vitest/polyfills/perf_hooks.js"),
},
},
});

View File

@@ -1,22 +0,0 @@
import {defineConfig, mergeConfig} from "vitest/config";
import vitestConfig from "./vitest.base.unit.config.js";
export default mergeConfig(
vitestConfig,
defineConfig({
test: {
coverage: {
enabled: false,
},
testTimeout: 60_000,
hookTimeout: 60_000,
passWithNoTests: true,
pool: "threads",
poolOptions: {
threads: {
isolate: false,
},
},
},
})
);

2587
yarn.lock

File diff suppressed because it is too large Load Diff