해결 방법
yarn add --dev jest-canvas-mock
jest.config.js
:
module.exports = {
preset: "ts-jest",
testEnvironment: "jsdom",
setupFilesAfterEnv: [
"@testing-library/jest-dom/extend-expect",
"jest-plugin-context/setup",
"jest-canvas-mock", // 추가
],
testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/dist/"],
moduleNameMapper: {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootDir>/__mocks__/fileMock.js",
"\\.(css|less|scss|sass)$": "identity-obj-proxy",
},
};
See also