Skip to content

Commit 559205f

Browse files
Support .mocharc.cjs
This allows for `"type": "module"` in package.json while also using a mocha config file, which was previously impossible. See: https://nodejs.org/api/esm.html Compare to jestjs/jest#9086
1 parent ac12f2c commit 559205f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/cli/config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const findUp = require('find-up');
2222
*/
2323
exports.CONFIG_FILES = [
2424
'.mocharc.js',
25+
'.mocharc.cjs',
2526
'.mocharc.yaml',
2627
'.mocharc.yml',
2728
'.mocharc.jsonc',
@@ -75,7 +76,7 @@ exports.loadConfig = filepath => {
7576
try {
7677
if (ext === '.yml' || ext === '.yaml') {
7778
config = parsers.yaml(filepath);
78-
} else if (ext === '.js') {
79+
} else if (ext === '.js' || ext === '.cjs') {
7980
config = parsers.js(filepath);
8081
} else {
8182
config = parsers.json(filepath);

0 commit comments

Comments
 (0)