cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.71k stars 3.16k forks source link

Cypress misses redirect/XHR GET despite interceptor #27590

Closed plweil closed 9 months ago

plweil commented 1 year ago

Current behavior

I'm testing a form in a Laravel/Vue/Inertia application that can select from a list of users. The form adds a new user (an XHR post) to the database. The Laravel controller then redirects back to the form (an XHR GET). The form's user menu now contains the updated list of users.

This works manually. But when I test in Cypress, it fails. I set up an interceptor for each XHR request. But even though the redirect occurs, the second XHR request (the one aliased as "@loadPage") is still spinning around in the Cypress spec window. It's as if Cypress is just plain missing the redirect.

Desired behavior

Cypress should obey the second interceptor, wait for and recognize the redirect (XHR GET), and then "see" the updated content on the page.

To reproduce this, I have the following:

  1. A form in a Vue 3 component with a list of registered members in a select. The form links to a second form in a modal that allows you to add a new member to the database via Inertia's form helper

  2. The form helper submits the new user data, hits a Laravel UserController that adds the new user and redirects back to the page. The form on this page now contains the updated user data, which is detectable via cy.contains()

When this is done manually, everything works as intended

Test code to reproduce

cy.visit('/auth/project/create')

        .get('#add-new-leader')
        .should('be.visible')
        .click()

      cy.wait(500)

      cy.get('dialog').should('be.visible')

      cy.get('#first_name').type('John')

      cy.get('#last_name').type('Coltrane')

      cy.get('#email').type('coltrane@myfavoritethings.com')

      cy.get('#netid').type('trane')

      cy.intercept({ method: 'POST', url: '/auth/user' }).as('addUser')
      cy.intercept({ method: 'GET', url: '/auth/project/create' }).as(
        'loadPage'
      )

      cy.get('#add-user-form').submit()

      cy.wait('@addUser').then(interception => {
        console.log('request', interception.request)
        console.log('request', interception.response)
      })

      cy.wait('@loadPage').then(interception => {
        console.log('request', interception.request)
        console.log('request', interception.response)
      })

      cy.contains('New user')

      cy.contains('Coltrane')

Cypress Version

12.17.2

Node version

16.20.1

Operating System

macOS 12.6.8

Debug Logs

Logs were too long to submit issue
-------------------------
  cypress:server:remote-states getting primary remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +0ms
GET /resources/images/envelope.svg 200 8.542 ms - -
GET /node_modules/.vite/deps/vue.js.map 200 519.404 ms - -
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +4ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +1ms
GET /node_modules/.vite/deps/chunk-2DAHQA63.js.map 200 517.194 ms - -
  cypress:server:request received status code & headers on request { requestId: 'request49', statusCode: 200, headers: { 'content-type': 'application/json' } } +8ms
  cypress:server:request successful response received { requestId: 'request49' } +0ms
  cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: '/node_modules/.vite/deps/chunk-U7YWGX7N.js.map' }, request: undefined } +7ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +2ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +7ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:server:remote-states getting primary remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +0ms
GET /node_modules/.vite/deps/lodash.js.map 200 518.931 ms - -
GET /node_modules/.vite/deps/chunk-U7YWGX7N.js.map 200 525.900 ms - -
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +488ms
  cypress:server:remote-states getting remote state: undefined for: http://127.0.0.1:5173/node_modules/.vite/deps/@inertiajs_vue3.js.map +488ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +0ms
  cypress:server:stream_buffer stream buffer writeable final called +502ms
  cypress:network:agent addRequest called { isHttps: false, href: 'http://127.0.0.1:5173/node_modules/.vite/deps/@inertiajs_vue3.js.map' } +502ms
  cypress:network:agent got family { family: 4, href: 'http://127.0.0.1:5173/node_modules/.vite/deps/@inertiajs_vue3.js.map' } +0ms
  cypress:server:request received status code & headers on request { requestId: 'request51', statusCode: 200, headers: { 'content-type': 'application/json' } } +494ms
  cypress:server:request successful response received { requestId: 'request51' } +0ms
  cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: '/node_modules/.vite/deps/@inertiajs_vue3.js.map' }, request: undefined } +494ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +7ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +7ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:server:remote-states getting primary remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +2ms
  cypress:server:remote-states getting remote state: undefined for: http://127.0.0.1:5173/node_modules/.vite/deps/laravel-vite-plugin_inertia-helpers.js.map +2ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +0ms
  cypress:server:stream_buffer stream buffer writeable final called +9ms
  cypress:network:agent addRequest called { isHttps: false, href: 'http://127.0.0.1:5173/node_modules/.vite/deps/laravel-vite-plugin_inertia-helpers.js.map' } +9ms
  cypress:network:agent got family { family: 4, href: 'http://127.0.0.1:5173/node_modules/.vite/deps/laravel-vite-plugin_inertia-helpers.js.map' } +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:server:remote-states getting remote state: undefined for: http://127.0.0.1:5173/node_modules/.vite/deps/uuid.js.map +1ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +1ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +0ms
  cypress:server:stream_buffer stream buffer writeable final called +1ms
  cypress:network:agent addRequest called { isHttps: false, href: 'http://127.0.0.1:5173/node_modules/.vite/deps/uuid.js.map' } +1ms
  cypress:network:agent got family { family: 4, href: 'http://127.0.0.1:5173/node_modules/.vite/deps/uuid.js.map' } +0ms
  cypress:server:request received status code & headers on request { requestId: 'request52', statusCode: 200, headers: { 'content-type': 'application/json' } } +4ms
  cypress:server:request successful response received { requestId: 'request52' } +0ms
  cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: '/node_modules/.vite/deps/laravel-vite-plugin_inertia-helpers.js.map' }, request: undefined } +4ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +1ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +1ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:server:remote-states getting primary remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +0ms
  cypress:server:request received status code & headers on request { requestId: 'request53', statusCode: 200, headers: { 'content-type': 'application/json' } } +1ms
  cypress:server:request successful response received { requestId: 'request53' } +0ms
  cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: '/node_modules/.vite/deps/uuid.js.map' }, request: undefined } +1ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:server:remote-states getting primary remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } +1ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +1ms
  cypress:network:cors Parsed URL { port: '5173', protocol: 'http:', subdomain: null, domain: '', tld: '127.0.0.1' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +0ms
GET /node_modules/.vite/deps/laravel-vite-plugin_inertia-helpers.js.map 200 502.450 ms - -
GET /node_modules/.vite/deps/uuid.js.map 200 502.492 ms - -
GET /node_modules/.vite/deps/@inertiajs_vue3.js.map 200 508.384 ms - -
  cypress:server:socket-base backend:request { eventName: 'net', args: [ 'route:added', { routeId: '1692363264475-48', hasInterceptor: false, routeMatcher: [Object] } ] } +2s
  cypress:net-stubbing:server:driver-events received driver event { eventName: 'route:added', args: [ 'route:added', { routeId: '1692363264475-48', hasInterceptor: false, routeMatcher: [Object] } ] } +0ms
  cypress:server:socket-base backend:request { eventName: 'net', args: [ 'route:added', { routeId: '1692363264483-49', hasInterceptor: false, routeMatcher: [Object] } ] } +8ms
  cypress:net-stubbing:server:driver-events received driver event { eventName: 'route:added', args: [ 'route:added', { routeId: '1692363264483-49', hasInterceptor: false, routeMatcher: [Object] } ] } +7ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +1s
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:net-stubbing:server:util sending event to driver { eventName: 'before:request', data: { eventId: 'event55', subscription: { eventName: 'before:request', await: false, routeId: '1692363264475-48' }, browserRequestId: '90257.202', requestId: 'interceptedRequest54', data: { headers: [Object], url: 'http://widea-editor.test/auth/user', method: 'POST', httpVersion: '1.1', resourceType: 'xhr', query: {}, body: '{"project_id":null,"first_name":"John","last_name":"Coltrane","middle_initial":"","email":"coltrane@myfavoritethings.com","netid":"trane","title":""}' } } } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +4ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test/auth/user +1s
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +0ms
  cypress:network:agent addRequest called { isHttps: false, href: 'http://widea-editor.test/auth/user' } +1s
  cypress:network:agent got family { family: 4, href: 'http://widea-editor.test/auth/user' } +0ms
GET /__cypress/runner/fonts/fa-solid-900.woff2 200 0.634 ms - 126828
  cypress:server:request received status code & headers on request { requestId: 'request56', statusCode: 302, headers: { 'content-type': 'text/html; charset=UTF-8', 'set-cookie': [ 'widb_editor=eyJpdiI6IkloYlpONlJxblM2T3J2SkFvZGQ0R3c9PSIsInZhbHVlIjoia2UvYTk2aFRKc2xJYVZaTVIydHVSM2l5M0t6V0V6L2lra1Q5VXdqajhncDYwSnhaTWFaVkNEMHRZeXVUNGxSdVREZk5aaTZRN1NvcVlHWDFKZlBvdll3OEtQS0RsZWVYQ3o2WFd4UUhxY281Q1BySTRnNDg0dVlPbmpkSnM5RzEiLCJtYWMiOiIwNDc2ODc2ZDQyNmNkNTUzODM0NDI4Mjc2YmEyYTU2OGJjMjE3MTI1OGMyYzRjYjI3MWMwMWI3YWQ0NzgyMzFiIiwidGFnIjoiIn0%3D; expires=Fri, 18 Aug 2023 14:54:24 GMT; Max-Age=7200; path=/; domain=widea-editor.test; httponly; samesite=lax' ], location: 'http://widea-editor.test/auth/project/create' } } +1s
  cypress:server:request successful response received { requestId: 'request56' } +0ms
  cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: 'http://widea-editor.test/auth/user' }, request: a { subscriptionsByRoute: [ [Object] ], includeBodyInAfterResponse: false, responseSent: false, onResponse: [Function (anonymous)], id: 'interceptedRequest54', req: IncomingMessage { _readableState: [ReadableState], _events: [Object: null prototype], _eventsCount: 1, _maxListeners: undefined, socket: [Socket], httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', complete: true, rawHeaders: [Array], rawTrailers: [], aborted: false, upgrade: false, url: 'http://widea-editor.test/auth/user', method: 'POST', statusCode: null, statusMessage: null, client: [Socket], _consuming: true, _dumped: false, proxiedUrl: 'http://widea-editor.test/auth/user', next: [Function: h], baseUrl: '', originalUrl: '/auth/user', _parsedUrl: [Url], params: [Object], query: {}, res: [ServerResponse], secret: undefined, cookies: [Object], signedCookies: [Object: null prototype] {}, _startAt: [Array], _startTime: 2023-08-18T12:54:24.510Z, _remoteAddress: '127.0.0.1', route: [p], isAUTFrame: false, browserPreRequest: [Object], resourceType: 'xhr', matchingRoutes: [Array], requestId: 'interceptedRequest54', body: '{"project_id":null,"first_name":"John","last_name":"Coltrane","middle_initial":"","email":"coltrane@myfavoritethings.com","netid":"trane","title":""}', [Symbol(kCapture)]: false, [Symbol(kHeaders)]: [Object], [Symbol(kHeadersCount)]: 34, [Symbol(kTrailers)]: null, [Symbol(kTrailersCount)]: 0, [Symbol(RequestTimeout)]: undefined }, res: ServerResponse { _events: [Object: null prototype], _eventsCount: 3, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: false, _last: false, chunkedEncoding: false, shouldKeepAlive: true, maxRequestsOnConnectionReached: false, _defaultKeepAlive: true, useChunkedEncodingByDefault: true, sendDate: true, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: false, _headerSent: false, _closed: false, socket: [Socket], _header: null, _keepAliveTimeout: 5000, _onPendingData: [Function: bound updateOutgoingData], req: [IncomingMessage], _sent100: false, _expect_continue: false, locals: [Object: null prototype] {}, flush: [Function (anonymous)], write: [Function (anonymous)], end: [Function (anonymous)], on: [Function (anonymous)], writeHead: [Function (anonymous)], _startAt: undefined, _startTime: undefined, __onFinished: [Function], [Symbol(kCapture)]: false, [Symbol(kNeedDrain)]: false, [Symbol(corked)]: 0, [Symbol(kOutHeaders)]: null }, continueRequest: [Function: next], onError: [Function: _], _onResponse: [Function: onResponse], state: { requests: [Object], routes: [Array], pendingEventHandlers: {}, reset: [Function: reset] }, socket: p { ensureProp: [Function: d], inRunMode: false, supportsRunEvents: false, ended: false, localBus: [EventEmitter], onTestFileChange: [Function: bound ], testFilePath: 'cypress/e2e/users/project-create.cy.js', onStudioTestFileChange: [Function: bound onStudioTestFileChange], removeOnStudioTestFileChange: [Function: bound removeOnStudioTestFileChange], _io: [u], _sendResetBrowserTabsForNextTestMessage: [AsyncFunction (anonymous)], _sendResetBrowserStateMessage: [AsyncFunction (anonymous)], _sendFocusBrowserMessage: [AsyncFunction (anonymous)], _isRunnerSocketConnected: [Function (anonymous)] }, lastEvent: 'before:request' } } +1s
  cypress:net-stubbing:server:util sending event to driver { eventName: 'response:callback', data: { eventId: 'event57', subscription: { eventName: 'response:callback', await: false, routeId: '1692363264475-48' }, browserRequestId: '90257.202', requestId: 'interceptedRequest54', data: { headers: [Object], url: 'http://widea-editor.test/auth/user', method: null, httpVersion: '1.1', statusCode: 302, statusMessage: 'Found', body: '<!DOCTYPE html>\n' + '<html>\n' + '    <head>\n' + '        <meta charset="UTF-8" />\n' + `        <meta http-equiv="refresh" content="0;url='http://widea-editor.test/auth/project/create'" />\n` + '\n' + '        <title>Redirecting to http://widea-editor.test/auth/project/create</title>\n' + '    </head>\n' + '    <body>\n' + '        Redirecting to <a href="http://widea-editor.test/auth/project/create">http://widea-editor.test/auth/project/create</a>.\n' + '    </body>\n' + '</html>' } } } +44ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +44ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +44ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting primary remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +0ms
POST /auth/user 302 49.206 ms - 132
  cypress:net-stubbing:server:util sending event to driver { eventName: 'after:response', data: { eventId: 'event58', subscription: { eventName: 'after:response', await: false, routeId: '1692363264475-48' }, browserRequestId: '90257.202', requestId: 'interceptedRequest54', data: {} } } +2ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +10ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:net-stubbing:server:util sending event to driver { eventName: 'before:request', data: { eventId: 'event60', subscription: { eventName: 'before:request', await: false, routeId: '1692363264483-49' }, browserRequestId: '90257.202', requestId: 'interceptedRequest59', data: { headers: [Object], url: 'http://widea-editor.test/auth/project/create', method: 'GET', httpVersion: '1.1', resourceType: 'xhr', query: {}, body: '' } } } +10ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +1ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test/auth/project/create +11ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +0ms
  cypress:server:stream_buffer stream buffer writeable final called +1s
  cypress:network:agent addRequest called { isHttps: false, href: 'http://widea-editor.test/auth/project/create' } +56ms
  cypress:network:agent got family { family: 4, href: 'http://widea-editor.test/auth/project/create' } +0ms
  cypress:server:request received status code & headers on request { requestId: 'request61', statusCode: 200, headers: { 'content-type': 'application/json', 'set-cookie': [ 'widb_editor=eyJpdiI6IkJZU2NEZ3BQTUxWbWV5ZHRBbGtIc0E9PSIsInZhbHVlIjoielBMcE54c1QzMVNpR2tGckhxeTZJdjFMTDErUlMzU1hDbFNKVWpGU0I1TDhBN3ovYkVaWDQ0ZGJ3YkxDZUhTT1ErOFZuK2NiWTdST09MZFpFR3BBNUdvUU05eXZ6OHNjNUhvc3VSTW5QTEFlODRZOWNoeDN1a1VrS2ZJV2tUY0MiLCJtYWMiOiIxNjQwMzU2MTk0OTNlNGViMmJjNjBmNzczMjI1NjM2ZTkxZmQwZTQ0ZWZlMjExZjBiZTc4NjkxMWM2NDllZGM1IiwidGFnIjoiIn0%3D; expires=Fri, 18 Aug 2023 14:54:24 GMT; Max-Age=7200; path=/; domain=widea-editor.test; httponly; samesite=lax' ] } } +35ms
  cypress:server:request successful response received { requestId: 'request61' } +0ms
  cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: 'http://widea-editor.test/auth/project/create' }, request: a { subscriptionsByRoute: [ [Object] ], includeBodyInAfterResponse: false, responseSent: false, onResponse: [Function (anonymous)], id: 'interceptedRequest59', req: IncomingMessage { _readableState: [ReadableState], _events: [Object: null prototype], _eventsCount: 1, _maxListeners: undefined, socket: [Socket], httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', complete: true, rawHeaders: [Array], rawTrailers: [], aborted: false, upgrade: false, url: 'http://widea-editor.test/auth/project/create', method: 'GET', statusCode: null, statusMessage: null, client: [Socket], _consuming: false, _dumped: false, proxiedUrl: 'http://widea-editor.test/auth/project/create', next: [Function: h], baseUrl: '', originalUrl: '/auth/project/create', _parsedUrl: [Url], params: [Object], query: {}, res: [ServerResponse], secret: undefined, cookies: [Object], signedCookies: [Object: null prototype] {}, _startAt: [Array], _startTime: 2023-08-18T12:54:24.568Z, _remoteAddress: '127.0.0.1', route: [p], isAUTFrame: false, browserPreRequest: [Object], resourceType: 'xhr', matchingRoutes: [Array], requestId: 'interceptedRequest59', body: '', [Symbol(kCapture)]: false, [Symbol(kHeaders)]: [Object], [Symbol(kHeadersCount)]: 28, [Symbol(kTrailers)]: null, [Symbol(kTrailersCount)]: 0, [Symbol(RequestTimeout)]: undefined }, res: ServerResponse { _events: [Object: null prototype], _eventsCount: 3, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: false, _last: false, chunkedEncoding: false, shouldKeepAlive: true, maxRequestsOnConnectionReached: false, _defaultKeepAlive: true, useChunkedEncodingByDefault: true, sendDate: true, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: false, _headerSent: false, _closed: false, socket: [Socket], _header: null, _keepAliveTimeout: 5000, _onPendingData: [Function: bound updateOutgoingData], req: [IncomingMessage], _sent100: false, _expect_continue: false, locals: [Object: null prototype] {}, flush: [Function (anonymous)], write: [Function (anonymous)], end: [Function (anonymous)], on: [Function (anonymous)], writeHead: [Function (anonymous)], _startAt: undefined, _startTime: undefined, __onFinished: [Function], [Symbol(kCapture)]: false, [Symbol(kNeedDrain)]: false, [Symbol(corked)]: 0, [Symbol(kOutHeaders)]: null }, continueRequest: [Function: next], onError: [Function: _], _onResponse: [Function: onResponse], state: { requests: [Object], routes: [Array], pendingEventHandlers: {}, reset: [Function: reset] }, socket: p { ensureProp: [Function: d], inRunMode: false, supportsRunEvents: false, ended: false, localBus: [EventEmitter], onTestFileChange: [Function: bound ], testFilePath: 'cypress/e2e/users/project-create.cy.js', onStudioTestFileChange: [Function: bound onStudioTestFileChange], removeOnStudioTestFileChange: [Function: bound removeOnStudioTestFileChange], _io: [u], _sendResetBrowserTabsForNextTestMessage: [AsyncFunction (anonymous)], _sendResetBrowserStateMessage: [AsyncFunction (anonymous)], _sendFocusBrowserMessage: [AsyncFunction (anonymous)], _isRunnerSocketConnected: [Function (anonymous)] }, lastEvent: 'before:request' } } +34ms
  cypress:net-stubbing:server:util sending event to driver { eventName: 'response:callback', data: { eventId: 'event62', subscription: { eventName: 'response:callback', await: false, routeId: '1692363264483-49' }, browserRequestId: '90257.202', requestId: 'interceptedRequest59', data: { headers: [Object], url: 'http://widea-editor.test/auth/project/create', method: null, httpVersion: '1.1', statusCode: 200, statusMessage: 'OK', body: '{"component":"Projects\\/Create","props":{"users":[{"id":2,"first_name":"Wendy","last_name":"Aaaaa","name":"Wendy Aaaaa","lastfirst":"Aaaaa, Wendy"},{"id":9,"first_name":"Chanelle","last_name":"Bailey","name":"Chanelle Bailey","lastfirst":"Bailey, Chanelle"},{"id":10,"first_name":"Valentina","last_name":"Baumbach","name":"Valentina Baumbach","lastfirst":"Baumbach, Valentina"},{"id":3,"first_name":"Wendy","last_name":"Bbbbb","name":"Wendy Bbbbb","lastfirst":"Bbbbb, Wendy"},{"id":11,"first_name":"Janessa","last_name":"Bosco","name":"Janessa Bosco","lastfirst":"Bosco, Janessa"},{"id":18,"first_name":"Clair","last_name":"Carter","name":"Clair Carter","lastfirst":"Carter, Clair"},{"id":8,"first_name":"Vincent","last_name":"Dickens","name":"Vincent Dickens","lastfirst":"Dickens, Vincent"},{"id":20,"first_name":"Jonathon","last_name":"Dietrich","name":"Jonathon Dietrich","lastfirst":"Dietrich, Jonathon"},{"id":22,"first_name":"Mitchell","last_name":"Feeney","name":"Mitchell Feeney","lastfirst":"Feeney, Mitchell"},{"id":12,"first_name":"Erling","last_name":"Gislason","name":"Erling Gislason","lastfirst":"Gislason, Erling"},{"id":17,"first_name":"Alvis","last_name":"Hayes","name":"Alvis Hayes","lastfirst":"Hayes, Alvis"},{"id":7,"first_name":"Felix","last_name":"Hessel","name":"Felix Hessel","lastfirst":"Hessel, Felix"},{"id":24,"first_name":"Foster","last_name":"Jaskolski","name":"Foster Jaskolski","lastfirst":"Jaskolski, Foster"},{"id":1,"first_name":"Thelonious","last_name":"Monk","name":"Thelonious Monk","lastfirst":"Monk, Thelonious","netid":"projecteditor"},{"id":23,"first_name":"Ova","last_name":"Ondricka","name":"Ova Ondricka","lastfirst":"Ondricka, Ova"},{"id":4,"first_name":"Bebe","last_name":"Rebozo","name":"Bebe Rebozo","lastfirst":"Rebozo, Bebe"},{"id":5,"first_name":"Shana","last_name":"Runolfsdottir","name":"Shana Runolfsdottir","lastfirst":"Runolfsdottir, Shana"},{"id":6,"first_name":"Jarrod","last_name":"Russel","name":"Jarrod Russel","lastfirst":"Russel, Jarrod"},{"id":14,"first_name":"Lexus","last_name":"Spinka","name":"Lexus Spinka","lastfirst":"Spinka, Lexus"},{"id":16,"first_name":"Elvis","last_name":"Spinka","name":"Elvis Spinka","lastfirst":"Spinka, Elvis"},{"id":15,"first_name":"Sandy","last_name":"Stracke","name":"Sandy Stracke","lastfirst":"Stracke, Sandy"},{"id":13,"first_name":"Dennis","last_name":"Swaniawski","name":"Dennis Swaniawski","lastfirst":"Swaniawski, Dennis"},{"id":21,"first_name":"Adam","last_name":"Wiegand","name":"Adam Wiegand","lastfirst":"Wiegand, Adam"},{"id":19,"first_name":"Isidro","last_name":"Wunsch","name":"Isidro Wunsch","lastfirst":"Wunsch, Isidro"}]},"url":"\\/auth\\/project\\/create","version":"78ea0ff778ae4f0ca683dd53e153a78f"}' } } } +23ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +24ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +24ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting primary remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:network:cors Parsed URL { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } +0ms
  cypress:server:remote-states getting remote state: { auth: null, origin: 'http://widea-editor.test', strategy: 'http', fileServer: null, domainName: 'widea-editor.test', props: { port: '80', protocol: 'http:', subdomain: null, domain: 'widea-editor', tld: 'test' } } for: http://widea-editor.test +0ms
GET /auth/project/create 200 25.598 ms - -
  cypress:net-stubbing:server:util sending event to driver { eventName: 'after:response', data: { eventId: 'event63', subscription: { eventName: 'after:response', await: false, routeId: '1692363264483-49' }, browserRequestId: '90257.202', requestId: 'interceptedRequest59', data: {} } } +2ms
  cypress:server:util:process_profiler current & mean memory and CPU usage by process group:
  cypress:server:util:process_profiler ┌─────────┬───────────────────┬──────────────┬────────────────┬────────────┬────────────────┬──────────┬──────────────┬─────────────┐
  cypress:server:util:process_profiler │ (index) │       group       │ processCount │      pids      │ cpuPercent │ meanCpuPercent │ memRssMb │ meanMemRssMb │ maxMemRssMb │
  cypress:server:util:process_profiler ├─────────┼───────────────────┼──────────────┼────────────────┼────────────┼────────────────┼──────────┼──────────────┼─────────────┤
  cypress:server:util:process_profiler │    0    │    'Electron'     │      1       │    '90257'     │    61.2    │     31.95      │  831.31  │    786.95    │   831.31    │
  cypress:server:util:process_profiler │    1    │     'cypress'     │      1       │    '89265'     │     0      │       24       │  369.02  │    354.46    │   385.98    │
  cypress:server:util:process_profiler │    2    │    'launchpad'    │      2       │ '90256, 89482' │     0      │     14.23      │  325.41  │    315.05    │   325.41    │
  cypress:server:util:process_profiler │    3    │     'plugin'      │      1       │    '89279'     │    0.7     │      2.53      │  164.34  │    178.59    │   260.42    │
  cypress:server:util:process_profiler │    4    │ 'electron-shared' │      2       │ '89267, 89481' │    5.6     │      5.45      │  100.2   │    76.11     │   103.16    │
  cypress:server:util:process_profiler │    5    │      'other'      │      1       │    '91612'     │     0      │      2.4       │   2.28   │     6.65     │    19.2     │
  cypress:server:util:process_profiler │    6    │      'TOTAL'      │      8       │      '-'       │    67.5    │      60.4      │ 1792.56  │   1200.93    │   1792.56   │
  cypress:server:util:process_profiler └─────────┴───────────────────┴──────────────┴────────────────┴────────────┴────────────────┴──────────┴──────────────┴─────────────┘ +10s
  cypress:server:util:process_profiler current & mean memory and CPU usage by process group:

Other

If there is some other way to catch the redirect other than the interceptor I am using, I'd love to know what it is.

nagash77 commented 1 year ago

Hi @plweil unfortunately we will not be able to replicate your component in order to replicate this behavior and so I do not see a way forward on further investigation. Have you taken any steps to simplify the test to verify you can intercept the second call when that is the only call being intercepted?

I would suggest you check out the Cypress Discord Community Discord chat, it can be helpful for debugging or answering questions on how to use Cypress.

plweil commented 1 year ago

Hi @nagash77 Simplifying the test as you suggested does not change anything. Cypress still cannot intercept that XHR GET request.

Am I telling Cypress to wait for this request properly? Or, barring something really unusual or unexpected about this app, shouldn't it work as written? I don't think this is Vue- or component-specific. It's just a XHR redirect from Laravel. Surely you don't need to replicate exactly all of the different apps and components people are using(?)

Or, to put the question somewhat differently, theoretically, what could prevent Cypress from catching the redirect?

jennifer-shehane commented 9 months ago

@plweil It’s not obvious what would prevent it from being intercepted in this case. That’s why we would need some way to run and see the behavior to track down what makes your case different. The code looks like it should work if ththere is an XHR that matches.