Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda