testdouble / testdouble/testdouble.js
Add docs for using `testdouble` when we have to use another loader (ie `ts-node/esm`)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 140
- Avg merge
- 22h
- Merged PRs (30d)
- 1
Description
Description
I am already running my tests with --loader=ts-node/esm to handle TypeScript to ESM compilation and writing my tests in TypeScript.
How can I now plug in Testdouble to be able to call replaceEsm in my tests? An example of this would be very useful.
From what I can see we can specify multiple loaders, but I have failed to find the right way to do it:
https://nodejs.org/docs/latest-v16.x/api/esm.html#loaders
(I am, in particular, using Ava)
Issue
It is not clear how to use testdouble with --loader=ts-node/esm
Environment
-
node -voutput: v16.13.2 -
npm -v(oryarn --version) output: -
npm ls testdouble(oryarn list testdouble) version: 3.17.2
Failing Test
- Fork the repo
- Add a failing test (probably to the `/regression/src' directory)
- Submit a pull request for the failing test or link to your branch here
Example Repo
- Create a minimal repository that reproduces the issue
- Make sure that a fresh clone can run only
npm itand observe the issue - Link to that repo here: https://github.com/codan84/jest-ts-experiments/tree/ava-testdouble
Runkit Notebook
- Create a Runkit notebook
- Invoke
var td = require('testdouble')at the top - Verify the behavior your issue is concerned with by clicking "Run"
- Link to the Runkit here
Code-fenced Examples
var td = require('testdouble')
// Your steps here.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start with the Node.js ESM loader documentation and the linked Ava example repository at https://github.com/codan84/jest-ts-experiments/tree/ava-testdouble. Review how ts-node/esm, Ava, and Testdouble's replaceEsm are combined. Done means the project documentation includes a working TypeScript example for using Testdouble with another loader.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, typescript
- Domain
- documentation, testing-qa
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100