I'm actually able to test the login of my app in Cypress by going through all the form, entering the username, password and clicking on the login button.
This set the token in my browser in the (Application) IndexedDB - ngStorage - localStorage section. Because I'm using the @ngx-pwa/local-storage plugin.
Then Cypress is able to go on the home page of my App.
But how to set the token in the browser, without using the UI?
I try to use localForage plugin but it set the token in the localForage section of my browser. And my app is not able to read my token.
I try to use window.localStorage.setItem('token', myToken); but it set the token in the localStorage of my browser.
How can I set my token in the good location: (Application) IndexedDB - ngStorage - localStorage
I've not found the solution, though the plugin
@ngx-pwa/local-storageis used by many people programming in Angular.I don't know if there is a better and cleaner solution than this one.
I used
window.cypress/support/window-helper.ts
cypress/support/commands.ts
cypress/support/index.ts
use in spec file
This subject help me: link
Thanks to rajd90