Skip to content
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
457 changes: 349 additions & 108 deletions e2e/plugin-coverage-e2e/tests/__snapshots__/collect.e2e.test.ts.snap

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions e2e/plugin-coverage-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { cp } from 'node:fs/promises';
import path from 'node:path';
import { simpleGit } from 'simple-git';
import { afterAll, afterEach, beforeAll } from 'vitest';
import { type Report, reportSchema } from '@code-pushup/models';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
initGitRepo,
omitVariableReportData,
teardownTestFolder,
} from '@code-pushup/test-utils';
Expand All @@ -22,6 +24,8 @@ describe('PLUGIN collect report with coverage-plugin NPM package', () => {

beforeAll(async () => {
await cp(fixtureDir, testFileDir, { recursive: true });
await initGitRepo(simpleGit, { baseDir: basicDir });
await initGitRepo(simpleGit, { baseDir: existingDir });
});

afterAll(async () => {
Expand All @@ -34,24 +38,24 @@ describe('PLUGIN collect report with coverage-plugin NPM package', () => {
await teardownTestFolder(path.join(existingDir, '.code-pushup'));
});

it('should run Code coverage plugin which collects passed results and creates report.json', async () => {
it('should run Code coverage plugin which runs tests and creates report.json', async () => {
const { code } = await executeProcess({
command: 'npx',
args: ['@code-pushup/cli', 'collect', '--no-progress'],
args: ['code-pushup', 'collect', '--no-progress'],
cwd: basicDir,
});

expect(code).toBe(0);

const report = await readJsonFile(
const report = await readJsonFile<Report>(
path.join(basicDir, '.code-pushup', 'report.json'),
);

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

it('should run Code coverage plugin that runs coverage tool and creates report.json', async () => {
it('should run Code coverage plugin which parses existing lcov report and creates report.json', async () => {
const { code } = await executeProcess({
command: 'npx',
args: ['@code-pushup/cli', 'collect', '--no-progress'],
Expand All @@ -60,11 +64,11 @@ describe('PLUGIN collect report with coverage-plugin NPM package', () => {

expect(code).toBe(0);

const report = await readJsonFile(
const report = await readJsonFile<Report>(
path.join(existingDir, '.code-pushup', 'report.json'),
);

expect(() => reportSchema.parse(report)).not.toThrow();
expect(omitVariableReportData(report as Report)).toMatchSnapshot();
expect(omitVariableReportData(report)).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion e2e/plugin-coverage-e2e/vite.config.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from 'vite';
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';

export default defineConfig({
cacheDir: '../../node_modules/.vite/plugin-lighthouse-e2e',
cacheDir: '../../node_modules/.vite/plugin-coverage-e2e',
test: {
reporters: ['basic'],
testTimeout: 40_000,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,92 +1,46 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`PLUGIN collect report with jsdocs-plugin NPM package > should run JSDoc plugin for Angular example dir and create report.json 1`] = `
{
"packageName": "@code-pushup/core",
"plugins": [
{
"title": "JSDoc coverage",
"slug": "jsdocs",
"icon": "folder-docs",
"description": "Official Code PushUp JSDoc coverage plugin.",
"docsUrl": "https://www.npmjs.com/package/@code-pushup/jsdocs-plugin/",
"groups": [
{
"slug": "documentation-coverage",
"refs": [
{
"slug": "classes-coverage",
"weight": 2
},
{
"slug": "methods-coverage",
"weight": 2
},
{
"slug": "functions-coverage",
"weight": 2
},
{
"slug": "interfaces-coverage",
"weight": 1
},
{
"slug": "variables-coverage",
"weight": 1
},
{
"slug": "properties-coverage",
"weight": 1
},
{
"slug": "types-coverage",
"weight": 1
},
{
"slug": "enums-coverage",
"weight": 1
}
],
"title": "Documentation coverage",
"description": "Documentation coverage"
}
],
"audits": [
{
"slug": "enums-coverage",
"displayValue": "0 undocumented enums",
"value": 0,
"score": 1,
"description": "Documentation coverage of enums",
"details": {
"issues": []
"issues": [],
},
"displayValue": "0 undocumented enums",
"score": 1,
"slug": "enums-coverage",
"title": "Enums coverage",
"description": "Documentation coverage of enums"
"value": 0,
},
{
"slug": "interfaces-coverage",
"displayValue": "0 undocumented interfaces",
"value": 0,
"score": 1,
"description": "Documentation coverage of interfaces",
"details": {
"issues": []
"issues": [],
},
"displayValue": "0 undocumented interfaces",
"score": 1,
"slug": "interfaces-coverage",
"title": "Interfaces coverage",
"description": "Documentation coverage of interfaces"
"value": 0,
},
{
"slug": "types-coverage",
"displayValue": "0 undocumented types",
"value": 0,
"score": 1,
"description": "Documentation coverage of types",
"details": {
"issues": []
"issues": [],
},
"displayValue": "0 undocumented types",
"score": 1,
"slug": "types-coverage",
"title": "Types coverage",
"description": "Documentation coverage of types"
"value": 0,
},
{
"slug": "functions-coverage",
"displayValue": "2 undocumented functions",
"value": 2,
"score": 0.3333,
"description": "Documentation coverage of functions",
"details": {
"issues": [
{
Expand All @@ -95,30 +49,30 @@
"source": {
"file": "tmp/e2e/plugin-jsdocs-e2e/__test__/angular/src/app.component.spec.ts",
"position": {
"startLine": 1
}
}
"startLine": 1,
},
},
},
{
"message": "Missing functions documentation for mapEventToCustomEvent",
"severity": "warning",
"source": {
"file": "tmp/e2e/plugin-jsdocs-e2e/__test__/angular/src/map-event.function.ts",
"position": {
"startLine": 3
}
}
}
]
"startLine": 3,
},
},
},
],
},
"displayValue": "2 undocumented functions",
"score": 0.3333,
"slug": "functions-coverage",
"title": "Functions coverage",
"description": "Documentation coverage of functions"
"value": 2,
},
{
"slug": "variables-coverage",
"displayValue": "1 undocumented variables",
"value": 1,
"score": 0,
"description": "Documentation coverage of variables",
"details": {
"issues": [
{
Expand All @@ -127,31 +81,31 @@
"source": {
"file": "tmp/e2e/plugin-jsdocs-e2e/__test__/angular/src/map-event.function.ts",
"position": {
"startLine": 1
}
}
}
]
"startLine": 1,
},
},
},
],
},
"displayValue": "1 undocumented variables",
"score": 0,
"slug": "variables-coverage",
"title": "Variables coverage",
"description": "Documentation coverage of variables"
"value": 1,
},
{
"slug": "classes-coverage",
"displayValue": "0 undocumented classes",
"value": 0,
"score": 1,
"description": "Documentation coverage of classes",
"details": {
"issues": []
"issues": [],
},
"displayValue": "0 undocumented classes",
"score": 1,
"slug": "classes-coverage",
"title": "Classes coverage",
"description": "Documentation coverage of classes"
"value": 0,
},
{
"slug": "methods-coverage",
"displayValue": "1 undocumented methods",
"value": 1,
"score": 0.5,
"description": "Documentation coverage of methods",
"details": {
"issues": [
{
Expand All @@ -160,20 +114,20 @@
"source": {
"file": "tmp/e2e/plugin-jsdocs-e2e/__test__/angular/src/app.component.ts",
"position": {
"startLine": 15
}
}
}
]
"startLine": 15,
},
},
},
],
},
"displayValue": "1 undocumented methods",
"score": 0.5,
"slug": "methods-coverage",
"title": "Methods coverage",
"description": "Documentation coverage of methods"
"value": 1,
},
{
"slug": "properties-coverage",
"displayValue": "1 undocumented properties",
"value": 1,
"score": 0,
"description": "Documentation coverage of properties",
"details": {
"issues": [
{
Expand All @@ -182,16 +136,66 @@
"source": {
"file": "tmp/e2e/plugin-jsdocs-e2e/__test__/angular/src/app.component.ts",
"position": {
"startLine": 5
}
}
}
]
"startLine": 5,
},
},
},
],
},
"displayValue": "1 undocumented properties",
"score": 0,
"slug": "properties-coverage",
"title": "Properties coverage",
"description": "Documentation coverage of properties"
}
]
}
]
}
"value": 1,
},
],
"description": "Official Code PushUp JSDoc coverage plugin.",
"docsUrl": "https://www.npmjs.com/package/@code-pushup/jsdocs-plugin/",
"groups": [
{
"description": "Documentation coverage",
"refs": [
{
"slug": "classes-coverage",
"weight": 2,
},
{
"slug": "methods-coverage",
"weight": 2,
},
{
"slug": "functions-coverage",
"weight": 2,
},
{
"slug": "interfaces-coverage",
"weight": 1,
},
{
"slug": "variables-coverage",
"weight": 1,
},
{
"slug": "properties-coverage",
"weight": 1,
},
{
"slug": "types-coverage",
"weight": 1,
},
{
"slug": "enums-coverage",
"weight": 1,
},
],
"slug": "documentation-coverage",
"title": "Documentation coverage",
},
],
"icon": "folder-docs",
"slug": "jsdocs",
"title": "JSDoc coverage",
},
],
}
`;
Loading