Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: allow compact diff for test failures #6783

Merged
merged 6 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/pages/contribution/testing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Testing is critical to the Lodestar project and there are many types of tests that are run to build a product that is both effective AND efficient. This page will help to break down the different types of tests you will find in the Lodestar repo.

There are few flags you can set through env variables to override behavior of testing and it's output.

| ENV variable | Effect | Impact |
| ----------------- | ------ | ----------------------------------------------------------------------------------------------------------- |
| TEST_COMPACT_DIFF | All | Will strip down the object difference rendered during test failures. Very useful for large object matching. |

### Unit Tests

This is the most fundamental type of test in most code bases. In all instances mocks, stubs and other forms of isolation are used to test code on a functional, unit level. See the [Unit Tests](./unit-tests.md) page for more information.
Expand Down
9 changes: 9 additions & 0 deletions scripts/vitest/vitest.diff.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type {DiffOptions} from "vitest";

export default {
aIndicator: "--",
bIndicator: "++",
includeChangeCounts: true,
contextLines: 2,
expand: false,
} satisfies DiffOptions;
1 change: 1 addition & 0 deletions vitest.base.unit.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ export default defineConfig({
"**/node_modules/**",
],
},
diff: process.env.TEST_COMPACT_DIFF ? path.join(import.meta.dirname, "./scripts/vitest/vitest.diff.ts") : undefined,
},
});
Loading