Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

129
Vistas
Cypress Component Test Types in React?

I'm trying to create a component test in cypress. I did the setup and all basics tests are working fine.

Now I tried to mock a function with jest:

import { mount } from '@cypress/react'

const onDissmis = jest.fn()

describe('Tags', () => {

  describe('Basic', () => {
    mount(<Component onDismiss={onDissmis} />)
  })
})

I also get the intellisense from VSCode: enter image description here

However when I try to run the code I get:

The following error originated from your test code, not from Cypress.

  > jest is not defined

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
Cypress could not associate this error to any specific test.
We dynamically generated a new test to display this failure.

Probably the ts config is wrong (so it's just referencing me jest but it's not using jest) Maybe mocha? How can I configure the project that it's correct?

This is my tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "types": [
      "cypress"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "src",
    "craco.config.js",
    "**/*.ts"
  ]
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I don;t know about using Jest with Cypress (you may just be able to add Jest package to the app).

But Cypress has cy.stub(). Does this work?

import { mount } from '@cypress/react'

const onDissmis = cy.stub()

describe('Tags', () => {

  describe('Basic', () => {
    mount(<Component onDismiss={onDissmis} />)
  })
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda