DenoDDeno
Powered by
thorocT
Denoβ€’13mo agoβ€’
5 replies
thoroc

Stubbing @std/x

I need some help understanding how to use the
stub()
stub()
method with
@std/x
@std/x
libraries.


import * as stdYaml from 'jsr:@std/yaml';

 using _parse = stub(
    stdYaml,
    'parse',
    returnsNext([{ version: '3.8' }]),
  );
import * as stdYaml from 'jsr:@std/yaml';

 using _parse = stub(
    stdYaml,
    'parse',
    returnsNext([{ version: '3.8' }]),
  );


The code above seems to satisfy the linter, but the test obviously fails with the following:

sh 
error: MockError: Cannot stub: non-configurable instance method
    throw new MockError("Cannot stub: non-configurable instance method");
sh 
error: MockError: Cannot stub: non-configurable instance method
    throw new MockError("Cannot stub: non-configurable instance method");
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Memory leak when conditionally stubbing fetch
SebGSSebG / help
2y ago
@std/expect `anyOf` equivalent?
GiraffeGGiraffe / help
17mo ago
Using std/crypto with x25519 crashes - How do i use node experimental modules instead?
chromaLTSCchromaLTS / help
2y ago