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: split coverage e2e #872

Merged
merged 16 commits into from
Nov 19, 2024
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
- name: Install dependencies
run: npm ci
- name: E2E test affected projects
run: npx nx affected -t nxv-e2e --exclude cli-e2e --parallel=1
run: npx nx affected -t nxv-e2e --exclude cli-e2e --parallel=1 --verbose
BioPhoton marked this conversation as resolved.
Show resolved Hide resolved
- name: E2E test cli-e2e project (due to bugs in the setup it has to run last :( )
run: npx nx run cli-e2e:e2e-old

Expand Down
55 changes: 0 additions & 55 deletions e2e/cli-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import {
type AuditReport,
type PluginReport,
Expand Down Expand Up @@ -65,59 +63,6 @@ describe('CLI collect', () => {
expect(omitVariableReportData(report as Report)).toMatchSnapshot();
});

it('should run Code coverage plugin which collects passed results and creates report.json', async () => {
/**
* The stats passed in the fixture are as follows
* 3 files: one partially covered, one with no coverage, one with full coverage
* Functions: 2 + 1 + 2 found | 1 + 0 + 2 covered (60% coverage)
* Branches: 10 + 2 + 5 found | 8 + 0 + 5 covered (76% coverage)
* Lines: 10 + 5 + 10 found | 7 + 0 + 10 covered (68% coverage)
*/

const configPath = join(
fileURLToPath(dirname(import.meta.url)),
'..',
'mocks',
'fixtures',
'code-pushup.config.ts',
);

const { code, stderr } = await executeProcess({
command: 'code-pushup',
args: [
'collect',
'--no-progress',
`--config=${configPath}`,
'--persist.outputDir=tmp/e2e',
'--onlyPlugins=coverage',
],
});

expect(code).toBe(0);
expect(stderr).toBe('');

const report = await readJsonFile(join('tmp', 'e2e', 'report.json'));

expect(() => reportSchema.parse(report)).not.toThrow();
expect(omitVariableReportData(report as Report)).toMatchSnapshot();
});

it('should run Code coverage plugin that runs coverage tool and creates report.json', async () => {
const { code, stderr } = await executeProcess({
command: 'code-pushup',
args: ['collect', '--no-progress', '--onlyPlugins=coverage'],
cwd: 'examples/react-todos-app',
});

expect(code).toBe(0);
expect(stderr).toBe('');

const report = await readJsonFile('tmp/e2e/react-todos-app/report.json');

expect(() => reportSchema.parse(report)).not.toThrow();
expect(omitVariableReportData(report as Report)).toMatchSnapshot();
BioPhoton marked this conversation as resolved.
Show resolved Hide resolved
});

it('should create report.md', async () => {
const { code, stderr } = await executeProcess({
command: 'code-pushup',
Expand Down
12 changes: 12 additions & 0 deletions e2e/plugin-coverage-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*", "code-pushup.config*.ts"],
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"parserOptions": {
"project": ["e2e/plugin-coverage-e2e/tsconfig.*?.json"]
}
}
]
}
33 changes: 33 additions & 0 deletions e2e/plugin-coverage-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "plugin-coverage-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/plugin-coverage-e2e/src",
"projectType": "application",
"targets": {
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["e2e/plugin-coverage-e2e/**/*.ts"]
}
},
"nxv-e2e": {
"options": {
"environmentRoot": "static-environments/coverage-e2e-env"
}
},
"nxv-env-setup": {
"options": {
"environmentRoot": "static-environments/coverage-e2e-env"
}
},
"e2e": {
"executor": "@nx/vite:test",
"options": {
"configFile": "e2e/plugin-coverage-e2e/vite.config.e2e.ts"
}
}
},
"implicitDependencies": ["cli", "plugin-coverage", "coverage-e2e-env"],
"tags": ["scope:plugin", "type:e2e"]
}
Loading