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

159
Visualizações
How to resolve a type error in javascript/cypress

I am learning cypress and javascript and have come across this type error.

 TypeError: _testElements.default.selectionRow is not a function

I looked at some documentation with cypress and can't see a mistake I am making in the code, so was hoping someone with javascript and cypress experience may know why this error is being outputted.

Code:

First the class where it gets the element:

class testElements {

    selectionRow() {
        return cy.get('.selectionRow')
     }

    typeButton() {
        return cy.get('.typeButton')
     }
 
  
}

export default testElements

And then the code it's referring the error to is below:

import { Given, When, Then } from "cypress-cucumber-preprocessor/steps";
import testElements from '../elements/testElements';

When ("User selects a row", () => {
  testElements.selectionRow()
  .within(() => {
    testElements.typeButton().not(".disabled");
  })
})
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You should first create a class instance to use the methods:

const testElem = new testElements();
testElem.selectionRow()

And I suggest to use uppercase name convention for class TestElements.

If you don't want to instantiating the class, you can use static methods

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