@@ -6,42 +6,42 @@ import { getDirname } from './helper.mock';
66const __dirname = getDirname ( import . meta. url ) ;
77
88const withDirName = ( path : string ) => join ( __dirname , path ) ;
9- const configPath = ( ext : string ) =>
9+ const config = ( ext : string ) =>
1010 `${ withDirName ( '../../../test/config.mock.' ) } ${ ext } ` ;
1111
1212describe ( 'applyConfigMiddleware' , ( ) => {
1313 it ( 'should load valid .mjs config' , async ( ) => {
14- const configPathMjs = configPath ( 'mjs' ) ;
15- const config = await configMiddleware ( { configPath : configPathMjs } ) ;
16- expect ( config . upload . project ) . toContain ( 'mjs' ) ;
17- expect ( config . persist . outputDir ) . toContain ( 'tmp' ) ;
14+ const configPathMjs = config ( 'mjs' ) ;
15+ const _config = await configMiddleware ( { config : configPathMjs } ) ;
16+ expect ( _config . upload . project ) . toContain ( 'mjs' ) ;
17+ expect ( _config . persist . outputDir ) . toContain ( 'tmp' ) ;
1818 } ) ;
1919
2020 it ( 'should load valid .cjs config' , async ( ) => {
21- const configPathCjs = configPath ( 'cjs' ) ;
22- const config = await configMiddleware ( { configPath : configPathCjs } ) ;
23- expect ( config . upload . project ) . toContain ( 'cjs' ) ;
24- expect ( config . persist . outputDir ) . toContain ( 'tmp' ) ;
21+ const configPathCjs = config ( 'cjs' ) ;
22+ const _config = await configMiddleware ( { config : configPathCjs } ) ;
23+ expect ( _config . upload . project ) . toContain ( 'cjs' ) ;
24+ expect ( _config . persist . outputDir ) . toContain ( 'tmp' ) ;
2525 } ) ;
2626
2727 it ( 'should load valid .js config' , async ( ) => {
28- const configPathJs = configPath ( 'js' ) ;
29- const config = await configMiddleware ( { configPath : configPathJs } ) ;
30- expect ( config . upload . project ) . toContain ( 'js' ) ;
31- expect ( config . persist . outputDir ) . toContain ( 'tmp' ) ;
28+ const configPathJs = config ( 'js' ) ;
29+ const _config = await configMiddleware ( { config : configPathJs } ) ;
30+ expect ( _config . upload . project ) . toContain ( 'js' ) ;
31+ expect ( _config . persist . outputDir ) . toContain ( 'tmp' ) ;
3232 } ) ;
3333
34- it ( 'should throw with invalid configPath ' , async ( ) => {
35- const configPath = 'wrong/path/to/config' ;
34+ it ( 'should throw with invalid config ' , async ( ) => {
35+ const config = 'wrong/path/to/config' ;
3636 let error : Error = new Error ( ) ;
37- await configMiddleware ( { configPath } ) . catch ( e => ( error = e ) ) ;
38- expect ( error ?. message ) . toContain ( configPath ) ;
37+ await configMiddleware ( { config } ) . catch ( e => ( error = e ) ) ;
38+ expect ( error ?. message ) . toContain ( config ) ;
3939 } ) ;
4040
41- it ( 'should provide default configPath ' , async ( ) => {
41+ it ( 'should provide default config ' , async ( ) => {
4242 const defaultConfigPath = 'code-pushup.config.js' ;
4343 let error : Error = new Error ( ) ;
44- await configMiddleware ( { configPath : undefined } ) . catch ( e => ( error = e ) ) ;
44+ await configMiddleware ( { config : undefined } ) . catch ( e => ( error = e ) ) ;
4545 expect ( error ?. message ) . toContain ( defaultConfigPath ) ;
4646 } ) ;
4747} ) ;
0 commit comments