You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't really figure how to do some browser mocking in deno.
I'm using the node command like this, which works:
node --experimental-strip-types --test --import ./test/mock-browser.ts (link to code)
But with deno i get:
deno test --no-check:
error: ReferenceError: document is not defined
container: document.createElement("div"),
I have in my deno.json
"lib": [
"deno.window",
"dom"
]
The mock-browser.ts being:
importMockBrowserfrom"mock-browser";constmock=newMockBrowser.mocks.MockBrowser();global.document=mock.getDocument();global.window={};// Polyfill based on https://gist.github.com/paulirish/1579671letlastTime=0;global.requestAnimationFrame=function(fn){constnow=Date.now();constnextTime=Math.max(lastTime+16,now);setTimeout(()=>fn(lastTime=nextTime),nextTime-now);};
For node compat, I believe I need a way to do a similar --import in deno test, or another way to give a setup file, which I believe vitest calls it
The text was updated successfully, but these errors were encountered:
birkskyum
changed the title
deno test --require or --import
deno test --require or --import (setup file)
Nov 21, 2024
birkskyum
changed the title
deno test --require or --import (setup file)
[node compat] deno test --require or --import (setup file)
Nov 21, 2024
birkskyum
changed the title
[node compat] deno test --require or --import (setup file)
deno test --require or --import (setup file)
Nov 21, 2024
I can't really figure how to do some browser mocking in deno.
I'm using the node command like this, which works:
node --experimental-strip-types --test --import ./test/mock-browser.ts
(link to code)But with deno i get:
deno test --no-check
:I have in my deno.json
The mock-browser.ts being:
For node compat, I believe I need a way to do a similar
--import
in deno test, or another way to give a setup file, which I believe vitest calls itThe text was updated successfully, but these errors were encountered: