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

207
Views
getting error _LoginPage.default is not a constructor

this is my code

/// \<reference types = "cypress" /\>

class LoginPage
{

    visit()
    {
        cy.visit("https://ec2-35-179-99-242.eu-west-2.compute.amazonaws.com:2021/")
    
    }
    
    username(name)
    {
        const field = cy.get('[id=UserName]')
        field.clear()
        field.type(name)
        return this
    }
    
    Password(pwd)
    {
        const pass = cy.get('[id=Password]')
        pass.clear()
        pass.type(pwd)
        return this
    }
    
    Submit()
    {
       const button = cy.get('[type=submit]')
       button.click()
    }

}

export default LoginPage
/// \<reference types = "cypress" /\>

import LoginPage from './PageObject/LoginPage'

    it('valid test', function()
    {
    
        const Login = new LoginPage()
         Login.visit()
         Login.username('arslan')
         Login.Password('123')
         Login.Submit()
        
    
    })

i make object of Login class

const Login = new LoginPage()

but getting error getting error _LoginPage.default is not a constructor

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Try using a named export

export class LoginPage {

  visit() {
    cy.visit("https://ec2-35-179-99-242.eu-west-2.compute.amazonaws.com:2021/")
  }
  ...
}

and import like this

import { LoginPage } from './PageObject/LoginPage'
about 4 years ago · Juan Pablo Isaza Report

0

You need to use function reserved name before all your functions names or declare the functions like a const using an arrow function like:

function visit()
    {
        cy.visit("https://ec2-35-179-99-242.eu-west-2.compute.amazonaws.com:2021/")
    
    }

or

const visit = () =>
    {
        cy.visit("https://ec2-35-179-99-242.eu-west-2.compute.amazonaws.com:2021/")
    
    }
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!