Skip to content

Commit

Permalink
Support .mocharc.cjs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
emma-borhanian committed Feb 16, 2020
1 parent ac12f2c commit 559205f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/cli/config.js
Expand Up @@ -22,6 +22,7 @@ const findUp = require('find-up');
*/
exports.CONFIG_FILES = [
'.mocharc.js',
'.mocharc.cjs',
'.mocharc.yaml',
'.mocharc.yml',
'.mocharc.jsonc',
Expand Down Expand Up @@ -75,7 +76,7 @@ exports.loadConfig = filepath => {
try {
if (ext === '.yml' || ext === '.yaml') {
config = parsers.yaml(filepath);
} else if (ext === '.js') {
} else if (ext === '.js' || ext === '.cjs') {
config = parsers.js(filepath);
} else {
config = parsers.json(filepath);
Expand Down

0 comments on commit 559205f

Please sign in to comment.