mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 01:26:44 +00:00
docs: Document how to generate and visualize test coverage locally (no-changelog) (#15385)
This commit is contained in:
committed by
GitHub
parent
1e92729492
commit
c09b67b232
1
.vscode/extensions.json
vendored
1
.vscode/extensions.json
vendored
@@ -7,6 +7,7 @@
|
|||||||
"EditorConfig.EditorConfig",
|
"EditorConfig.EditorConfig",
|
||||||
"esbenp.prettier-vscode",
|
"esbenp.prettier-vscode",
|
||||||
"mjmlio.vscode-mjml",
|
"mjmlio.vscode-mjml",
|
||||||
|
"ryanluker.vscode-coverage-gutters",
|
||||||
"Vue.volar",
|
"Vue.volar",
|
||||||
"vitest.explorer"
|
"vitest.explorer"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -19,9 +19,14 @@ Great that you are here and you want to contribute to n8n
|
|||||||
- [Actual n8n setup](#actual-n8n-setup)
|
- [Actual n8n setup](#actual-n8n-setup)
|
||||||
- [Start](#start)
|
- [Start](#start)
|
||||||
- [Development cycle](#development-cycle)
|
- [Development cycle](#development-cycle)
|
||||||
- [Community PR Guidelines](#community-pr-guidelines)
|
- [Community PR Guidelines](#community-pr-guidelines)
|
||||||
|
- [**1. Change Request/Comment**](#1-change-requestcomment)
|
||||||
|
- [**2. General Requirements**](#2-general-requirements)
|
||||||
|
- [**3. PR Specific Requirements**](#3-pr-specific-requirements)
|
||||||
|
- [**4. Workflow Summary for Non-Compliant PRs**](#4-workflow-summary-for-non-compliant-prs)
|
||||||
- [Test suite](#test-suite)
|
- [Test suite](#test-suite)
|
||||||
- [Unit tests](#unit-tests)
|
- [Unit tests](#unit-tests)
|
||||||
|
- [Code Coverage](#code-coverage)
|
||||||
- [E2E tests](#e2e-tests)
|
- [E2E tests](#e2e-tests)
|
||||||
- [Releasing](#releasing)
|
- [Releasing](#releasing)
|
||||||
- [Create custom nodes](#create-custom-nodes)
|
- [Create custom nodes](#create-custom-nodes)
|
||||||
@@ -253,6 +258,10 @@ tests of all packages.
|
|||||||
|
|
||||||
If you made a change which requires an update on a `.test.ts.snap` file, pass `-u` to the command to run tests or press `u` in watch mode.
|
If you made a change which requires an update on a `.test.ts.snap` file, pass `-u` to the command to run tests or press `u` in watch mode.
|
||||||
|
|
||||||
|
#### Code Coverage
|
||||||
|
We track coverage for all our code on [Codecov](https://app.codecov.io/gh/n8n-io/n8n).
|
||||||
|
But when you are working on tests locally, we recommend running your tests with env variable `COVERAGE_ENABLED` set to `true`. You can then view the code coverage in the `coverage` folder, or you can use [this VSCode extension](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters) to visualize the coverage directly in VSCode.
|
||||||
|
|
||||||
#### E2E tests
|
#### E2E tests
|
||||||
|
|
||||||
⚠️ You have to run `pnpm cypress:install` to install cypress before running the tests for the first time and to update cypress.
|
⚠️ You have to run `pnpm cypress:install` to install cypress before running the tests for the first time and to update cypress.
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ const config = {
|
|||||||
setupFilesAfterEnv: ['jest-expect-message'],
|
setupFilesAfterEnv: ['jest-expect-message'],
|
||||||
collectCoverage: isCoverageEnabled,
|
collectCoverage: isCoverageEnabled,
|
||||||
coverageReporters: ['text-summary', 'lcov', 'html-spa'],
|
coverageReporters: ['text-summary', 'lcov', 'html-spa'],
|
||||||
collectCoverageFrom: ['src/**/*.ts'],
|
|
||||||
workerIdleMemoryLimit: '1MB',
|
workerIdleMemoryLimit: '1MB',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (process.env.CI === 'true') {
|
if (process.env.CI === 'true') {
|
||||||
|
config.collectCoverageFrom = ['src/**/*.ts'];
|
||||||
config.reporters = ['default', 'jest-junit'];
|
config.reporters = ['default', 'jest-junit'];
|
||||||
config.coverageReporters = ['cobertura'];
|
config.coverageReporters = ['cobertura'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,16 +11,12 @@ export const vitestConfig = defineVitestConfig({
|
|||||||
globals: true,
|
globals: true,
|
||||||
environment: 'jsdom',
|
environment: 'jsdom',
|
||||||
setupFiles: ['./src/__tests__/setup.ts'],
|
setupFiles: ['./src/__tests__/setup.ts'],
|
||||||
...(process.env.COVERAGE_ENABLED === 'true'
|
coverage: {
|
||||||
? {
|
enabled: false,
|
||||||
coverage: {
|
all: false,
|
||||||
enabled: true,
|
provider: 'v8',
|
||||||
provider: 'v8',
|
reporter: ['text-summary', 'lcov', 'html-spa'],
|
||||||
reporter: process.env.CI === 'true' ? 'cobertura' : 'text-summary',
|
},
|
||||||
all: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
css: {
|
css: {
|
||||||
modules: {
|
modules: {
|
||||||
classNameStrategy: 'non-scoped',
|
classNameStrategy: 'non-scoped',
|
||||||
@@ -28,3 +24,12 @@ export const vitestConfig = defineVitestConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (process.env.COVERAGE_ENABLED === 'true') {
|
||||||
|
const { coverage } = vitestConfig.test;
|
||||||
|
coverage.enabled = true;
|
||||||
|
if (process.env.CI === 'true') {
|
||||||
|
coverage.all = true;
|
||||||
|
coverage.reporter = ['cobertura'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user