1

When I open Page with LWC Component under Cypress.io test, then Salesforce returns error:

A Component Error has occurred!

undefined is not a valid component, or does not extends LightningElement from "lwc". You probably forgot to add the extend clause on the class declaration.

Use Lightning Web Security for Lightning web components is enabled

enter image description here

Cypress code is simple:

describe('playground', () => {
  it('playground', function () {

    cy.request({
      body: {
        display: 'page',
        hasRememberUn: true,
        height: '1080',
        lt: 'standard',
        pw: Cypress.env('password'),
        un: Cypress.env('email'),
        useSecure: true,
        username: Cypress.env('email'),
        width: '2560',
      },
      form: true,
      method: 'POST',
      url: 'https://login.salesforce.com',
    })

    cy.visit('/lightning/n/TestCypressPage')
  })
})

What I do wrong?

2
  • does it work when you manually navigate to that URL? Commented May 4, 2022 at 21:53
  • @KrisGoncalves, if I open this page manually, then such an error does not appear. There is a suspicion that Cypress cannot access the LWC correctly.
    – TIT
    Commented May 5, 2022 at 10:44

1 Answer 1

0

I was struggling with the Component Error issue and din't find any solutions. Whatever solutions available tried most of them finally overcome with wait statements. You can try with before and after where the component error is generating by cy.wait(15000) if that help.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .