Issue with Jest
- 主要言語
- JavaScript
- スター
- 11.9k
- フォーク
- 2.1k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
### Issue occuring when trying to write jest tests
I have followed the docs and added the following to setupTests.json
```
window.matchMedia = window.matchMedia || function() {
return {
matches : false,
addListener : function() {},
removeListener: function() {}
};
};
```
I am still getting the following error:
` matchMedia not present, legacy browsers require a polyfill
`
Package Json:
```
{
"name": "kegthat-headless",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "jest"
},
"dependencies": {
"@apollo/client": "^3.7.2",
"@types/node": "18.11.15",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"axios": "^0.21.1",
"eslint": "8.29.0",
"eslint-config-next": "13.0.6",
"jest-environment-jsdom": "^29.3.1",
"lodash": "^4.17.21",
"next": "13.0.6",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-slick": "^0.29.0",
"slick-carousel": "^1.8.1",
"typescript": "4.9.4"
},
"devDependencies": {
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@testing-library/dom": "^8.19.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@types/react-slick": "^0.23.10",
"autoprefixer": "^10.4.13",
"babel-jest": "^29.3.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.3.1",
"jest-cli": "^29.3.1",
"polyfill": "^0.1.0",
"postcss": "^8.4.20",
"tailwindcss": "^3.2.4",
"ts-node": "^10.9.1"
}
}
```
I cannot add a `test-setup.js` as there is already a `jest.config.ts` in the project. Is there a fix for this?
Cheers
コントリビューションガイド
評価
この issue はまだ評価されていません。