File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ const utils = require('../utils');
2424exports . CONFIG_FILES = [
2525 '.mocharc.cjs' ,
2626 '.mocharc.js' ,
27+ '.mocharc.mjs' ,
2728 '.mocharc.yaml' ,
2829 '.mocharc.yml' ,
2930 '.mocharc.jsonc' ,
@@ -64,13 +65,16 @@ const parsers = (exports.parsers = {
6465 * @returns {Object } Parsed config object
6566 */
6667exports . loadConfig = filepath => {
68+ const packageJson = require ( path . resolve ( utils . cwd ( ) , 'package.json' ) ) ;
6769 let config = { } ;
6870 debug ( 'loadConfig: trying to parse config at %s' , filepath ) ;
6971
7072 const ext = path . extname ( filepath ) ;
7173 try {
7274 if ( ext === '.yml' || ext === '.yaml' ) {
7375 config = parsers . yaml ( filepath ) ;
76+ } else if ( ( ext === '.js' && packageJson . type === "module" ) || ext === '.mjs' ) {
77+ config = parsers . js ( filepath ) . default ;
7478 } else if ( ext === '.js' || ext === '.cjs' ) {
7579 config = parsers . js ( filepath ) ;
7680 } else {
You can’t perform that action at this time.
0 commit comments