New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use jest-canvas-mock without jest #51
Comments
I can not catch your problem, can give me a test case? |
jest-canvas-mock/src/window.js Line 47 in d895824
Is it because Path2D exists in jsdom? so mock failed? |
Yeah. I recently had to bootstrap this library without using jest so I could test a few wasm simd functions in my canvas library. I want to think on this before I make any suggestions. |
I believe this can be fixed by checking to see if Another really easy fix might also be to just import the I find that using |
I will likely start to tackle this soon. I feel like people should be able to import this module without having to do any setup. This means testing the module without |
I believe this is still worth using. Perhaps the core functionality of emulating the |
Change this repo to mono repo? |
I don't entirely know the right answer. It would be nice for someone else to pick up the responsibility, because I'm only good at the canvas part. :) |
You can get around this by importing the script inside of a setup module. // jest.config.js module.exports = {
setupFilesAfterEnv: ["./jest.setup.js"],
// other jest config
} // jest.setup.js require("jest-canvas-mock")
\\ jest setup stuff Essentially the setup file works like a before block, so it's already in a jest context. This should remove the jest global error. |
I'm having similar issues but for a totally separate reason. I like to use jest with the |
Example setup needed to bootstrap jest manually that can be a pain point:
@hustcc is this something worth supporting?
The text was updated successfully, but these errors were encountered: