Possible Bug with mocha new configuration file
See original GitHub issueHi, I need help with an issue with mocha new configuration file. I apologize if I am going through the wrong avenue for help. Anyways my .mocharc.js file is in the root directory of my project and its content is
'use strict';
module.exports = {
require: ['ts-node/register', 'esm'],
file: ['./test/testSetup.ts'],
reporter: 'nyan',
ui: 'bdd',
};
when i run the cli mocha "./test/**/*.spec.tsx"
I get an unexpected token export in one of my node_modules dependencies
when I specify explicitly through the cli mocha -r ts-node/register -r esm --file "./test/testSetup.ts" --ui bdd "./test/**/*.spec.tsx"
it is able to run the test just fine
Issue Analytics
- State:
- Created 4 years ago
- Comments:27 (14 by maintainers)
Top Results From Across the Web
mochajs/mocha - Gitter
Hello all! I have been running around SO, mocha source, issues, and any other tutorials I can find, but I am still doing...
Read more >FAQ - MochaSoft
After installation, use menu - tools - configuration to import/export the users configuration file. You can run tn5250.exe or tn3270.exe with the configuration ......
Read more >Why is Mocha not working with Yarn Berry? - Stack Overflow
If a bug you should open an issue on our repository (Yarn). However, Mocha is covered by an E2E test and a bug...
Read more >Mocha documentation — DevDocs
New in v6.0.0. Specify an explicit path to a package.json file (ostensibly containing configuration in a mocha property). By ...
Read more >mocha - UNPKG
13, ## :bug: Fixes. 14. 15, - [#4668](https://github.com/mochajs/mocha/issues/4668): ESM: make `--require <dir>` work with new `import`-first loading ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi,
I had a similar issue to this happen to me earlier today.
Using version 6.1.4 I was able to use mocha with esm with the following sections in my package.json file:
Post upgrade to mocha 6.2.0 this did not work. The esm module wasn’t being called. I was getting the dreaded
SyntaxError: Unexpected token {
error for my import statement.I needed to change my package.json file so that esm was explicitly called via the command line. For example:
I’m not sure if these two issues are related or not. As I found this thread via a Google search to work out what was wrong, I thought it worth mentioning.
@juergba I can confirm that with the patch applied as per #3983 my use case works. Specifically using the following in my package.json file.
My thanks to you and the team for working on this issue.