https://cypress.io logo
<@715580668045951047> - I agree that the cypress ...
# e2e-testing
g
@gray-kilobyte-89541 - I agree that the cypress test is updating a different window instance to what the svelte app is running in. Used https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/logging-in__single-sign-on/cypress/e2e/logging-in-single-sign-on-spec.cy.js as a guide, I used the follwoing code cy.request('POST', Cypress.env('api')+'users/login', { email: "johnny@email.com", password: "12345678" }).its('body').then((body) => { cy.window().then(win =>{ cy.visit(
/
, { onBeforeLoad(win) { win.authorised =true win.emailName = "johnny@email.com" win.fred = "Johnny" win.authToken = body.token win.userId = body.userId }, }) }) cy.get('h1').should('contain', 'Svelte To-Do List') }) Now running this works and in the svelte app, I have some console logging and that shows what I expected / hoped. Do I need the cy.window? Or can I just use the visit with onBeforeLoad? Many thanks for this - though being able to authenticate with request is not an essential (the time saving is minimal), this has been frustrating me for a while.