11import path from 'node:path' ;
22import { fileURLToPath } from 'node:url' ;
3+ import { executeProcess } from '@code-pushup/utils' ;
34import { coreConfigMiddleware } from './core-config.middleware.js' ;
45
56const configDirPath = path . join (
@@ -8,15 +9,26 @@ const configDirPath = path.join(
89 '..' ,
910 '..' ,
1011 '..' ,
11- '..' ,
12- 'testing' ,
13- 'test-fixtures' ,
14- 'src' ,
15- 'lib' ,
16- 'fixtures' ,
12+ 'cli' ,
13+ 'mocks' ,
1714 'configs' ,
1815) ;
19-
16+ const helperPath = path . join (
17+ fileURLToPath ( path . dirname ( import . meta. url ) ) ,
18+ '..' ,
19+ '..' ,
20+ '..' ,
21+ '..' ,
22+ 'cli' ,
23+ 'mocks' ,
24+ 'core-config-middleware.int-helper.ts' ,
25+ ) ;
26+ const runMiddlewareInCwd = async ( ) =>
27+ await executeProcess ( {
28+ command : 'npx' ,
29+ args : [ 'tsx' , helperPath ] ,
30+ cwd : configDirPath ,
31+ } ) ;
2032describe ( 'coreConfigMiddleware' , ( ) => {
2133 const CLI_DEFAULTS = {
2234 plugins : [ ] ,
@@ -43,16 +55,14 @@ describe('coreConfigMiddleware', () => {
4355 } ) ;
4456
4557 it ( 'should load config which relies on provided --tsconfig' , async ( ) => {
46- await expect (
47- coreConfigMiddleware ( {
48- config : path . join (
49- configDirPath ,
50- 'code-pushup.needs-tsconfig.config.ts' ,
51- ) ,
52- tsconfig : path . join ( configDirPath , 'tsconfig.json' ) ,
53- ...CLI_DEFAULTS ,
54- } ) ,
55- ) . resolves . toBeTruthy ( ) ;
58+ const { stdout, code } = await runMiddlewareInCwd ( ) ;
59+
60+ expect ( code ) . toBe ( 0 ) ;
61+ const output = JSON . parse ( stdout ) ;
62+ expect ( output ) . toStrictEqual ( {
63+ success : true ,
64+ config : expect . any ( String ) ,
65+ } ) ;
5666 } ) ;
5767
5868 it ( 'should throw if --tsconfig is missing but needed to resolve import' , async ( ) => {
0 commit comments