cssinjs/jss

[react-jss] Jest tests error

Open

#1395 opened on Sep 23, 2020

View on GitHub
 (7 comments) (10 reactions) (0 assignees)JavaScript (7,000 stars) (434 forks)batch import
help wantedquestion

Description

Problem with testing react with jest. I am getting this error whenever I use jss in a component.

Screenshot from 2020-09-23 17-41-26

Also i have a valid config for jest:

{
  "moduleDirectories": [
    "node_modules",
    "src"
  ],
  "moduleFileExtensions": [
    "ts",
    "tsx",
    "js",
    "jsx",
    "json",
    "node"
  ],
  "moduleNameMapper": {
    "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|pdf)$": "identity-obj-proxy"
  },
  "preset": "ts-jest",
  "roots": [
    "<rootDir>/src"
  ],
  "setupFilesAfterEnv": [
    "<rootDir>/src/setupTests.js"
  ],
  "testEnvironment": "jsdom",
  "testMatch": [
    "<rootDir>/src/**/__tests__/**/*.{ts,tsx}",
    "<rootDir>/src/**/*(*.)(spec|test).{ts,tsx}",
    "<rootDir>/test/**/*.{ts,tsx}",
    "<rootDir>/test/**/?(*.)(spec|test).{ts,tsx}"
  ],
  "transform": {
    "^.+\\.tsx?$": "ts-jest",
    "^.+\\.jsx?$": "babel-jest"
  },
  "verbose": true
}

Contributor guide