Can I use NYC with ESM and Mocha without the "@std/esm" library
Asked Answered
D

0

8

I work at a company where @std/esm has not been approved. I have got my Mocha test working like this...

// suite.js
async function wire(){
    await import("./Sanity.spec.mjs"); // eslint-disable-line
    run();
}
wire();

//Sanity.spec.mjs
import chai from "chai"

describe("My Test", ()=>{
    it("Should do what I want", ()=>chai.assert.equal(1,1, "One is in fact 1")); // eslint-disable-line no-self-compare
});

But when I run like nyc mocha --delay --exit ./test/suite.js I see the mocha tests run but the code coverage results are empty.

  My Test
    √ Should do what I want

  When using base App
info: Healthcheck server is listening on 420
    √ App should not be null
    √ The port should be correct


  3 passing (24ms)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |        0 |        0 |        0 |        0 |                   |
----------|----------|----------|----------|----------|-------------------|

I left the other tests out but they do import libraries. The question is how do I get this to work with NYC?

Daisey answered 14/2, 2019 at 2:20 Comment(1)
Does this answer your question? How do I get Istanbul to recognize code coverage when using ESM?Joab

© 2022 - 2024 — McMap. All rights reserved.