amplify-ui: Error message being raised by amplyfy authenticate v6 in cypress tests - not in production
Before creating a new issue, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have tried disabling all browser extensions or using a different browser
- I have tried deleting the node_modules folder and reinstalling my dependencies
- I have read the guide for submitting bug reports.
On which framework/platform are you having an issue?
Vue
Which UI component?
Authenticator
How is your app built?
Vite
What browsers are you seeing the problem on?
Chrome
Which region are you seeing the problem in?
cognito-idp.ap-southeast-2.amazonaws.com
Please describe your bug.
Trying to update an integration test running with cypress.io. This test worked with Amplify V5, but pops up a dialog in the browser saying “Unknown error occurred.”, and provides no other information in the console; no stack trace. This error is raised after the first POST request is sent from the browser to AWS Cognito for authentication. This application works outside of cypress. I notice one difference that outside of cypress the protocol is using http/2.0, while cypress is using http/1.1 - I don’t know whether this is relevant. I realise that this error is specific to using cypress, but the failure is inside the Amplify library code. Any ideas gratefully accepted. Thanks for reading. @aws-amplify/ui-vue: 4.2.0; vue: 3.4.18; aws-amplify: 6.0.16; cypress/vue: 5.0.5; cypress: 13.6.4; chrome: 121.0.6167.139.
What’s the expected behaviour?
I expect the login to succeed without throwing an unknown error in the amplify code, like it did with v5.
Help us reproduce the bug!
The following code snippet show how the Amplify code is integrated with the application. Followed by a cutdown version of the test that fails.
Again, I know this is a failure in testing, but the failure appears to be happening in the amplify code.
Code Snippet
Integration of Amplify
import {getCurrentUser, fetchAuthSession} from 'aws-amplify/auth';
import {AuthUser} from 'aws-amplify/auth/cognito';
export const getAuthUser = async (): Promise<AuthUser | undefined> => {
return await getCurrentUser().catch(() => undefined);
};
export const getAuthToken = async (): Promise<string | undefined> => {
return await fetchAuthSession().then((authSession) => authSession.tokens?.idToken?.toString()).catch(() => undefined);
};
Cypress test
describe('Login Smoke Tests', () => {
it('allows login, logout, login, then navigation across navigation items.', () => {
cy.intercept('GET', '/').as('landing-page');
cy.intercept('GET', '/dashboard/home').as('dashboard-home');
cy.visit('/');
cy.wait('@landing-page');
cy.get('input.amplify-input[name="username"]').type(Cypress.env('ADMIN_TEST_USER_ONE_USERNAME'));
cy.get('input.amplify-input[name="password"]').type(Cypress.env('ADMIN_TEST_USER_ONE_PASSWORD'), {force: true});
cy.get('button.amplify-button--primary').click();
cy.wait('@dashboard-home');
cy.get('h1').contains('Dashboard');
});
});
Console log output
There is no console log output.
Additional information and screenshots
No response
About this issue
- Original URL
- State: open
- Created 4 months ago
- Comments: 15 (8 by maintainers)
@reesscot I’m deliberately not trying to mock anything in this test. It’s aimed at being a smoke test for the deployed application, so it’s meant to run just as it does for end-users. The endpoint for the test is the same as the endpoint that is used in the manual run of the website in the video. The only difference between the two interactions is that Cypress is doing the clickety-clinking, and not me in the automated test.
Watching your video, one thing that comes to mind is you may not be inspecting the right window. I believe that Cypress runs your tests in an iframe, so you should see if you can make devtools target the iframe and maybe you’ll see the full error message.