mirror of
https://github.com/ChainSafe/lodestar.git
synced 2026-01-09 15:48:08 -05:00
Follow up to https://github.com/ChainSafe/lodestar/pull/7610 with a few restructuring suggestions, see comments below for detailed changes, revives constants tests we are no longer running in CI and makes each package executable separately again, ie. `cd packages/<package-name>` into `yarn test:unit` works for all packages again. One major change is that unit tests default should be written with `mainnet` preset in mind as I noticed that makes a lot more sense for a bunch of existing tests, eg. we have tests that depend on external fixtures, like api spec tests for events and those are not compatible with `minimal` preset. Also there doesn't seem to be much downside in most cases for unit tests to use `mainnet` preset as it does not run through all the epoch, like for example a e2e or sim test does. So overall, it allows us to use mainnet fixtures / more "real world" data which seems better with little to no downside. Time comparison running unit tests on `unstable` vs. this branch **unstable**  **nflaig/restructure-tests**  There is just a difference of 2 seconds (might be a fluke) in a 6 minute run, this seems acceptable to me considering the benefits of using `mainnet` preset noted above.
94 lines
2.6 KiB
TypeScript
94 lines
2.6 KiB
TypeScript
import path from "node:path";
|
|
import {defineConfig} from "vitest/config";
|
|
import {browserTestProject} from "./configs/vitest.config.browser.js";
|
|
import {e2eMainnetProject, e2eMinimalProject} 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, unitTestMinimalProject} from "./configs/vitest.config.unit.js";
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
workspace: [
|
|
{
|
|
extends: true,
|
|
...unitTestMinimalProject,
|
|
},
|
|
{
|
|
extends: true,
|
|
...unitTestMainnetProject,
|
|
},
|
|
{
|
|
extends: true,
|
|
...browserTestProject,
|
|
},
|
|
{
|
|
extends: true,
|
|
...e2eMinimalProject,
|
|
},
|
|
{
|
|
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/**",
|
|
],
|
|
},
|
|
},
|
|
});
|