Skip to content

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

@codan84

Description

@codan84

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions