From be46986128cfa36608a353a363dd95312c67633b Mon Sep 17 00:00:00 2001 From: Jack Reed <phillipjreed@gmail.com> Date: Fri, 25 Jan 2019 10:39:13 -0700 Subject: [PATCH] enable css to be directly imported/mocked into components for unit testing in jest --- __mocks__/css.js | 1 + jest.json | 3 +++ webpack.config.js | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 __mocks__/css.js diff --git a/__mocks__/css.js b/__mocks__/css.js new file mode 100644 index 000000000..f053ebf79 --- /dev/null +++ b/__mocks__/css.js @@ -0,0 +1 @@ +module.exports = {}; diff --git a/jest.json b/jest.json index 65b010d0e..398f92a51 100644 --- a/jest.json +++ b/jest.json @@ -5,6 +5,9 @@ ], "coverageDirectory": "<rootDir>/coverage", "coverageReporters": ["html", "lcov"], + "moduleNameMapper": { + "\\.css$": "<rootDir>/__mocks__/css.js" + }, "setupFiles": [ "<rootDir>/setupJest.js" ], diff --git a/webpack.config.js b/webpack.config.js index 91ac63b35..76cf075c3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -73,7 +73,7 @@ const baseConfig = [ eslintLoaderConfig, babelLoaderConfig, { - test: /\.scss$/, + test: /\.s?css$/, use: [ 'style-loader', // creates style nodes from JS strings 'css-loader', // translates CSS into CommonJS -- GitLab