akiran / akiran/react-slick

Issue with Jest

Abierto
#2,202 4 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
11.9k
Forks
2.1k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### 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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.