File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Original file line number Diff line number Diff line change 1
1
const findBabelConfig = require ( 'find-babel-config' )
2
2
const logger = require ( './logger' )
3
3
const cache = require ( './cache' )
4
- const { readFileSync } = require ( 'fs' )
4
+ const path = require ( 'path' )
5
+ const { readFileSync, existsSync } = require ( 'fs' )
5
6
6
7
module . exports = function getBabelConfig ( vueJestConfig ) {
7
8
const cachedConfig = cache . get ( 'babel-config' )
@@ -14,6 +15,8 @@ module.exports = function getBabelConfig (vueJestConfig) {
14
15
15
16
if ( vueJestConfig . babelRcFile ) {
16
17
babelConfig = JSON . parse ( readFileSync ( vueJestConfig . babelRcFile ) )
18
+ } else if ( existsSync ( 'babel.config.js' ) ) {
19
+ babelConfig = require ( path . resolve ( 'babel.config.js' ) )
17
20
} else {
18
21
const { file, config } = findBabelConfig . sync ( process . cwd ( ) , 0 )
19
22
Original file line number Diff line number Diff line change @@ -64,4 +64,15 @@ describe('load-babel-config.js', () => {
64
64
throw err
65
65
}
66
66
} )
67
+
68
+ it ( 'supports babel.config.js' , ( ) => {
69
+ const babelConfigPath = resolve ( __dirname , '../babel.config.js' )
70
+ const config = {
71
+ plugins : [ 'foo' ]
72
+ }
73
+ writeFileSync ( babelConfigPath , `module.exports = ${ JSON . stringify ( config ) } ` )
74
+ const babelConfig = loadBabelConfig ( { } )
75
+ expect ( babelConfig ) . toEqual ( config )
76
+ unlinkSync ( babelConfigPath )
77
+ } )
67
78
} )
You can’t perform that action at this time.
0 commit comments