@@ -3,9 +3,6 @@ import * as babel from '@babel/core';
3
3
import { readFile } from 'fs-extra' ;
4
4
import glob from 'fast-glob' ;
5
5
6
- const workspaceRoot = path . join ( __dirname , '../../../' ) ;
7
- const defaultBabelConfigPath = path . join ( workspaceRoot , 'babel.config.js' ) ;
8
-
9
6
function getTestFilesNames ( filepath : string ) {
10
7
return glob . sync (
11
8
path
@@ -18,15 +15,14 @@ function getTestFilesNames(filepath: string) {
18
15
) ;
19
16
}
20
17
21
- async function parseWithConfig ( filename : string , configFilePath : string ) {
18
+ async function parseWithConfig ( filename : string ) {
22
19
const source = await readFile ( filename , { encoding : 'utf8' } ) ;
23
20
const partialConfig = babel . loadPartialConfig ( {
24
- configFile : configFilePath ,
25
21
filename,
26
22
} ) ;
27
23
28
24
if ( partialConfig === null ) {
29
- throw new Error ( `Could not load a babel config for ${ filename } located at ${ configFilePath } .` ) ;
25
+ throw new Error ( `Could not load a babel config for ${ filename } .` ) ;
30
26
}
31
27
32
28
return babel . parseAsync ( source , partialConfig . options ) ;
@@ -128,10 +124,7 @@ export interface ParseResult {
128
124
themeDefaultProps : boolean | undefined | null ;
129
125
}
130
126
131
- export default async function parseTest (
132
- componentFilename : string ,
133
- babelConfigPath : string = defaultBabelConfigPath ,
134
- ) : Promise < ParseResult > {
127
+ export default async function parseTest ( componentFilename : string ) : Promise < ParseResult > {
135
128
const testFilenames = getTestFilesNames ( componentFilename ) ;
136
129
137
130
if ( testFilenames . length === 0 ) {
@@ -146,7 +139,7 @@ export default async function parseTest(
146
139
// eslint-disable-next-line no-restricted-syntax
147
140
for await ( const testFilename of testFilenames ) {
148
141
if ( descriptor === null ) {
149
- const babelParseResult = await parseWithConfig ( testFilename , babelConfigPath ) ;
142
+ const babelParseResult = await parseWithConfig ( testFilename ) ;
150
143
if ( babelParseResult === null ) {
151
144
throw new Error ( `Could not parse ${ testFilename } .` ) ;
152
145
}
0 commit comments