diff --git a/packages/driver/cypress.config.ts b/packages/driver/cypress.config.ts index c1002a5d24f9..12f6a552ed72 100644 --- a/packages/driver/cypress.config.ts +++ b/packages/driver/cypress.config.ts @@ -22,6 +22,15 @@ export default defineConfig({ experimentalOriginDependencies: true, experimentalModifyObstructiveThirdPartyCode: true, setupNodeEvents: (on, config) => { + on('task', { + log (message) { + // eslint-disable-next-line no-console + console.log(message) + + return null + }, + }) + return require('./cypress/plugins')(on, config) }, baseUrl: 'http://localhost:3500', diff --git a/packages/driver/cypress/e2e/commands/task.cy.js b/packages/driver/cypress/e2e/commands/task.cy.js index 75a670b97b3a..6fb8c672ea4e 100644 --- a/packages/driver/cypress/e2e/commands/task.cy.js +++ b/packages/driver/cypress/e2e/commands/task.cy.js @@ -234,7 +234,7 @@ describe('src/cy/commands/task', () => { expect(lastLog.get('error')).to.eq(err) expect(lastLog.get('state')).to.eq('failed') - expect(err.message).to.eq(`\`cy.task('bar')\` failed with the following error:\n\nThe task 'bar' was not handled in the setupNodeEvents method. The following tasks are registered: return:arg, return:foo, return:bar, return:baz, cypress:env, arg:is:undefined, wait, create:long:file, check:screenshot:size\n\nFix this in your setupNodeEvents method here:\n${Cypress.config('configFile')}`) + expect(err.message).to.eq(`\`cy.task('bar')\` failed with the following error:\n\nThe task 'bar' was not handled in the setupNodeEvents method. The following tasks are registered: log, return:arg, return:foo, return:bar, return:baz, cypress:env, arg:is:undefined, wait, create:long:file, check:screenshot:size\n\nFix this in your setupNodeEvents method here:\n${Cypress.config('configFile')}`) done() }) diff --git a/packages/driver/cypress/e2e/e2e/origin/snapshots.cy.ts b/packages/driver/cypress/e2e/e2e/origin/snapshots.cy.ts index 644487783710..8b798614d0bb 100644 --- a/packages/driver/cypress/e2e/e2e/origin/snapshots.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/snapshots.cy.ts @@ -66,63 +66,72 @@ describe('cy.origin - snapshots', { browser: '!webkit' }, () => { logs.set(attrs.id, log) }) + cy.task('log', 'beforeEach before visit') + cy.fixture('foo.bar.baz.json').then((fooBarBaz) => { + cy.task('log', 'beforeEach before intercept') + cy.intercept('GET', '/foo.bar.baz.json', { body: fooBarBaz }).as('fooBarBaz') }) + cy.task('log', 'beforeEach before visit') + cy.visit('/fixtures/primary-origin.html') + cy.task('log', 'beforeEach before get') + cy.get('a[data-cy="xhr-fetch-requests-onload"]').click() + cy.task('log', 'beforeEach after get') }) // TODO: fix failing test: https://github.com/cypress-io/cypress/issues/23840 - it.skip('verifies XHR requests made while a secondary origin is active eventually update with snapshots of the secondary origin', () => { - cy.origin('http://www.foobar.com:3500', () => { - // need to set isInteractive in the spec bridge in order to take xhr snapshots in run mode, similar to how isInteractive is set within support/defaults.js - // @ts-ignore - Cypress.config('isInteractive', true) - cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-requests.html') - cy.get(`[data-cy="assertion-header"]`).should('exist') - cy.wait('@fooBarBaz') - }) + // it.skip('verifies XHR requests made while a secondary origin is active eventually update with snapshots of the secondary origin', () => { + // cy.origin('http://www.foobar.com:3500', () => { + // // need to set isInteractive in the spec bridge in order to take xhr snapshots in run mode, similar to how isInteractive is set within support/defaults.js + // // @ts-ignore + // Cypress.config('isInteractive', true) + // cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-requests.html') + // cy.get(`[data-cy="assertion-header"]`).should('exist') + // cy.wait('@fooBarBaz') + // }) - cy.shouldWithTimeout(() => { - const xhrLogFromSecondaryOrigin = findLog(logs, 'xhr', 'http://localhost:3500/foo.bar.baz.json')?.get() + // cy.shouldWithTimeout(() => { + // const xhrLogFromSecondaryOrigin = findLog(logs, 'xhr', 'http://localhost:3500/foo.bar.baz.json')?.get() - expect(xhrLogFromSecondaryOrigin).to.exist + // expect(xhrLogFromSecondaryOrigin).to.exist - const snapshots = xhrLogFromSecondaryOrigin.snapshots.map((snapshot) => snapshot.body.get()[0]) + // const snapshots = xhrLogFromSecondaryOrigin.snapshots.map((snapshot) => snapshot.body.get()[0]) - expect(snapshots.length).to.equal(2) + // expect(snapshots.length).to.equal(2) - // TODO: Since we have two events, one of them does not have a request snapshot + // // TODO: Since we have two events, one of them does not have a request snapshot - expect(snapshots[1].querySelector(`[data-cy="assertion-header"]`)).to.have.property('innerText').that.equals('Making XHR and Fetch Requests behind the scenes if fireOnload is true!') - }) - }) + // expect(snapshots[1].querySelector(`[data-cy="assertion-header"]`)).to.have.property('innerText').that.equals('Making XHR and Fetch Requests behind the scenes if fireOnload is true!') + // }) + // }) - // TODO: fix failing test: https://github.com/cypress-io/cypress/issues/23840 - it.skip('verifies fetch requests made while a secondary origin is active eventually update with snapshots of the secondary origin', () => { - cy.origin('http://www.foobar.com:3500', () => { - // need to set isInteractive in the spec bridge in order to take xhr snapshots in run mode, similar to how isInteractive is set within support/defaults.js - // @ts-ignore - Cypress.config('isInteractive', true) - cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-requests.html') - cy.get(`[data-cy="assertion-header"]`).should('exist') - cy.wait('@fooBarBaz') - }) + // // TODO: fix failing test: https://github.com/cypress-io/cypress/issues/23840 + // it.skip('verifies fetch requests made while a secondary origin is active eventually update with snapshots of the secondary origin', () => { + // cy.origin('http://www.foobar.com:3500', () => { + // // need to set isInteractive in the spec bridge in order to take xhr snapshots in run mode, similar to how isInteractive is set within support/defaults.js + // // @ts-ignore + // Cypress.config('isInteractive', true) + // cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-requests.html') + // cy.get(`[data-cy="assertion-header"]`).should('exist') + // cy.wait('@fooBarBaz') + // }) - cy.shouldWithTimeout(() => { - const xhrLogFromSecondaryOrigin = findLog(logs, 'fetch', 'http://localhost:3500/foo.bar.baz.json')?.get() + // cy.shouldWithTimeout(() => { + // const xhrLogFromSecondaryOrigin = findLog(logs, 'fetch', 'http://localhost:3500/foo.bar.baz.json')?.get() - expect(xhrLogFromSecondaryOrigin).to.exist + // expect(xhrLogFromSecondaryOrigin).to.exist - const snapshots = xhrLogFromSecondaryOrigin.snapshots.map((snapshot) => snapshot.body.get()[0]) + // const snapshots = xhrLogFromSecondaryOrigin.snapshots.map((snapshot) => snapshot.body.get()[0]) - snapshots.forEach((snapshot) => { - expect(snapshot.querySelector(`[data-cy="assertion-header"]`)).to.have.property('innerText').that.equals('Making XHR and Fetch Requests behind the scenes if fireOnload is true!') - }) - }) - }) + // snapshots.forEach((snapshot) => { + // expect(snapshot.querySelector(`[data-cy="assertion-header"]`)).to.have.property('innerText').that.equals('Making XHR and Fetch Requests behind the scenes if fireOnload is true!') + // }) + // }) + // }) it('Does not take snapshots of XHR/fetch requests from secondary origin if the wrong origin is visited / origin mismatch, but instead the primary origin (existing behavior)', { defaultCommandTimeout: 50, @@ -142,16 +151,29 @@ describe('cy.origin - snapshots', { browser: '!webkit' }, () => { done() }) + cy.task('log', 'test before visit') + cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-requests.html') + cy.task('log', 'test after visit') + cy.origin('http://www.barbaz.com:3500', () => { // need to set isInteractive in the spec bridge in order to take xhr snapshots in run mode, similar to how isInteractive is set within support/defaults.js // @ts-ignore Cypress.config('isInteractive', true) + cy.task('log', 'test before get') + cy.get(`[data-cy="assertion-header"]`).should('exist') + + cy.task('log', 'test after get') + cy.wait('@fooBarBaz') + + cy.task('log', 'test after wait') }) + + cy.task('log', 'test after origin') }) }) }) diff --git a/packages/frontend-shared/cypress/support/e2e.ts b/packages/frontend-shared/cypress/support/e2e.ts index 5e8a3031ec51..cc236a177242 100644 --- a/packages/frontend-shared/cypress/support/e2e.ts +++ b/packages/frontend-shared/cypress/support/e2e.ts @@ -369,7 +369,9 @@ function visitLaunchpad () { return logInternal(`visitLaunchpad ${Cypress.env('e2e_launchpadPort')}`, () => { return cy.visit(`/__launchpad/index.html`, { log: false }).then((val) => { return cy.get('[data-e2e]', { timeout: 10000, log: false }).then(() => { - return val + return cy.get('.spinner', { timeout: 10000, log: false }).should('not.exist').then(() => { + return val + }) }) }) }) diff --git a/packages/launchpad/cypress/e2e/project-setup.cy.ts b/packages/launchpad/cypress/e2e/project-setup.cy.ts index 784e4790bf22..edcfb30b308a 100644 --- a/packages/launchpad/cypress/e2e/project-setup.cy.ts +++ b/packages/launchpad/cypress/e2e/project-setup.cy.ts @@ -615,7 +615,7 @@ describe('Launchpad: Setup Project', () => { cy.visitLaunchpad() - cy.get('[data-cy-testingtype="component"]').click() + cy.get('[data-cy-testingtype="component"]', { timeout: 10000 }).click() cy.get('[data-testid="select-framework"]').click() cy.findByText('Vue.js 3').click() cy.contains('button', 'Pick a bundler').click()