From 5decde47627d188b9abd2bd1337c5f318371dcbe Mon Sep 17 00:00:00 2001 From: Matt Schile Date: Mon, 30 Jan 2023 13:13:28 -0700 Subject: [PATCH 1/9] fix: removing reporter logs for collapsed tests in run mode --- .../driver/cypress/e2e/memory/memory.cy.js | 6 + packages/driver/src/cypress.ts | 2 +- packages/reporter/cypress/e2e/memory.cy.ts | 234 +++++++++ .../cypress/fixtures/runnables_memory.json | 484 ++++++++++++++++++ .../reporter/src/attempts/attempt-model.ts | 16 +- packages/reporter/src/lib/events.ts | 4 +- .../reporter/src/runnables/runnables-store.ts | 4 +- packages/reporter/src/test/test-model.ts | 4 +- 8 files changed, 746 insertions(+), 8 deletions(-) create mode 100644 packages/reporter/cypress/e2e/memory.cy.ts create mode 100644 packages/reporter/cypress/fixtures/runnables_memory.json diff --git a/packages/driver/cypress/e2e/memory/memory.cy.js b/packages/driver/cypress/e2e/memory/memory.cy.js index 45a7aeb6a3b7..38ed2ab3ef9e 100644 --- a/packages/driver/cypress/e2e/memory/memory.cy.js +++ b/packages/driver/cypress/e2e/memory/memory.cy.js @@ -1,7 +1,13 @@ describe('memory spec', { browser: { family: 'chromium' } }, () => { + const text = 'x'.repeat(100000) + for (let index = 0; index < 50; index++) { it(`test ${index + 1} passes`, () => { cy.visit('http://localhost:3500/memory') + + for (let index = 0; index < 100; index++) { + cy.get(`#p${index}`).should('have.text', text) + } }) } }) diff --git a/packages/driver/src/cypress.ts b/packages/driver/src/cypress.ts index 2d0ded980238..19dd4f43e113 100644 --- a/packages/driver/src/cypress.ts +++ b/packages/driver/src/cypress.ts @@ -551,7 +551,7 @@ class $Cypress { // this event is how the reporter knows how to display // stats and runnable properties such as errors - this.emit('test:after:run', ...args) + this.emit('test:after:run', args[0], this.config('isInteractive')) this.maybeEmitCypressInCypress('mocha', 'test:after:run', args[0]) if (this.config('isTextTerminal')) { diff --git a/packages/reporter/cypress/e2e/memory.cy.ts b/packages/reporter/cypress/e2e/memory.cy.ts new file mode 100644 index 000000000000..0e11fc21e462 --- /dev/null +++ b/packages/reporter/cypress/e2e/memory.cy.ts @@ -0,0 +1,234 @@ +import { EventEmitter } from 'events' +import { RootRunnable } from '../../src/runnables/runnables-store' +import { MobxRunnerStore } from '@packages/app/src/store/mobx-runner-store' + +let runner: EventEmitter +let runnables: RootRunnable +const { _ } = Cypress + +function visitAndRenderReporter (studioEnabled: boolean = false, studioActive: boolean = false) { + cy.fixture('runnables_memory').then((_runnables) => { + runnables = _runnables + }) + + runner = new EventEmitter() + + const runnerStore = new MobxRunnerStore('e2e') + + runnerStore.setSpec({ + name: 'foo.js', + relative: 'relative/path/to/foo.js', + absolute: '/absolute/path/to/foo.js', + }) + + cy.visit('/').then((win) => { + win.render({ + studioEnabled, + runner, + runnerStore, + }) + }) + + cy.get('.reporter').then(() => { + runner.emit('runnables:ready', runnables) + runner.emit('reporter:start', { studioActive }) + }) + + return runnerStore +} + +describe('tests', () => { + beforeEach(() => { + visitAndRenderReporter() + }) + + context('run mode', () => { + beforeEach(() => { + _.each(runnables.suites, (suite) => { + _.each(suite.tests, (test) => { + runner.emit('test:after:run', test, false) + }) + }) + }) + + it('clears logs for a collapsed test', () => { + cy.contains('passed') + .as('passed') + .closest('.runnable') + .should('have.class', 'test') + .find('.runnable-instruments').should('not.exist') + + cy.get('@passed').click() + + cy.get('@passed') + .parents('.collapsible').first() + .find('.attempt-item').eq(0) + .contains('No commands were issued in this test.') + + cy.percySnapshot() + }) + + it('retains logs for an expanded test', () => { + cy.contains('failed') + .parents('.collapsible').first() + .should('have.class', 'is-open') + .find('.collapsible-content') + .should('be.visible') + + cy.contains('failed') + .parents('.collapsible').first() + .find('.attempt-item') + .eq(0) + .find('.attempt-1') + .within(() => { + cy.get('.sessions-container') + cy.get('.runnable-agents-region') + cy.get('.runnable-routes-region') + cy.get('.runnable-commands-region') + }) + + cy.percySnapshot() + }) + + it('retains logs for failed attempt and clears logs for passed attempt after retry', () => { + cy.contains('passed after retry') + .parents('.collapsible').first() + .should('not.have.class', 'is-open') + .find('.collapsible-content') + .should('not.exist') + + cy.contains('passed after retry').click() + + cy.contains('passed after retry') + .parents('.collapsible').first() + .find('.attempt-item').as('attempts') + + cy.get('@attempts').eq(0).as('firstAttempt') + .find('.collapsible') + .should('not.have.class', 'is-open') + .find('.collapsible-indicator').should('not.exist') + + cy.get('@firstAttempt') + .contains('Attempt 1') + .click() + + cy.get('@firstAttempt') + .find('.attempt-1') + .within(() => { + cy.get('.sessions-container') + cy.get('.runnable-agents-region') + cy.get('.runnable-routes-region') + cy.get('.runnable-commands-region') + }) + + cy.get('@attempts').eq(1).as('secondAttempt') + .find('.collapsible') + .should('have.class', 'is-open') + .find('.collapsible-indicator').should('not.exist') + + cy.get('@secondAttempt') + .contains('No commands were issued in this test.') + + cy.percySnapshot() + }) + + it('retains logs for failed attempts', () => { + cy.contains('failed with retries') + .parents('.collapsible').first() + .find('.attempt-item').as('attempts') + + cy.get('@attempts').eq(0).as('firstAttempt') + .find('.collapsible') + .should('not.have.class', 'is-open') + .find('.collapsible-indicator').should('not.exist') + + cy.get('@firstAttempt') + .contains('Attempt 1') + .click() + + cy.get('@firstAttempt') + .find('.attempt-1') + .within(() => { + cy.get('.sessions-container') + cy.get('.runnable-agents-region') + cy.get('.runnable-routes-region') + cy.get('.runnable-commands-region') + }) + + cy.get('@attempts').eq(1).as('secondAttempt') + .find('.collapsible') + .should('have.class', 'is-open') + .find('.collapsible-content') + .should('be.visible') + + cy.get('@secondAttempt') + .find('.attempt-2') + .within(() => { + cy.get('.sessions-container') + cy.get('.runnable-agents-region') + cy.get('.runnable-routes-region') + cy.get('.runnable-commands-region') + }) + + cy.contains('failed with retries') + .scrollIntoView() + .percySnapshot() + }) + }) + + context('open mode', () => { + beforeEach(() => { + _.each(runnables.suites, (suite) => { + _.each(suite.tests, (test) => { + runner.emit('test:after:run', test, true) + }) + }) + }) + + it('retains logs for a collapsed test', () => { + cy.contains('passed') + .as('passed') + .closest('.runnable') + .should('have.class', 'test') + .find('.runnable-instruments').should('not.exist') + + cy.get('@passed').click() + + cy.get('@passed') + .parents('.collapsible').first() + .find('.attempt-item') + .eq(0) + .find('.attempt-1') + .within(() => { + cy.get('.sessions-container') + cy.get('.runnable-agents-region') + cy.get('.runnable-routes-region') + cy.get('.runnable-commands-region') + }) + + cy.percySnapshot() + }) + + it('retains logs for an expanded test', () => { + cy.contains('failed') + .parents('.collapsible').first() + .should('have.class', 'is-open') + .find('.collapsible-content') + .should('be.visible') + + cy.contains('failed') + .parents('.collapsible').first() + .find('.attempt-item') + .eq(0) + .find('.attempt-1') + .within(() => { + cy.get('.sessions-container') + cy.get('.runnable-agents-region') + cy.get('.runnable-routes-region') + cy.get('.runnable-commands-region') + }) + + cy.percySnapshot() + }) + }) +}) diff --git a/packages/reporter/cypress/fixtures/runnables_memory.json b/packages/reporter/cypress/fixtures/runnables_memory.json new file mode 100644 index 000000000000..b2cc249c667e --- /dev/null +++ b/packages/reporter/cypress/fixtures/runnables_memory.json @@ -0,0 +1,484 @@ +{ + "id": "r1", + "title": "", + "root": true, + "hooks": [], + "tests": [], + "suites": [ + { + "id": "r2", + "title": "suite 1", + "root": false, + "hooks": [], + "tests": [ + { + "id": "r3", + "title": "passed", + "state": "passed", + "hooks": [ + { + "title": "\"before each\" hook", + "hookName": "before each", + "hookId": "h1", + "pending": false, + "body": "() => {\\n cy.session('test', () => {});\\n }", + "type": "hook", + "currentRetry": 0, + "retries": -1 + } + ], + "agents": [ + { + "id": 1, + "functionName": "get", + "name": "spy", + "alias": "getAlias", + "instrument": "agent", + "callCount": 1 + } + ], + "routes": [ + { + "id": 1, + "name": "route", + "numResponses": 1, + "method": "GET", + "url": "/", + "instrument": "route" + } + ], + "commands": [ + { + "id": "c2", + "hookId": "h1", + "instrument": "command", + "message": "test", + "name": "session", + "sessionInfo": { + "id": "test", + "isGlobalSession": false, + "status": "created" + }, + "state": "passed", + "testId": "r3", + "type": "parent" + }, + { + "id": "c1", + "hookId": "r3", + "instrument": "command", + "message": "http://localhost:3000", + "name": "visit", + "state": "passed", + "testId": "r3", + "timeout": 4000, + "type": "parent", + "wallClockStartedAt": "2020-01-01T00:00:00.000Z" + } + ] + }, + { + "id": "r4", + "title": "failed", + "state": "failed", + "err": { + "name": "CommandError", + "message": "failed to visit", + "stack": "failed to visit\n\ncould not visit http: //localhost:3000" + }, + "hooks": [ + { + "title": "\"before each\" hook", + "hookName": "before each", + "hookId": "h1", + "pending": false, + "body": "() => {\\n cy.session('test', () => {});\\n }", + "type": "hook", + "currentRetry": 0, + "retries": -1 + } + ], + "agents": [ + { + "id": 1, + "functionName": "get", + "name": "spy", + "alias": "getAlias", + "instrument": "agent", + "callCount": 1 + } + ], + "routes": [ + { + "id": 1, + "name": "route", + "numResponses": 1, + "method": "GET", + "url": "/", + "instrument": "route" + } + ], + "commands": [ + { + "id": "c2", + "hookId": "h1", + "instrument": "command", + "message": "test", + "name": "session", + "sessionInfo": { + "id": "test", + "isGlobalSession": false, + "status": "created" + }, + "state": "passed", + "testId": "r3", + "type": "parent" + }, + { + "id": "c1", + "hookId": "r3", + "instrument": "command", + "message": "http://localhost:3000", + "name": "visit", + "state": "passed", + "testId": "r3", + "timeout": 4000, + "type": "parent", + "wallClockStartedAt": "2020-01-01T00:00:00.000Z" + } + ] + }, + { + "id": "r5", + "title": "passed after retry", + "state": "passed", + "retries": 1, + "currentRetry": 1, + "hooks": [ + { + "title": "\"before each\" hook", + "hookName": "before each", + "hookId": "h1", + "pending": false, + "body": "() => {\\n cy.session('test', () => {});\\n }", + "type": "hook", + "currentRetry": 0, + "retries": -1 + } + ], + "agents": [ + { + "id": 1, + "functionName": "get", + "name": "spy", + "alias": "getAlias", + "instrument": "agent", + "callCount": 1 + } + ], + "routes": [ + { + "id": 1, + "name": "route", + "numResponses": 1, + "method": "GET", + "url": "/", + "instrument": "route" + } + ], + "commands": [ + { + "id": "c1", + "hookId": "h1", + "instrument": "command", + "message": "test", + "name": "session", + "sessionInfo": { + "id": "test", + "isGlobalSession": false, + "status": "created" + }, + "state": "passed", + "testId": "r5", + "type": "parent" + }, + { + "id": "c2", + "hookId": "r5", + "instrument": "command", + "message": "http://localhost:3000", + "name": "visit", + "state": "passed", + "testId": "r5", + "timeout": 4000, + "type": "parent", + "wallClockStartedAt": "2020-01-01T00:00:00.000Z" + } + ], + "prevAttempts": [ + { + "hookId": "r88", + "id": "c1", + "instrument": "command", + "message": "#id", + "name": "get", + "state": "failed", + "testId": "r88", + "timeout": 4000, + "type": "parent", + "wallClockStartedAt": "2020-01-01T00:00:00.000Z", + "hooks": [ + { + "title": "\"before each\" hook", + "hookName": "before each", + "hookId": "h1", + "pending": false, + "body": "() => {\\n cy.session('test', () => {});\\n }", + "type": "hook", + "currentRetry": 0, + "retries": -1 + } + ], + "agents": [ + { + "id": 1, + "functionName": "get", + "name": "spy", + "alias": "getAlias", + "instrument": "agent", + "callCount": 1 + } + ], + "routes": [ + { + "id": 1, + "name": "route", + "numResponses": 1, + "method": "GET", + "url": "/", + "instrument": "route" + } + ], + "commands": [ + { + "id": "c2", + "hookId": "h1", + "instrument": "command", + "message": "test", + "name": "session", + "sessionInfo": { + "id": "test", + "isGlobalSession": false, + "status": "created" + }, + "state": "passed", + "testId": "r3", + "type": "parent" + }, + { + "hookId": "r5", + "id": "c3", + "instrument": "command", + "message": "#does_not_exist", + "name": "get", + "state": "failed", + "testId": "r5", + "timeout": 4000, + "type": "parent", + "wallClockStartedAt": "2020-01-01T00:00:00.000Z", + "err": { + "name": "CommandError", + "message": "failed to get", + "stack": "failed to get element" + } + } + ] + } + ] + }, + { + "id": "r6", + "title": "failed with retries", + "state": "failed", + "retries": 1, + "currentRetry": 1, + "hooks": [ + { + "title": "\"before each\" hook", + "hookName": "before each", + "hookId": "h1", + "pending": false, + "body": "() => {\\n cy.session('test', () => {});\\n }", + "type": "hook", + "currentRetry": 0, + "retries": -1 + } + ], + "agents": [ + { + "id": 1, + "functionName": "get", + "name": "spy", + "alias": "getAlias", + "instrument": "agent", + "callCount": 1 + } + ], + "routes": [ + { + "id": 1, + "name": "route", + "numResponses": 1, + "method": "GET", + "url": "/", + "instrument": "route" + } + ], + "commands": [ + { + "id": "c2", + "hookId": "h1", + "instrument": "command", + "message": "test", + "name": "session", + "sessionInfo": { + "id": "test", + "isGlobalSession": false, + "status": "created" + }, + "state": "passed", + "testId": "r3", + "type": "parent" + }, + { + "id": "c1", + "hookId": "r6", + "instrument": "command", + "message": "http://localhost:3000", + "name": "visit", + "state": "passed", + "testId": "r6", + "timeout": 4000, + "type": "parent", + "wallClockStartedAt": "2020-01-01T00:00:00.000Z" + }, + { + "hookId": "r6", + "id": "c1", + "instrument": "command", + "message": "#does_not_exist", + "name": "get", + "state": "failed", + "testId": "r6", + "timeout": 4000, + "type": "parent", + "wallClockStartedAt": "2020-01-01T00:00:00.000Z", + "err": { + "name": "CommandError", + "message": "failed to get", + "stack": "failed to get element" + } + } + ], + "prevAttempts": [ + { + "hookId": "r6", + "id": "c1", + "instrument": "command", + "message": "#does_not_exist", + "name": "get", + "state": "failed", + "testId": "r6", + "timeout": 4000, + "type": "parent", + "wallClockStartedAt": "2020-01-01T00:00:00.000Z", + "hooks": [ + { + "title": "\"before each\" hook", + "hookName": "before each", + "hookId": "h1", + "pending": false, + "body": "() => {\\n cy.session('test', () => {});\\n }", + "type": "hook", + "currentRetry": 0, + "retries": -1 + } + ], + "agents": [ + { + "id": 1, + "functionName": "get", + "name": "spy", + "alias": "getAlias", + "instrument": "agent", + "callCount": 1 + } + ], + "routes": [ + { + "id": 1, + "name": "route", + "numResponses": 1, + "method": "GET", + "url": "/", + "instrument": "route" + } + ], + "commands": [ + { + "id": "c1", + "hookId": "h1", + "instrument": "command", + "message": "test", + "name": "session", + "sessionInfo": { + "id": "test", + "isGlobalSession": false, + "status": "created" + }, + "state": "passed", + "testId": "r6", + "type": "parent" + }, + { + "id": "c2", + "hookId": "r6", + "instrument": "command", + "message": "http://localhost:3000", + "name": "visit", + "state": "passed", + "testId": "r6", + "timeout": 4000, + "type": "parent", + "wallClockStartedAt": "2020-01-01T00:00:00.000Z" + }, + { + "hookId": "r6", + "id": "c3", + "instrument": "command", + "message": "#does_not_exist", + "name": "get", + "state": "failed", + "testId": "r6", + "timeout": 4000, + "type": "parent", + "wallClockStartedAt": "2020-01-01T00:00:00.000Z", + "err": { + "name": "CommandError", + "message": "failed to get", + "stack": "failed to get element" + } + } + ] + } + ], + "err": { + "name": "CommandError", + "message": "failed to get", + "stack": "failed to get element" + } + } + ] + } + ] +} diff --git a/packages/reporter/src/attempts/attempt-model.ts b/packages/reporter/src/attempts/attempt-model.ts index 59716cb78084..5c15dbfdecca 100644 --- a/packages/reporter/src/attempts/attempt-model.ts +++ b/packages/reporter/src/attempts/attempt-model.ts @@ -194,9 +194,23 @@ export default class Attempt { } } - @action finish (props: UpdatableTestProps) { + @action finish (props: UpdatableTestProps, isInteractive: boolean) { this.update(props) this.isActive = false + + // if the test is not open and we aren't in interactive mode, clear out the attempt details + if (!this.test.isOpen && !isInteractive) { + this._clear() + } + } + + _clear () { + this.commands = [] + this.routes = [] + this.agents = [] + this.hooks = [] + this._logs = {} + this.sessions = {} } _addAgent (props: AgentProps) { diff --git a/packages/reporter/src/lib/events.ts b/packages/reporter/src/lib/events.ts index 9339d036f951..91980f1510b2 100644 --- a/packages/reporter/src/lib/events.ts +++ b/packages/reporter/src/lib/events.ts @@ -95,8 +95,8 @@ const events: Events = { runnablesStore.runnableStarted(runnable) })) - runner.on('test:after:run', action('test:after:run', (runnable: TestProps) => { - runnablesStore.runnableFinished(runnable) + runner.on('test:after:run', action('test:after:run', (runnable: TestProps, isInteractive: boolean) => { + runnablesStore.runnableFinished(runnable, isInteractive) if (runnable.final && !appState.studioActive) { statsStore.incrementCount(runnable.state!) } diff --git a/packages/reporter/src/runnables/runnables-store.ts b/packages/reporter/src/runnables/runnables-store.ts index d0f2229bbb3d..7f55fb434ef3 100644 --- a/packages/reporter/src/runnables/runnables-store.ts +++ b/packages/reporter/src/runnables/runnables-store.ts @@ -150,9 +150,9 @@ export class RunnablesStore { }) } - runnableFinished (props: TestProps) { + runnableFinished (props: TestProps, isInteractive: boolean) { this._withTest(props.id, (test) => { - test.finish(props) + test.finish(props, isInteractive) }) } diff --git a/packages/reporter/src/test/test-model.ts b/packages/reporter/src/test/test-model.ts index 61682825e433..f5eac05a97df 100644 --- a/packages/reporter/src/test/test-model.ts +++ b/packages/reporter/src/test/test-model.ts @@ -186,11 +186,11 @@ export default class Test extends Runnable { } } - @action finish (props: UpdatableTestProps) { + @action finish (props: UpdatableTestProps, isInteractive: boolean) { this._isFinished = !(props.retries && props.currentRetry) || props.currentRetry >= props.retries this._withAttempt(props.currentRetry || 0, (attempt: Attempt) => { - attempt.finish(props) + attempt.finish(props, isInteractive) }) } From ce99784232ae76ba3bd8bb48fd7091547f54d9bf Mon Sep 17 00:00:00 2001 From: Matt Schile Date: Mon, 30 Jan 2023 14:28:39 -0700 Subject: [PATCH 2/9] update changelog --- cli/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 55b2ad3c72f8..11c7d1758284 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -7,6 +7,8 @@ _Released 01/31/2023 (PENDING)_ - Fixed an issue where alternative Microsoft Edge Beta, Canary, and Dev binary versions were not being discovered by Cypress. Fixes [#25455](https://github.com/cypress-io/cypress/issues/25455). +- Improved memory consumption in `run` mode by removing reporter logs for successful tests. + Fixes [#25230]https://github.com/cypress-io/cypress/issues/25230 ## 12.4.1 From c7a2a072b4e62f737dd6c6dd7dbdccb008551275 Mon Sep 17 00:00:00 2001 From: Matt Schile Date: Mon, 30 Jan 2023 15:03:44 -0700 Subject: [PATCH 3/9] updating changelog --- cli/CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 11c7d1758284..20890f285759 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -7,8 +7,10 @@ _Released 01/31/2023 (PENDING)_ - Fixed an issue where alternative Microsoft Edge Beta, Canary, and Dev binary versions were not being discovered by Cypress. Fixes [#25455](https://github.com/cypress-io/cypress/issues/25455). + +**Performance:** - Improved memory consumption in `run` mode by removing reporter logs for successful tests. - Fixes [#25230]https://github.com/cypress-io/cypress/issues/25230 + Fixes [#25230]https://github.com/cypress-io/cypress/issues/25230. ## 12.4.1 From 0a75d296be5ce73536fe9cbace2c803ce97f91ef Mon Sep 17 00:00:00 2001 From: Matt Schile Date: Mon, 30 Jan 2023 15:08:57 -0700 Subject: [PATCH 4/9] Update cli/CHANGELOG.md Co-authored-by: Emily Rohrbough --- cli/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 20890f285759..ec5f42747c40 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -10,7 +10,7 @@ _Released 01/31/2023 (PENDING)_ **Performance:** - Improved memory consumption in `run` mode by removing reporter logs for successful tests. - Fixes [#25230]https://github.com/cypress-io/cypress/issues/25230. + Fixes [#25230](https://github.com/cypress-io/cypress/issues/25230). ## 12.4.1 From 7136f84c72adfc14b9fc4184f19684c36b4e2905 Mon Sep 17 00:00:00 2001 From: Matt Schile Date: Mon, 30 Jan 2023 15:28:54 -0700 Subject: [PATCH 5/9] fix changelog --- cli/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index ec5f42747c40..90be9a918eba 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -9,6 +9,7 @@ _Released 01/31/2023 (PENDING)_ Fixes [#25455](https://github.com/cypress-io/cypress/issues/25455). **Performance:** + - Improved memory consumption in `run` mode by removing reporter logs for successful tests. Fixes [#25230](https://github.com/cypress-io/cypress/issues/25230). From 39f635b8e17e0fbf0cb0f449cb01e702c16db9e6 Mon Sep 17 00:00:00 2001 From: Matt Schile Date: Mon, 30 Jan 2023 15:46:08 -0700 Subject: [PATCH 6/9] updating isInteractive for memory.cy.js --- packages/driver/cypress/e2e/memory/memory.cy.js | 7 +++++++ packages/driver/cypress/support/defaults.js | 2 ++ 2 files changed, 9 insertions(+) diff --git a/packages/driver/cypress/e2e/memory/memory.cy.js b/packages/driver/cypress/e2e/memory/memory.cy.js index 38ed2ab3ef9e..ac7903f1bb6f 100644 --- a/packages/driver/cypress/e2e/memory/memory.cy.js +++ b/packages/driver/cypress/e2e/memory/memory.cy.js @@ -1,6 +1,13 @@ describe('memory spec', { browser: { family: 'chromium' } }, () => { const text = 'x'.repeat(100000) + beforeEach(() => { + if (!Cypress.config('isActuallyInteractive')) { + Cypress.config('isInteractive', false) + Cypress.config('numTestsKeptInMemory', 0) + } + }) + for (let index = 0; index < 50; index++) { it(`test ${index + 1} passes`, () => { cy.visit('http://localhost:3500/memory') diff --git a/packages/driver/cypress/support/defaults.js b/packages/driver/cypress/support/defaults.js index 2b0396c80b08..9fbcceda6c1e 100644 --- a/packages/driver/cypress/support/defaults.js +++ b/packages/driver/cypress/support/defaults.js @@ -2,6 +2,8 @@ const { $ } = Cypress const isActuallyInteractive = Cypress.config('isInteractive') +Cypress.config('isActuallyInteractive', isActuallyInteractive) + window.top.__cySkipValidateConfig = true if (!isActuallyInteractive) { From 56a6e7dd6925c02308f4ebb7f87b743b768c42cb Mon Sep 17 00:00:00 2001 From: Matt Schile Date: Mon, 30 Jan 2023 16:03:06 -0700 Subject: [PATCH 7/9] fixing test --- packages/reporter/cypress/e2e/unit/test_model.cy.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/reporter/cypress/e2e/unit/test_model.cy.ts b/packages/reporter/cypress/e2e/unit/test_model.cy.ts index 2d6f0f03c4d6..f520c0b2d52e 100644 --- a/packages/reporter/cypress/e2e/unit/test_model.cy.ts +++ b/packages/reporter/cypress/e2e/unit/test_model.cy.ts @@ -101,7 +101,7 @@ describe('Test model', () => { command.isLongRunning = true - test.finish({} as UpdatableTestProps) + test.finish({} as UpdatableTestProps, false) expect(test.isLongRunning).to.be.false }) }) @@ -282,21 +282,21 @@ describe('Test model', () => { it('sets the test as inactive', () => { const test = createTest() - test.finish({} as UpdatableTestProps) + test.finish({} as UpdatableTestProps, false) expect(test.isActive).to.be.false }) it('updates the state of the test', () => { const test = createTest() - test.finish({ state: 'failed' } as UpdatableTestProps) + test.finish({ state: 'failed' } as UpdatableTestProps, false) expect(test.state).to.equal('failed') }) it('updates the test err', () => { const test = createTest() - test.finish({ err: { name: 'SomeError' } as Err } as UpdatableTestProps) + test.finish({ err: { name: 'SomeError' } as Err } as UpdatableTestProps, false) expect(test.err.name).to.equal('SomeError') }) @@ -304,7 +304,7 @@ describe('Test model', () => { const test = createTest({ hooks: [{ hookId: 'h1', hookName: 'before each' }] }) test.addLog(createCommand({ instrument: 'command' })) - test.finish({ failedFromHookId: 'h1', err: { message: 'foo' } as Err } as UpdatableTestProps) + test.finish({ state: 'failed', failedFromHookId: 'h1', err: { message: 'foo' } as Err } as UpdatableTestProps, false) expect(test.lastAttempt.hooks[1].failed).to.be.true }) @@ -312,7 +312,7 @@ describe('Test model', () => { const test = createTest() expect(() => { - test.finish({ hookId: 'h1' } as UpdatableTestProps) + test.finish({ hookId: 'h1' } as UpdatableTestProps, false) }).not.to.throw() }) }) From 2f189aa549b014813276c4f8da6007713a45edd2 Mon Sep 17 00:00:00 2001 From: Matt Schile Date: Tue, 31 Jan 2023 07:26:56 -0700 Subject: [PATCH 8/9] updating memory.cy.js --- packages/driver/cypress/e2e/memory/memory.cy.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/packages/driver/cypress/e2e/memory/memory.cy.js b/packages/driver/cypress/e2e/memory/memory.cy.js index ac7903f1bb6f..45a7aeb6a3b7 100644 --- a/packages/driver/cypress/e2e/memory/memory.cy.js +++ b/packages/driver/cypress/e2e/memory/memory.cy.js @@ -1,20 +1,7 @@ describe('memory spec', { browser: { family: 'chromium' } }, () => { - const text = 'x'.repeat(100000) - - beforeEach(() => { - if (!Cypress.config('isActuallyInteractive')) { - Cypress.config('isInteractive', false) - Cypress.config('numTestsKeptInMemory', 0) - } - }) - for (let index = 0; index < 50; index++) { it(`test ${index + 1} passes`, () => { cy.visit('http://localhost:3500/memory') - - for (let index = 0; index < 100; index++) { - cy.get(`#p${index}`).should('have.text', text) - } }) } }) From f952901b649502ec1f1fa264525ab2b01579df01 Mon Sep 17 00:00:00 2001 From: Matt Schile Date: Tue, 31 Jan 2023 08:17:13 -0700 Subject: [PATCH 9/9] removing isActuallyInteractive --- packages/driver/cypress/support/defaults.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/driver/cypress/support/defaults.js b/packages/driver/cypress/support/defaults.js index 9fbcceda6c1e..2b0396c80b08 100644 --- a/packages/driver/cypress/support/defaults.js +++ b/packages/driver/cypress/support/defaults.js @@ -2,8 +2,6 @@ const { $ } = Cypress const isActuallyInteractive = Cypress.config('isInteractive') -Cypress.config('isActuallyInteractive', isActuallyInteractive) - window.top.__cySkipValidateConfig = true if (!isActuallyInteractive) {