Mocha require seems to be ignored for test discovery
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- node.js
- Domain
- devtools, testing-qa
Research direction
Reproduce the issue with the npm command and the equivalent mocha.json containing module-alias/register and esm. Compare how the two configurations are applied during test discovery, then verify that ES6 imports are accepted during discovery as they are when running Mocha directly.
Written by the indexing model from the issue text.
Description
I have a Mocha setup that uses module-alias and esm to load modules using ES6 import. That works fine when running that through npm using:
mocha --require module-alias/register --require esm "test/**/*.js"
I've added a mocha.json with the same require:
"require": [ "module-alias/register", "esm" ]
From the test log I can see that this configuration is read correctly, but the test discovery fails with an error message indicating that the ES6 import is not understood:
Test discovery error: mytest.js:1
(function (exports, require, module, __filename, __dirname) { import { assert } from 'chai';
^
SyntaxError: Unexpected token {
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
[...]
This is the exact same error I get when running through npm without --require esm.
- Dominant language
- C#
- Stars
- 1.8k
- Forks
- 355
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/nodejstools
-
microsoft/nodejstools#2523 · 1 reaction · 1 assignee ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
microsoft/nodejstools#2519 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
microsoft/nodejstools#2517 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
microsoft/nodejstools#2514 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
microsoft/nodejstools#2513 · 5 comments ·
All issues in microsoft/nodejstools
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·