@@ -2,26 +2,36 @@ import os from 'node:os';
22import path from 'node:path' ;
33import { fileURLToPath } from 'node:url' ;
44import { type MockInstance , describe , expect , it } from 'vitest' ;
5- import type { AuditOutput , AuditOutputs , Issue } from '@code-pushup/models' ;
5+ import type {
6+ AuditOutput ,
7+ AuditOutputs ,
8+ Issue ,
9+ RunnerFilesPaths ,
10+ } from '@code-pushup/models' ;
611import { osAgnosticAuditOutputs } from '@code-pushup/test-utils' ;
712import { readJsonFile } from '@code-pushup/utils' ;
813import type { ESLintTarget } from './config.js' ;
914import { listAuditsAndGroups } from './meta/index.js' ;
10- import {
11- RUNNER_OUTPUT_PATH ,
12- createRunnerConfig ,
13- executeRunner ,
14- } from './runner/index.js' ;
15+ import { createRunnerConfig , executeRunner } from './runner/index.js' ;
1516
1617describe ( 'executeRunner' , ( ) => {
1718 let cwdSpy : MockInstance < [ ] , string > ;
1819 let platformSpy : MockInstance < [ ] , NodeJS . Platform > ;
1920
20- const createPluginConfig = async ( eslintrc : ESLintTarget [ 'eslintrc' ] ) => {
21+ const createPluginConfig = async (
22+ eslintrc : ESLintTarget [ 'eslintrc' ] ,
23+ ) : Promise < RunnerFilesPaths > => {
2124 const patterns = [ 'src/**/*.js' , 'src/**/*.jsx' ] ;
2225 const targets : ESLintTarget [ ] = [ { eslintrc, patterns } ] ;
2326 const { audits } = await listAuditsAndGroups ( targets ) ;
24- await createRunnerConfig ( 'bin.js' , audits , targets ) ;
27+ const { outputFile } = await createRunnerConfig ( 'bin.js' , audits , targets ) ;
28+ return {
29+ runnerOutputPath : outputFile ,
30+ runnerConfigPath : outputFile . replace (
31+ 'runner-output.json' ,
32+ 'plugin-config.json' ,
33+ ) ,
34+ } ;
2535 } ;
2636
2737 const appDir = path . join (
@@ -45,18 +55,22 @@ describe('executeRunner', () => {
4555 } ) ;
4656
4757 it ( 'should execute ESLint and create audit results for React application' , async ( ) => {
48- await createPluginConfig ( 'eslint.config.js' ) ;
49- await executeRunner ( ) ;
58+ const runnerPaths = await createPluginConfig ( 'eslint.config.js' ) ;
59+ await executeRunner ( runnerPaths ) ;
5060
51- const json = await readJsonFile < AuditOutputs > ( RUNNER_OUTPUT_PATH ) ;
61+ const json = await readJsonFile < AuditOutputs > ( runnerPaths . runnerOutputPath ) ;
5262 expect ( osAgnosticAuditOutputs ( json ) ) . toMatchSnapshot ( ) ;
5363 } ) ;
5464
5565 it ( 'should execute runner with custom config using @code-pushup/eslint-config' , async ( ) => {
56- await createPluginConfig ( 'code-pushup.eslint.config.mjs' ) ;
57- await executeRunner ( ) ;
66+ const runnerPaths = await createPluginConfig (
67+ 'code-pushup.eslint.config.mjs' ,
68+ ) ;
69+ await executeRunner ( runnerPaths ) ;
5870
59- const json = await readJsonFile < AuditOutput [ ] > ( RUNNER_OUTPUT_PATH ) ;
71+ const json = await readJsonFile < AuditOutput [ ] > (
72+ runnerPaths . runnerOutputPath ,
73+ ) ;
6074 // expect warnings from unicorn/filename-case rule from default config
6175 expect ( json ) . toContainEqual (
6276 expect . objectContaining < Partial < AuditOutput > > ( {
0 commit comments