testdouble / testdouble/testdouble.js

Add docs for using `testdouble` when we have to use another loader (ie `ts-node/esm`)

Open
#514 8 comments 0 reactions 0 assignees View on GitHub

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 -v output: v16.13.2
  • npm -v (or yarn --version) output:
  • npm ls testdouble (or yarn 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
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

  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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.