cssinjs / cssinjs/jss

[react-jss] Jest tests error

Open
#1,395 7 comments 10 reactions 0 assignees View on GitHub
help wanted question
Dominant language
JavaScript
Stars
7.1k
Forks
386
PR merge metrics
No merged PRs in 30d

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](https://user-images.githubusercontent.com/30584905/94021237-ffd57380-fddd-11ea-996e-c9d256e1d388.png)

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": [
"/src"
],
"setupFilesAfterEnv": [
"/src/setupTests.js"
],
"testEnvironment": "jsdom",
"testMatch": [
"/src/**/__tests__/**/*.{ts,tsx}",
"/src/**/*(*.)(spec|test).{ts,tsx}",
"/test/**/*.{ts,tsx}",
"/test/**/?(*.)(spec|test).{ts,tsx}"
],
"transform": {
"^.+\\.tsx?$": "ts-jest",
"^.+\\.jsx?$": "babel-jest"
},
"verbose": true
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported Jest failure with the configuration shown in the issue, including src/setupTests.js and the jsdom environment. Inspect the linked error screenshot and determine whether the failure is specific to a component using JSS; done means the relevant Jest test runs without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.