From f4faaeab805b58c937a4c9b467355acb2b2c4595 Mon Sep 17 00:00:00 2001 From: Toshimitsu Watanabe Date: Mon, 7 Feb 2022 12:39:24 +0900 Subject: [PATCH] Fix jest config to import .css --- jest.config.js | 8 ++++++++ package-lock.json | 13 +++++++++++++ package.json | 1 + 3 files changed, 22 insertions(+) diff --git a/jest.config.js b/jest.config.js index e8176658..94a4d18e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -4,4 +4,12 @@ module.exports = { setupFilesAfterEnv: ["./src/setupTest.ts"], testEnvironment: "jsdom", verbose: true, + transform: { + "^.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": + "jest-transform-stub", + }, + moduleNameMapper: { + "^.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": + "jest-transform-stub", + }, }; diff --git a/package-lock.json b/package-lock.json index f00cf2c2..bdc9cd06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56,6 +56,7 @@ "eslint-plugin-unused-imports": "^1.1.5", "husky": "^7.0.4", "jest": "^27.4.7", + "jest-transform-stub": "^2.0.0", "lint-staged": "^12.3.3", "loki": "^0.28.1", "npm-run-all": "^4.1.5", @@ -22446,6 +22447,12 @@ "node": ">=8" } }, + "node_modules/jest-transform-stub": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/jest-transform-stub/-/jest-transform-stub-2.0.0.tgz", + "integrity": "sha512-lspHaCRx/mBbnm3h4uMMS3R5aZzMwyNpNIJLXj4cEsV0mIUtS4IjYJLSoyjRCtnxb6RIGJ4NL2quZzfIeNhbkg==", + "dev": true + }, "node_modules/jest-util": { "version": "26.6.2", "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", @@ -50479,6 +50486,12 @@ } } }, + "jest-transform-stub": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/jest-transform-stub/-/jest-transform-stub-2.0.0.tgz", + "integrity": "sha512-lspHaCRx/mBbnm3h4uMMS3R5aZzMwyNpNIJLXj4cEsV0mIUtS4IjYJLSoyjRCtnxb6RIGJ4NL2quZzfIeNhbkg==", + "dev": true + }, "jest-util": { "version": "26.6.2", "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-26.6.2.tgz", diff --git a/package.json b/package.json index 4520bdd0..fa3d0c97 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,7 @@ "eslint-plugin-unused-imports": "^1.1.5", "husky": "^7.0.4", "jest": "^27.4.7", + "jest-transform-stub": "^2.0.0", "lint-staged": "^12.3.3", "loki": "^0.28.1", "npm-run-all": "^4.1.5",