Skip to content

Commit 5454e03

Browse files
committed
refactor: fix int tests 1
1 parent 5d24b82 commit 5454e03

File tree

7 files changed

+45
-48
lines changed

7 files changed

+45
-48
lines changed

packages/plugin-eslint/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@code-pushup/eslint-plugin",
3-
"version": "0.76.0",
3+
"version": "0.77.0",
44
"license": "MIT",
55
"description": "Code PushUp plugin for detecting problems in source code using ESLint.📋",
66
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-eslint#readme",
@@ -39,8 +39,8 @@
3939
"type": "module",
4040
"dependencies": {
4141
"glob": "^11.0.0",
42-
"@code-pushup/utils": "0.76.0",
43-
"@code-pushup/models": "0.76.0",
42+
"@code-pushup/utils": "0.77.0",
43+
"@code-pushup/models": "0.77.0",
4444
"yargs": "^17.7.2",
4545
"zod": "^4.0.5"
4646
},

packages/plugin-eslint/src/lib/runner.int.test.ts

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,23 @@ import path from 'node:path';
33
import process from 'node:process';
44
import { fileURLToPath } from 'node:url';
55
import { type MockInstance, describe, expect, it } from 'vitest';
6-
import type {
7-
AuditOutput,
8-
AuditOutputs,
9-
Issue,
10-
RunnerFilesPaths,
11-
} from '@code-pushup/models';
6+
import type { Audit, AuditOutput, Issue } from '@code-pushup/models';
127
import { osAgnosticAuditOutputs } from '@code-pushup/test-utils';
13-
import { readJsonFile } from '@code-pushup/utils';
148
import type { ESLintTarget } from './config.js';
159
import { listAuditsAndGroups } from './meta/index.js';
16-
import { createRunnerConfig, executeRunner } from './runner/index.js';
10+
import { createRunnerFunction } from './runner/index.js';
1711

1812
describe('executeRunner', () => {
1913
let cwdSpy: MockInstance<[], string>;
2014
let platformSpy: MockInstance<[], NodeJS.Platform>;
2115

22-
const createPluginConfig = async (
16+
const createAudits = async (
2317
eslintrc: ESLintTarget['eslintrc'],
24-
): Promise<RunnerFilesPaths> => {
18+
): Promise<Audit[]> => {
2519
const patterns = ['src/**/*.js', 'src/**/*.jsx'];
2620
const targets: ESLintTarget[] = [{ eslintrc, patterns }];
2721
const { audits } = await listAuditsAndGroups(targets);
28-
const { outputFile, configFile } = await createRunnerConfig(
29-
'bin.js',
30-
audits,
31-
targets,
32-
);
33-
return {
34-
runnerOutputPath: outputFile,
35-
runnerConfigPath: configFile!,
36-
};
22+
return audits;
3723
};
3824

3925
const appDir = path.join(
@@ -57,24 +43,35 @@ describe('executeRunner', () => {
5743
});
5844

5945
it('should execute ESLint and create audit results for React application', async () => {
60-
const runnerPaths = await createPluginConfig('eslint.config.js');
61-
await executeRunner(runnerPaths);
62-
63-
const json = await readJsonFile<AuditOutputs>(runnerPaths.runnerOutputPath);
64-
expect(osAgnosticAuditOutputs(json)).toMatchSnapshot();
46+
const eslintTarget = 'eslint.config.js';
47+
const runnerFn = await createRunnerFunction({
48+
audits: await createAudits(eslintTarget),
49+
targets: [
50+
{
51+
eslintrc: eslintTarget,
52+
patterns: '.',
53+
},
54+
],
55+
});
56+
const res = await runnerFn({ outputDir: '' });
57+
await expect(osAgnosticAuditOutputs(res)).resolves.toMatchSnapshot();
6558
});
6659

6760
it.skipIf(process.platform === 'win32')(
6861
'should execute runner with custom config using @code-pushup/eslint-config',
6962
async () => {
70-
const runnerPaths = await createPluginConfig(
71-
'code-pushup.eslint.config.mjs',
72-
);
73-
await executeRunner(runnerPaths);
63+
const eslintTarget = 'eslint.config.js';
64+
const runnerFn = await createRunnerFunction({
65+
audits: await createAudits(eslintTarget),
66+
targets: [
67+
{
68+
eslintrc: 'code-pushup.eslint.config.mjs',
69+
patterns: '.',
70+
},
71+
],
72+
});
7473

75-
const json = await readJsonFile<AuditOutput[]>(
76-
runnerPaths.runnerOutputPath,
77-
);
74+
const json = await runnerFn({ outputDir: '' });
7875
// expect warnings from unicorn/filename-case rule from default config
7976
expect(json).toContainEqual(
8077
expect.objectContaining<Partial<AuditOutput>>({

packages/plugin-js-packages/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@code-pushup/js-packages-plugin",
3-
"version": "0.76.0",
3+
"version": "0.77.0",
44
"description": "Code PushUp plugin for JavaScript packages 🛡️",
55
"license": "MIT",
66
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-js-packages#readme",
@@ -37,8 +37,8 @@
3737
},
3838
"type": "module",
3939
"dependencies": {
40-
"@code-pushup/models": "0.76.0",
41-
"@code-pushup/utils": "0.76.0",
40+
"@code-pushup/models": "0.77.0",
41+
"@code-pushup/utils": "0.77.0",
4242
"build-md": "^0.4.1",
4343
"semver": "^7.6.0",
4444
"yargs": "^17.7.2",

packages/plugin-jsdocs/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@code-pushup/jsdocs-plugin",
3-
"version": "0.76.0",
3+
"version": "0.77.0",
44
"description": "Code PushUp plugin for tracking documentation coverage 📚",
55
"license": "MIT",
66
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-jsdocs#readme",
@@ -35,8 +35,8 @@
3535
},
3636
"type": "module",
3737
"dependencies": {
38-
"@code-pushup/models": "0.76.0",
39-
"@code-pushup/utils": "0.76.0",
38+
"@code-pushup/models": "0.77.0",
39+
"@code-pushup/utils": "0.77.0",
4040
"zod": "^4.0.5",
4141
"ts-morph": "^24.0.0"
4242
},

packages/plugin-lighthouse/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@code-pushup/lighthouse-plugin",
3-
"version": "0.76.0",
3+
"version": "0.77.0",
44
"license": "MIT",
55
"description": "Code PushUp plugin for measuring web performance and quality with Lighthouse 🔥",
66
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-lighthouse#readme",
@@ -36,8 +36,8 @@
3636
},
3737
"type": "module",
3838
"dependencies": {
39-
"@code-pushup/models": "0.76.0",
40-
"@code-pushup/utils": "0.76.0",
39+
"@code-pushup/models": "0.77.0",
40+
"@code-pushup/utils": "0.77.0",
4141
"ansis": "^3.3.0",
4242
"chrome-launcher": "^1.1.1",
4343
"lighthouse": "^12.0.0",

packages/plugin-typescript/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@code-pushup/typescript-plugin",
3-
"version": "0.76.0",
3+
"version": "0.77.0",
44
"license": "MIT",
55
"description": "Code PushUp plugin for incrementally adopting strict compilation flags in TypeScript projects",
66
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-typescript#readme",
@@ -23,8 +23,8 @@
2323
},
2424
"type": "module",
2525
"dependencies": {
26-
"@code-pushup/models": "0.76.0",
27-
"@code-pushup/utils": "0.76.0",
26+
"@code-pushup/models": "0.77.0",
27+
"@code-pushup/utils": "0.77.0",
2828
"zod": "^4.0.5"
2929
},
3030
"peerDependencies": {

packages/utils/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@code-pushup/utils",
3-
"version": "0.76.0",
3+
"version": "0.77.0",
44
"description": "Low-level utilities (helper functions, etc.) used by Code PushUp CLI",
55
"license": "MIT",
66
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/utils#readme",
@@ -27,7 +27,7 @@
2727
"node": ">=17.0.0"
2828
},
2929
"dependencies": {
30-
"@code-pushup/models": "0.76.0",
30+
"@code-pushup/models": "0.77.0",
3131
"@isaacs/cliui": "^8.0.2",
3232
"@poppinss/cliui": "^6.4.0",
3333
"ansis": "^3.3.0",

0 commit comments

Comments
 (0)