From 559205faf6f2cc31cc3b5dc019fee3c02ccd5df9 Mon Sep 17 00:00:00 2001 From: Emma Borhanian Date: Sat, 15 Feb 2020 17:25:47 -0800 Subject: [PATCH] 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 https://github.com/facebook/jest/issues/9086 --- lib/cli/config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cli/config.js b/lib/cli/config.js index 6fa4e2dbca..fd3e118228 100644 --- a/lib/cli/config.js +++ b/lib/cli/config.js @@ -22,6 +22,7 @@ const findUp = require('find-up'); */ exports.CONFIG_FILES = [ '.mocharc.js', + '.mocharc.cjs', '.mocharc.yaml', '.mocharc.yml', '.mocharc.jsonc', @@ -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);