Industrial
Industrial•2y ago

How do I patch a std api?

Hello. This person posted in this command that they "patched" the vm.isContext function to return false in order to get the node:jsdom library to work: https://github.com/denoland/fresh/issues/427#issuecomment-1251918545 I am wondering how they did that. I tried this:
import * as vm from "std/node/vm.ts";
vm.isContext = () => false;
import * as vm from "std/node/vm.ts";
vm.isContext = () => false;
But this throws the error:
error: TypeError: Cannot assign to read only property 'isContext' of object '[object Module]'
error: TypeError: Cannot assign to read only property 'isContext' of object '[object Module]'
GitHub
Testing Fresh Components · Issue #427 · denoland/fresh
Issue: Deno testing suit documentation does not elaborate on how to render and test components. Discussion: I have been having trouble finding ways to conduct unit tests for Fresh components. When ...
3 Replies
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Industrial
Industrial•2y ago
I did it like this:
"https://deno.land/std@0.158.0/node/vm.ts": "./lib/std/node/vm.ts",
"https://deno.land/std@0.158.0/node/vm.ts": "./lib/std/node/vm.ts",
import * as vm from "std/node/vm.ts";

const isContext = () => false;

export default {
...vm,
isContext,
};
import * as vm from "std/node/vm.ts";

const isContext = () => false;

export default {
...vm,
isContext,
};
Almost have React component tests with React Testing Library working 🤞 If i get that + a CSS-in-JS approach for Fresh then I can start using Fresh for Serious Business (tm) 🙂