question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cypress can't select authenticator inputs for @aws-amplify/ui-react

See original GitHub issue

Describe the bug cypress can’t select authenticator input in @aws-amplify/ui-react

To Reproduce Steps to reproduce the behavior:

  1. add amplify auth to a react app
  2. add amplify auth and cypress
  3. write simple test on authenticator, eg. login

Expected behavior

selectors in this blog can select right inputs,but it’s legacy amplify-ui-react …

export const selectors = {
  // Auth component classes
  usernameInput: '[data-test="username-input"]',
  signInPasswordInput: '[data-test="sign-in-password-input"]',
  signInSignInButton: '[data-test="sign-in-sign-in-button"]',
  signOutButton: '[data-test="sign-out-button"]'
}

tried selectors on chrome developer tools console, it does not work

** Screenshots **

Screen Shot 2020-08-24 at 9 51 06 AM

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
Nxtracommented, Oct 13, 2020

Cypress 5.2.0 added the configuration option includeShadowDom for enabling shadow DOM.

In cypress.json set

{
  "includeShadowDom": true
}

Then in your test select for example the login input field:
cy.get('[data-test="sign-in-username-input"]').first().type("DUMMY_USERNAME");

This works, not sure why the first() is necessary though.

1reaction
jordanranzcommented, Aug 24, 2020

Hey @dfang, Cypress does now support shadow dom in their Experiments section

cy.get('amplify-authenticator')
  .shadow()
  .get('amplify-sign-in')...

Could you try using this and report back?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Amazon Cognito Authentication - Cypress Documentation
What you'll learn Log in to Amazon Cognito through the UI with cy.origin() Programmatically authenticate with Amazon Cognito via a custom Cypress command....
Read more >
How can I test AWS Amplify Angular Authenticator component ...
I want to be able to "type" testing input into the AWS Amplify Authenticator component (amplify-authenticator) in a cypress test like this:
Read more >
Use Cypress to test AWS Amplify Apps with Authentication
Use Cypress to test AWS Amplify Apps with Authentication · We use the amplify Auth class to create a session for our user....
Read more >
Amplify continuous integration/deployment with end-to-end tests
A tutorial for building and deploying an amplify app with cypress tests built into the deployment pipeline.
Read more >
AWS Amplify: code lint & end-to-end testing with Cypress
The web application I created with AWS Amplify includes a React ... the AWS Amplify Cognito authentication backend and its UI components.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found