Basic Mocking example for `override global or imported objects` does not work
I am following the example https://docs.deno.com/examples/testing_tutorial/#basic-mocking and when run with
deno test --no-check
the example fails with:
I'm running with --no-checks
to prove its not only a type issue, but the type checker does catch it if you remove the --no-check
flag.
Is there anyway to get this example to work or another way to isolate imports
in Deno?
I am using the latest Deno:
3 Replies
good catch, looks like this example in the documentation is wrong. Module exports cannot be mocked as they are not writable
Filed an issue for that https://github.com/denoland/docs/issues/1631
GitHub
Bug: Basic mocking example doesn't work · Issue #1631 · denoland/...
The example for basic mocking doesn't work, see https://docs.deno.com/examples/testing_tutorial/#basic-mocking . Reason it doesn't work is that it tries to replace properties of a module re...
Thank you for opening the issue. I'll look around to see how people handle breaking dependencies.