-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing Flags to Node.js #3060
Comments
Also I need to pass an |
The flags Mocha will pass to Node are in |
Perfect. Thank you @ScottFreeCode 👍 |
@jondubois Did you get it to run with |
@stefanwalther ScottFreeCode's solution above worked well for me. You just need to run the mocha script with the |
Well... I cannot get it to work with
|
Did you get this to work @michael-brade ? |
@seenickcode nope, I gave up on it and won't use modules for the time being. Modules caused a whole lot of problems with the toolchain and I wasted way too much of my precious time on it. Maybe I'll try again in a year or two when it's ready. |
you can use esm if you want to use modules. install esm then adding |
@pukapukan indeed it does! |
@pukapukan works perfectly, thanks! I was initally confused where to add this (whether it was a node flag or a mocha flag) but my tests are working after the following "scripts": {
- "test": "mocha test.js"
+ "test": "mocha test.js -r esm"
} hope this helps anyone else slightly confused for a similar reason |
ERROR: Cannot find module 'esm' |
try |
Has anyone gotten this to work with Node 12 and My
But I'm still getting a syntax error on on |
@justinfagnani After experimenting with the experimental module support in Node and reading up on how the new support works, I believe testing ES Modules using Mocha alone cannot be made to work using just Node at the moment. Using the built-in support isn't possible until Mocha decides it to be by changing its core. You can pass the flags to enable module support in Node like this: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/fatso/dev/sinon/test/es2015/module-support-assessment-test.mjs Wuuut? The reason Node complains is that Mocha imports the test files using the normal CommonJS cc: @stefanwalther |
both fail for me with |
@brandonros I linked to an article from the Node team on how the new module support works in Node 12. Excerpt:
That means you cannot expect files ending in The only change you need to do is change the file extension to something not explicitly treated by Node in any specific way, like |
If we want to pass flags to node that mocha doesn't understand, we have to pass them to node and then invoke mocha as a script. Refs: mochajs/mocha#3060
This worked for me, thanks! |
I can't figure out a way to pass the
--expose-http2
flag to node. I would like to be able to do:Is this currently possible (using mocha v3.2.0)?
The text was updated successfully, but these errors were encountered: