sinonjs / sinonjs/sinon

How to stub ES module imports documentation is incorrect

Open Beginner friendly
#2,714 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
9.8k
Forks
809
PR merge metrics
No merged PRs in 30d

Description

Documentation was added in #2676 (~2 months ago)

I tried following it and discovered that it is, in fact, incorrect, at least when using the most recent version of esm.

The set up file, according to the instructions, should look like this:

require = require("esm")(module, {
  cjs: true,
  mutableNamespace: true,
});

however, if you look on esm documentation (https://www.npmjs.com/package/esm#options), you can see that mutableNamespace is NOT a top-level key. It should be set up like this:

require = require("esm")(module, {
  cjs: {mutableNamespace: true}
});

Given that the foundation of this documentation is incorrect, it makes me doubt if this has actually been verified by a human, and I think that incorrect docs are worse than no docs at all.

I hope you are able to either delete the file, or mark it as "unverified" tutorial, after updating the esm config.
Thank you in advance

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the documentation added in #2676 and compare its esm setup instructions with the esm options documentation linked in the issue. Done means the configuration is corrected, or the tutorial is deleted or marked unverified as requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.