Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!