1- import { screen } from '@testing-library/react' ;
1+ import { screen , waitFor } from '@testing-library/react' ;
22import userEvent from '@testing-library/user-event' ;
33
44import { renderWithAppContext } from '../__helpers__/test-utils' ;
@@ -107,9 +107,11 @@ describe('renderer/routes/LoginWithPersonalAccessToken.tsx', () => {
107107
108108 await userEvent . click ( screen . getByTestId ( 'login-submit' ) ) ;
109109
110- expect ( loginWithPersonalAccessTokenMock ) . toHaveBeenCalledTimes ( 1 ) ;
111- expect ( navigateMock ) . toHaveBeenCalledTimes ( 1 ) ;
112- expect ( navigateMock ) . toHaveBeenCalledWith ( - 1 ) ;
110+ await waitFor ( ( ) => {
111+ expect ( loginWithPersonalAccessTokenMock ) . toHaveBeenCalledTimes ( 1 ) ;
112+ expect ( navigateMock ) . toHaveBeenCalledTimes ( 1 ) ;
113+ expect ( navigateMock ) . toHaveBeenCalledWith ( - 1 ) ;
114+ } ) ;
113115 } ) ;
114116
115117 it ( 'should login using a token - failure' , async ( ) => {
@@ -133,9 +135,11 @@ describe('renderer/routes/LoginWithPersonalAccessToken.tsx', () => {
133135
134136 await userEvent . click ( screen . getByTestId ( 'login-submit' ) ) ;
135137
136- expect ( loginWithPersonalAccessTokenMock ) . toHaveBeenCalledTimes ( 1 ) ;
137- expect ( navigateMock ) . toHaveBeenCalledTimes ( 0 ) ;
138- expect ( rendererLogErrorSpy ) . toHaveBeenCalledTimes ( 1 ) ;
138+ await waitFor ( ( ) => {
139+ expect ( loginWithPersonalAccessTokenMock ) . toHaveBeenCalledTimes ( 1 ) ;
140+ expect ( navigateMock ) . toHaveBeenCalledTimes ( 0 ) ;
141+ expect ( rendererLogErrorSpy ) . toHaveBeenCalledTimes ( 1 ) ;
142+ } ) ;
139143 } ) ;
140144
141145 it ( 'should render the form with errors' , async ( ) => {
0 commit comments