Skip to content

test: add E2E for coverage plugin, fix onlyPlugins logic #505

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

Merged
merged 5 commits into from
Feb 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ node_modules
/.sass-cache
/connect.lock
/coverage
/examples/react-todos-app/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
Expand Down
2 changes: 1 addition & 1 deletion .verdaccio/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ packages:
proxy: npmjs

# log settings
logs:
log:
type: stdout
format: pretty
level: warn
Expand Down
31 changes: 0 additions & 31 deletions e2e/cli-e2e/mocks/fixtures/code-pushup.config.coverage.ts

This file was deleted.

17 changes: 17 additions & 0 deletions e2e/cli-e2e/mocks/fixtures/code-pushup.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { join } from 'node:path';
import coveragePlugin from '@code-pushup/coverage-plugin';
import eslintPlugin from '@code-pushup/eslint-plugin';

export default {
Expand All @@ -20,8 +22,23 @@ export default {
{ type: 'group', plugin: 'eslint', slug: 'suggestions', weight: 1 },
],
},
{
slug: 'code-coverage',
title: 'Code coverage',
refs: [
{
type: 'group',
plugin: 'coverage',
slug: 'coverage',
weight: 1,
},
],
},
],
plugins: [
await eslintPlugin({ eslintrc: '.eslintrc.json', patterns: '**/*.ts' }),
await coveragePlugin({
reports: [join('e2e', 'cli-e2e', 'mocks', 'fixtures', 'lcov.info')],
}),
],
};
17 changes: 17 additions & 0 deletions e2e/cli-e2e/mocks/fixtures/code-pushup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { join } from 'node:path';
import coveragePlugin from '@code-pushup/coverage-plugin';
import eslintPlugin from '@code-pushup/eslint-plugin';

export default {
Expand All @@ -20,8 +22,23 @@ export default {
{ type: 'group', plugin: 'eslint', slug: 'suggestions', weight: 1 },
],
},
{
slug: 'code-coverage',
title: 'Code coverage',
refs: [
{
type: 'group',
plugin: 'coverage',
slug: 'coverage',
weight: 1,
},
],
},
],
plugins: [
await eslintPlugin({ eslintrc: '.eslintrc.json', patterns: '**/*.ts' }),
await coveragePlugin({
reports: [join('e2e', 'cli-e2e', 'mocks', 'fixtures', 'lcov.info')],
}),
],
};
17 changes: 17 additions & 0 deletions e2e/cli-e2e/mocks/fixtures/code-pushup.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { join } from 'node:path';
import coveragePlugin from '@code-pushup/coverage-plugin';
import eslintPlugin from '@code-pushup/eslint-plugin';
import { CoreConfig } from '@code-pushup/models';

Expand All @@ -21,8 +23,23 @@ export default {
{ type: 'group', plugin: 'eslint', slug: 'suggestions', weight: 1 },
],
},
{
slug: 'code-coverage',
title: 'Code coverage',
refs: [
{
type: 'group',
plugin: 'coverage',
slug: 'coverage',
weight: 1,
},
],
},
],
plugins: [
await eslintPlugin({ eslintrc: '.eslintrc.json', patterns: '**/*.ts' }),
await coveragePlugin({
reports: [join('e2e', 'cli-e2e', 'mocks', 'fixtures', 'lcov.info')],
}),
],
} satisfies CoreConfig;
237 changes: 236 additions & 1 deletion e2e/cli-e2e/tests/__snapshots__/collect.e2e.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,241 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`CLI collect > should run Code coverage plugin and create report.json 1`] = `
exports[`CLI collect > should run Code coverage plugin that runs coverage tool and creates report.json 1`] = `
{
"categories": [
{
"refs": [
{
"plugin": "coverage",
"slug": "coverage",
"type": "group",
"weight": 1,
},
],
"slug": "code-coverage",
"title": "Code coverage",
},
],
"packageName": "@code-pushup/core",
"plugins": [
{
"audits": [
{
"description": "Measures how many functions were called in at least one test.",
"details": {
"issues": [
{
"message": "Function onSubmit is not called in any test case.",
"severity": "error",
"source": {
"file": "examples/react-todos-app/src/components/CreateTodo.jsx",
"position": {
"startLine": 13,
},
},
},
{
"message": "Function onInput is not called in any test case.",
"severity": "error",
"source": {
"file": "examples/react-todos-app/src/components/CreateTodo.jsx",
"position": {
"startLine": 21,
},
},
},
{
"message": "Function onInput is not called in any test case.",
"severity": "error",
"source": {
"file": "examples/react-todos-app/src/components/TodoFilter.jsx",
"position": {
"startLine": 9,
},
},
},
{
"message": "Function onChange is not called in any test case.",
"severity": "error",
"source": {
"file": "examples/react-todos-app/src/components/TodoFilter.jsx",
"position": {
"startLine": 17,
},
},
},
],
},
"displayValue": "56 %",
"score": 0.5556,
"slug": "function-coverage",
"title": "Function coverage",
"value": 56,
},
{
"description": "Measures how many branches were executed after conditional statements in at least one test.",
"displayValue": "100 %",
"score": 1,
"slug": "branch-coverage",
"title": "Branch coverage",
"value": 100,
},
{
"description": "Measures how many lines of code were executed in at least one test.",
"details": {
"issues": [
{
"message": "Lines 14-17 are not covered in any test case.",
"severity": "warning",
"source": {
"file": "examples/react-todos-app/src/components/CreateTodo.jsx",
"position": {
"endLine": 17,
"startLine": 14,
},
},
},
{
"message": "Lines 22-23 are not covered in any test case.",
"severity": "warning",
"source": {
"file": "examples/react-todos-app/src/components/CreateTodo.jsx",
"position": {
"endLine": 23,
"startLine": 22,
},
},
},
{
"message": "Lines 10-11 are not covered in any test case.",
"severity": "warning",
"source": {
"file": "examples/react-todos-app/src/components/TodoFilter.jsx",
"position": {
"endLine": 11,
"startLine": 10,
},
},
},
{
"message": "Lines 18-19 are not covered in any test case.",
"severity": "warning",
"source": {
"file": "examples/react-todos-app/src/components/TodoFilter.jsx",
"position": {
"endLine": 19,
"startLine": 18,
},
},
},
{
"message": "Lines 10-28 are not covered in any test case.",
"severity": "warning",
"source": {
"file": "examples/react-todos-app/src/components/TodoList.jsx",
"position": {
"endLine": 28,
"startLine": 10,
},
},
},
{
"message": "Lines 7-9 are not covered in any test case.",
"severity": "warning",
"source": {
"file": "examples/react-todos-app/src/components/TodoList.jsx",
"position": {
"endLine": 9,
"startLine": 7,
},
},
},
{
"message": "Lines 12-13 are not covered in any test case.",
"severity": "warning",
"source": {
"file": "examples/react-todos-app/src/hooks/useTodos.js",
"position": {
"endLine": 13,
"startLine": 12,
},
},
},
{
"message": "Lines 18-37 are not covered in any test case.",
"severity": "warning",
"source": {
"file": "examples/react-todos-app/src/hooks/useTodos.js",
"position": {
"endLine": 37,
"startLine": 18,
},
},
},
{
"message": "Lines 41-45 are not covered in any test case.",
"severity": "warning",
"source": {
"file": "examples/react-todos-app/src/hooks/useTodos.js",
"position": {
"endLine": 45,
"startLine": 41,
},
},
},
{
"message": "Lines 54-60 are not covered in any test case.",
"severity": "warning",
"source": {
"file": "examples/react-todos-app/src/hooks/useTodos.js",
"position": {
"endLine": 60,
"startLine": 54,
},
},
},
],
},
"displayValue": "64 %",
"score": 0.6413,
"slug": "line-coverage",
"title": "Line coverage",
"value": 64,
},
],
"description": "Official Code PushUp code coverage plugin.",
"docsUrl": "https://www.npmjs.com/package/@code-pushup/coverage-plugin/",
"groups": [
{
"description": "Group containing all defined coverage types as audits.",
"refs": [
{
"slug": "function-coverage",
"weight": 6,
},
{
"slug": "branch-coverage",
"weight": 3,
},
{
"slug": "line-coverage",
"weight": 1,
},
],
"slug": "coverage",
"title": "Code coverage metrics",
},
],
"icon": "folder-coverage-open",
"packageName": "@code-pushup/coverage-plugin",
"slug": "coverage",
"title": "Code coverage",
},
],
}
`;

exports[`CLI collect > should run Code coverage plugin which collects passed results and creates report.json 1`] = `
{
"categories": [
{
Expand Down
Loading