Cypress Reactjs Application testing (MSAL) issue

27 views Asked by At

I'm new to both Cypress and Azure AD, I have created a testcase using Cypress for an existing Reactjs application. In it Microsoft Authentication Library is used in which while running login testcase I am getting an exception "(uncaught exception)ClientAuthError: Token renewal operation failed due to timeout." due to which I am unable to login and redirected back to login page. I want to skip or bypass MSAL Authentication to test other modules.

describe("bypass login", () => {
     beforeEach(()=>{
         cy.intercept('POST', 'https://login.microsoftonline.com/*', (req) => {
            req.reply({
                statusCode: 200,
                 body: 'Successfully authenticated with Microsoft',
             })
         }).as('microsoftAuth');
     });
     it('should perform test without Microsoft auth', () => {
         cy.visit('http://localhost:3000')
         cy.get('.button-user').should('exist').click()
         
         cy.origin('https://login.microsoftonline.com/*', () => {
              cy.visit('http://localhost:3000/feedstock-overview')
         })
})

Here is the code of testcase which is for skipping authentication while testing. Exception is raised after "(xhr)GET 200 https://login.microsoftonline.com/id/v2.0/.well-known/openid-configuration" this url.

0

There are 0 answers