Skip to content

Support for ESM #2450

Answered by mastermatt
emilioSp asked this question in Q&A
Feb 24, 2023 · 2 comments · 5 replies
Discussion options

You must be logged in to vote

@emilioSp I haven't worked with vitest before, or even vite, but there shouldn't be an issue with mixing Nock and vitest as ESM first.

My gut is that the error it self is mostly a red herring from how vite monkey patches Node's built-in require functionality (similar to what Jest does).
Thanks for providing the repo, I was able to get things going by ensuring esModuleInterop was set to true in your ts-config then fixing the nock import.
import nock from 'nock';

Hopefully that's enough to get you going.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@emilioSp
Comment options

@mastermatt
Comment options

@emilioSp
Comment options

@emilioSp
Comment options

@emilioSp
Comment options

Answer selected by emilioSp
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants