diff --git a/.gitignore b/.gitignore
index 1407c8975..3360c953c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@ node_modules
/.sass-cache
/connect.lock
/coverage
+/examples/react-todos-app/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
diff --git a/.verdaccio/config.yml b/.verdaccio/config.yml
index a007fe824..f74420f2b 100644
--- a/.verdaccio/config.yml
+++ b/.verdaccio/config.yml
@@ -19,7 +19,7 @@ packages:
proxy: npmjs
# log settings
-logs:
+log:
type: stdout
format: pretty
level: warn
diff --git a/e2e/cli-e2e/mocks/fixtures/code-pushup.config.coverage.ts b/e2e/cli-e2e/mocks/fixtures/code-pushup.config.coverage.ts
deleted file mode 100644
index df76233b8..000000000
--- a/e2e/cli-e2e/mocks/fixtures/code-pushup.config.coverage.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { join } from 'node:path';
-import coveragePlugin from '@code-pushup/coverage-plugin';
-import { CoreConfig } from '@code-pushup/models';
-
-export default {
- upload: {
- organization: 'code-pushup',
- project: 'cli-ts',
- apiKey: 'e2e-api-key',
- server: 'https://e2e.com/api',
- },
- categories: [
- {
- slug: 'code-coverage',
- title: 'Code coverage',
- refs: [
- {
- type: 'group',
- plugin: 'coverage',
- slug: 'coverage',
- weight: 1,
- },
- ],
- },
- ],
- plugins: [
- await coveragePlugin({
- reports: [join('e2e', 'cli-e2e', 'mocks', 'fixtures', 'lcov.info')],
- }),
- ],
-} satisfies CoreConfig;
diff --git a/e2e/cli-e2e/mocks/fixtures/code-pushup.config.js b/e2e/cli-e2e/mocks/fixtures/code-pushup.config.js
index b1f832775..2a2f0c418 100644
--- a/e2e/cli-e2e/mocks/fixtures/code-pushup.config.js
+++ b/e2e/cli-e2e/mocks/fixtures/code-pushup.config.js
@@ -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 {
@@ -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')],
+ }),
],
};
diff --git a/e2e/cli-e2e/mocks/fixtures/code-pushup.config.mjs b/e2e/cli-e2e/mocks/fixtures/code-pushup.config.mjs
index caf140741..ee282c54e 100644
--- a/e2e/cli-e2e/mocks/fixtures/code-pushup.config.mjs
+++ b/e2e/cli-e2e/mocks/fixtures/code-pushup.config.mjs
@@ -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 {
@@ -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')],
+ }),
],
};
diff --git a/e2e/cli-e2e/mocks/fixtures/code-pushup.config.ts b/e2e/cli-e2e/mocks/fixtures/code-pushup.config.ts
index 108f9c05e..1c2dc64ae 100644
--- a/e2e/cli-e2e/mocks/fixtures/code-pushup.config.ts
+++ b/e2e/cli-e2e/mocks/fixtures/code-pushup.config.ts
@@ -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';
@@ -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;
diff --git a/e2e/cli-e2e/tests/__snapshots__/collect.e2e.test.ts.snap b/e2e/cli-e2e/tests/__snapshots__/collect.e2e.test.ts.snap
index 571be9ae0..1e059b7cc 100644
--- a/e2e/cli-e2e/tests/__snapshots__/collect.e2e.test.ts.snap
+++ b/e2e/cli-e2e/tests/__snapshots__/collect.e2e.test.ts.snap
@@ -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": [
{
diff --git a/e2e/cli-e2e/tests/collect.e2e.test.ts b/e2e/cli-e2e/tests/collect.e2e.test.ts
index 2453f2011..72f342944 100644
--- a/e2e/cli-e2e/tests/collect.e2e.test.ts
+++ b/e2e/cli-e2e/tests/collect.e2e.test.ts
@@ -30,7 +30,7 @@ describe('CLI collect', () => {
it('should run ESLint plugin and create report.json', async () => {
const { code, stderr } = await executeProcess({
command: 'code-pushup',
- args: ['collect', '--no-progress'],
+ args: ['collect', '--no-progress', '--onlyPlugins=eslint'],
cwd: 'examples/react-todos-app',
});
@@ -43,7 +43,7 @@ describe('CLI collect', () => {
expect(omitVariableReportData(report as Report)).toMatchSnapshot();
});
- it('should run Code coverage plugin and create report.json', async () => {
+ 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
@@ -57,7 +57,7 @@ describe('CLI collect', () => {
'..',
'mocks',
'fixtures',
- 'code-pushup.config.coverage.ts',
+ 'code-pushup.config.ts',
);
const { code, stderr } = await executeProcess({
@@ -66,7 +66,8 @@ describe('CLI collect', () => {
'collect',
'--no-progress',
`--config=${configPath}`,
- `--persist.outputDir=tmp/e2e`,
+ '--persist.outputDir=tmp/e2e',
+ '--onlyPlugins=coverage',
],
});
@@ -79,6 +80,22 @@ describe('CLI collect', () => {
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/react-todos-app/report.json');
+
+ expect(() => reportSchema.parse(report)).not.toThrow();
+ expect(omitVariableReportData(report as Report)).toMatchSnapshot();
+ });
+
it('should create report.md', async () => {
const { code, stderr } = await executeProcess({
command: 'code-pushup',
diff --git a/e2e/cli-e2e/tests/print-config.e2e.test.ts b/e2e/cli-e2e/tests/print-config.e2e.test.ts
index 2f25799a7..2c19a3421 100644
--- a/e2e/cli-e2e/tests/print-config.e2e.test.ts
+++ b/e2e/cli-e2e/tests/print-config.e2e.test.ts
@@ -25,6 +25,7 @@ describe('print-config', () => {
expect(code).toBe(0);
expect(stderr).toBe('');
+
expect(JSON.parse(stdout)).toEqual(
expect.objectContaining({
config: expect.stringContaining(`code-pushup.config.${ext}`),
@@ -42,10 +43,15 @@ describe('print-config', () => {
},
plugins: [
expect.objectContaining({ slug: 'eslint', title: 'ESLint' }),
+ expect.objectContaining({
+ slug: 'coverage',
+ title: 'Code coverage',
+ }),
],
categories: [
expect.objectContaining({ slug: 'bug-prevention' }),
expect.objectContaining({ slug: 'code-style' }),
+ expect.objectContaining({ slug: 'code-coverage' }),
],
onlyPlugins: [],
}),
diff --git a/examples/react-todos-app/code-pushup.config.js b/examples/react-todos-app/code-pushup.config.js
index 88b8c968d..9d7cb3a2a 100644
--- a/examples/react-todos-app/code-pushup.config.js
+++ b/examples/react-todos-app/code-pushup.config.js
@@ -1,4 +1,5 @@
-// TODO: import plugins using NPM package names using local registry: https://github.com/flowup/quality-metrics-cli/issues/33
+import { join } from 'node:path';
+import coveragePlugin from '../../dist/packages/plugin-coverage';
import eslintPlugin from '../../dist/packages/plugin-eslint';
const eslintAuditRef = (slug, weight) => ({
@@ -13,6 +14,13 @@ export default {
outputDir: '../../tmp/react-todos-app',
},
plugins: [
+ await coveragePlugin({
+ reports: [join('coverage', 'lcov.info')],
+ coverageToolCommand: {
+ command: 'npx',
+ args: ['vitest', 'run', '--coverage'],
+ },
+ }),
await eslintPlugin({
eslintrc: '.eslintrc.js',
patterns: ['src/**/*.js', 'src/**/*.jsx'],
@@ -20,7 +28,18 @@ export default {
],
categories: [
// TODO: add performance category once Lighthouse plugin implemented, include eslintAuditRef('react-jsx-key', 0)
-
+ {
+ slug: 'code-coverage',
+ title: 'Code coverage',
+ refs: [
+ {
+ type: 'group',
+ plugin: 'coverage',
+ slug: 'coverage',
+ weight: 1,
+ },
+ ],
+ },
{
slug: 'bug-prevention',
title: 'Bug prevention',
diff --git a/examples/react-todos-app/project.json b/examples/react-todos-app/project.json
index feceb7219..868d237d2 100644
--- a/examples/react-todos-app/project.json
+++ b/examples/react-todos-app/project.json
@@ -37,6 +37,15 @@
}
}
},
+ "test": {
+ "executor": "@nx/vite:test",
+ "outputs": ["{options.reportsDirectory}"],
+ "options": {
+ "config": "examples/react-todos-app/vite.config.ts",
+ "reportsDirectory": "../../coverage/examples/react-todos-app",
+ "coverage": true
+ }
+ },
"preview": {
"executor": "@nx/vite:preview-server",
"defaultConfiguration": "development",
diff --git a/examples/react-todos-app/src/App.test.jsx b/examples/react-todos-app/src/App.test.jsx
new file mode 100644
index 000000000..c8e5667bc
--- /dev/null
+++ b/examples/react-todos-app/src/App.test.jsx
@@ -0,0 +1,20 @@
+import '@testing-library/jest-dom';
+import { render, screen } from '@testing-library/react';
+import React from 'react';
+import { describe, expect, it } from 'vitest';
+import App from './App';
+
+describe('App', () => {
+ it('should display the app title', async () => {
+ render();
+
+ expect(screen.getByRole('heading')).toHaveTextContent('TODOs');
+ });
+
+ it('should display an Add button', async () => {
+ render();
+
+ expect(screen.getByRole('button')).toBeVisible();
+ expect(screen.getByRole('button')).toHaveTextContent('Add');
+ });
+});
diff --git a/examples/react-todos-app/test-setup.js b/examples/react-todos-app/test-setup.js
new file mode 100644
index 000000000..141cd45f9
--- /dev/null
+++ b/examples/react-todos-app/test-setup.js
@@ -0,0 +1,9 @@
+import * as matchers from '@testing-library/jest-dom/matchers';
+import { cleanup } from '@testing-library/react';
+import { afterEach, expect } from 'vitest';
+
+expect.extend(matchers);
+
+afterEach(() => {
+ cleanup();
+});
diff --git a/examples/react-todos-app/tsconfig.app.json b/examples/react-todos-app/tsconfig.app.json
index cd44a1e78..a86621c8c 100644
--- a/examples/react-todos-app/tsconfig.app.json
+++ b/examples/react-todos-app/tsconfig.app.json
@@ -10,6 +10,7 @@
]
},
"exclude": [
+ "vite.config.ts",
"src/**/*.spec.ts",
"src/**/*.test.ts",
"src/**/*.spec.tsx",
diff --git a/examples/react-todos-app/tsconfig.spec.json b/examples/react-todos-app/tsconfig.spec.json
index 0c872b8e3..9a202f348 100644
--- a/examples/react-todos-app/tsconfig.spec.json
+++ b/examples/react-todos-app/tsconfig.spec.json
@@ -6,10 +6,6 @@
},
"include": [
"vite.config.ts",
- "src/**/*.test.ts",
- "src/**/*.spec.ts",
- "src/**/*.test.tsx",
- "src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
diff --git a/examples/react-todos-app/vite.config.ts b/examples/react-todos-app/vite.config.ts
index d1d37adae..5bff82afb 100644
--- a/examples/react-todos-app/vite.config.ts
+++ b/examples/react-todos-app/vite.config.ts
@@ -22,7 +22,11 @@ export default defineConfig({
cache: {
dir: '../../node_modules/.vitest',
},
+ coverage: {
+ reporter: ['lcov', 'text'],
+ },
environment: 'jsdom',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
+ setupFiles: ['test-setup.js'],
},
});
diff --git a/package-lock.json b/package-lock.json
index 5506a6267..4b702501c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@code-pushup/cli-source",
- "version": "0.18.1",
+ "version": "0.20.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@code-pushup/cli-source",
- "version": "0.18.1",
+ "version": "0.20.0",
"license": "MIT",
"dependencies": {
"@code-pushup/portal-client": "^0.5.0",
@@ -40,7 +40,8 @@
"@nx/workspace": "17.1.3",
"@swc/cli": "~0.1.62",
"@swc/core": "1.3.99",
- "@testing-library/react": "14.0.0",
+ "@testing-library/jest-dom": "^6.4.2",
+ "@testing-library/react": "^14.0.0",
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
"@types/benchmark": "^2.1.4",
"@types/chalk": "^2.2.0",
@@ -107,6 +108,12 @@
"node": ">=0.10.0"
}
},
+ "node_modules/@adobe/css-tools": {
+ "version": "4.3.3",
+ "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.3.3.tgz",
+ "integrity": "sha512-rE0Pygv0sEZ4vBWHlAgJLGDU7Pm8xoO6p3wsEceb7GYAjScrOHpEo8KK/eVkAcnSM+slAEtXjA2JpdjLp4fJQQ==",
+ "dev": true
+ },
"node_modules/@ampproject/remapping": {
"version": "2.2.1",
"dev": true,
@@ -5885,6 +5892,103 @@
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
"dev": true
},
+ "node_modules/@testing-library/jest-dom": {
+ "version": "6.4.2",
+ "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.4.2.tgz",
+ "integrity": "sha512-CzqH0AFymEMG48CpzXFriYYkOjk6ZGPCLMhW9e9jg3KMCn5OfJecF8GtGW7yGfR/IgCe3SX8BSwjdzI6BBbZLw==",
+ "dev": true,
+ "dependencies": {
+ "@adobe/css-tools": "^4.3.2",
+ "@babel/runtime": "^7.9.2",
+ "aria-query": "^5.0.0",
+ "chalk": "^3.0.0",
+ "css.escape": "^1.5.1",
+ "dom-accessibility-api": "^0.6.3",
+ "lodash": "^4.17.15",
+ "redent": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=14",
+ "npm": ">=6",
+ "yarn": ">=1"
+ },
+ "peerDependencies": {
+ "@jest/globals": ">= 28",
+ "@types/bun": "latest",
+ "@types/jest": ">= 28",
+ "jest": ">= 28",
+ "vitest": ">= 0.32"
+ },
+ "peerDependenciesMeta": {
+ "@jest/globals": {
+ "optional": true
+ },
+ "@types/bun": {
+ "optional": true
+ },
+ "@types/jest": {
+ "optional": true
+ },
+ "jest": {
+ "optional": true
+ },
+ "vitest": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@testing-library/jest-dom/node_modules/ansi-styles": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+ "dev": true,
+ "dependencies": {
+ "color-convert": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+ }
+ },
+ "node_modules/@testing-library/jest-dom/node_modules/chalk": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
+ "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
+ "dev": true,
+ "dependencies": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/@testing-library/jest-dom/node_modules/color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "dev": true,
+ "dependencies": {
+ "color-name": "~1.1.4"
+ },
+ "engines": {
+ "node": ">=7.0.0"
+ }
+ },
+ "node_modules/@testing-library/jest-dom/node_modules/color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+ "dev": true
+ },
+ "node_modules/@testing-library/jest-dom/node_modules/dom-accessibility-api": {
+ "version": "0.6.3",
+ "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.6.3.tgz",
+ "integrity": "sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==",
+ "dev": true
+ },
"node_modules/@testing-library/react": {
"version": "14.0.0",
"resolved": "https://registry.npmjs.org/@testing-library/react/-/react-14.0.0.tgz",
@@ -10053,6 +10157,12 @@
"url": "https://github.com/sponsors/fb55"
}
},
+ "node_modules/css.escape": {
+ "version": "1.5.1",
+ "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz",
+ "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==",
+ "dev": true
+ },
"node_modules/csso": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/csso/-/csso-5.0.5.tgz",
diff --git a/package.json b/package.json
index 1775afc88..ebd6c1273 100644
--- a/package.json
+++ b/package.json
@@ -77,7 +77,8 @@
"@nx/workspace": "17.1.3",
"@swc/cli": "~0.1.62",
"@swc/core": "1.3.99",
- "@testing-library/react": "14.0.0",
+ "@testing-library/jest-dom": "^6.4.2",
+ "@testing-library/react": "^14.0.0",
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
"@types/benchmark": "^2.1.4",
"@types/chalk": "^2.2.0",
diff --git a/packages/cli/src/lib/implementation/only-plugins.utils.ts b/packages/cli/src/lib/implementation/only-plugins.utils.ts
index 1d04c3f98..c37cebee9 100644
--- a/packages/cli/src/lib/implementation/only-plugins.utils.ts
+++ b/packages/cli/src/lib/implementation/only-plugins.utils.ts
@@ -1,5 +1,5 @@
import chalk from 'chalk';
-import { CategoryConfig, CoreConfig } from '@code-pushup/models';
+import type { CategoryConfig, CoreConfig } from '@code-pushup/models';
export function filterPluginsBySlug(
plugins: CoreConfig['plugins'],
@@ -29,14 +29,14 @@ export function filterCategoryByPluginSlug(
return categories.filter(category =>
category.refs.every(ref => {
- const isNotSkipped = onlyPlugins.includes(ref.slug);
+ const isNotSkipped = onlyPlugins.includes(ref.plugin);
if (!isNotSkipped && verbose) {
console.info(
`${chalk.yellow('⚠')} Category "${
category.title
}" is ignored because it references audits from skipped plugin "${
- ref.slug
+ ref.plugin
}"`,
);
}
diff --git a/packages/cli/src/lib/implementation/only-plugins.utils.unit.test.ts b/packages/cli/src/lib/implementation/only-plugins.utils.unit.test.ts
index 694588ad1..2c69877c5 100644
--- a/packages/cli/src/lib/implementation/only-plugins.utils.unit.test.ts
+++ b/packages/cli/src/lib/implementation/only-plugins.utils.unit.test.ts
@@ -39,14 +39,18 @@ describe('filterCategoryByPluginSlug', () => {
expect(
filterCategoryByPluginSlug(
[
- { refs: [{ slug: 'plugin1' }, { slug: 'plugin2' }] },
- { refs: [{ slug: 'plugin3' }] },
+ {
+ refs: [{ plugin: 'plugin1' }, { plugin: 'plugin2' }],
+ },
+ { refs: [{ plugin: 'plugin3' }] },
] as CategoryConfig[],
{},
),
).toEqual([
- { refs: [{ slug: 'plugin1' }, { slug: 'plugin2' }] },
- { refs: [{ slug: 'plugin3' }] },
+ {
+ refs: [{ plugin: 'plugin1' }, { plugin: 'plugin2' }],
+ },
+ { refs: [{ plugin: 'plugin3' }] },
]);
});
@@ -54,12 +58,14 @@ describe('filterCategoryByPluginSlug', () => {
expect(
filterCategoryByPluginSlug(
[
- { refs: [{ slug: 'plugin1' }, { slug: 'plugin2' }] },
- { refs: [{ slug: 'plugin3' }] },
+ {
+ refs: [{ plugin: 'plugin1' }, { plugin: 'plugin2' }],
+ },
+ { refs: [{ plugin: 'plugin3' }] },
] as CategoryConfig[],
{ onlyPlugins: ['plugin1', 'plugin3'] },
),
- ).toEqual([{ refs: [{ slug: 'plugin3' }] }]);
+ ).toEqual([{ refs: [{ plugin: 'plugin3' }] }]);
});
it('should print ignored category and its first violating plugin', () => {
@@ -67,9 +73,13 @@ describe('filterCategoryByPluginSlug', () => {
[
{
title: 'category1',
- refs: [{ slug: 'plugin1' }, { slug: 'plugin2' }, { slug: 'plugin4' }],
+ refs: [
+ { plugin: 'plugin1' },
+ { plugin: 'plugin2' },
+ { plugin: 'plugin4' },
+ ],
},
- { title: 'category2', refs: [{ slug: 'plugin3' }] },
+ { title: 'category2', refs: [{ plugin: 'plugin3' }] },
] as CategoryConfig[],
{
onlyPlugins: ['plugin1', 'plugin3'],