Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add option to disable command log #8689

Merged
merged 4 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/runner/cypress/integration/retries.ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('runner/cypress retries.ui.spec', { viewportWidth: 600, viewportHeight:
})
.then(shouldHaveTestResults(2, 0))

cy.get('.test').should('have.length', 2)
cy.percySnapshot()
})

Expand Down
20 changes: 20 additions & 0 deletions packages/runner/cypress/integration/runner.ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,5 +341,25 @@ describe('src/cypress/runner', () => {
},
})
})

it('supports disabling command log reporter with env var NO_COMMAND_LOG', () => {
runIsolatedCypress(() => {
it('foo', () => {
// simulate a page load, ensures reporter state event is properly stubbed
cy.then(() => Cypress.action('cy:collect:run:state'))
cy.visit('/')

// ensures runner doesn't wait for nonexist before:screenshot ack
cy.screenshot({
capture: 'runner',
})
})
},
{
config: { env: { NO_COMMAND_LOG: '1' } },
})

cy.get('.reporter').should('not.exist')
flotwig marked this conversation as resolved.
Show resolved Hide resolved
})
})
})
6 changes: 4 additions & 2 deletions packages/runner/src/app/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class App extends Component {
*/
const spec = this.props.config.spec

const NO_COMMAND_LOG = this.props.config.env && this.props.config.env.NO_COMMAND_LOG

return (
<div className={cs({
'is-reporter-resizing': this.isReporterResizing,
Expand All @@ -36,13 +38,13 @@ class App extends Component {
className='reporter-wrap'
style={{ width: this.props.state.reporterWidth }}
>
<Reporter
{Boolean(NO_COMMAND_LOG) || <Reporter
runner={this.props.eventManager.reporterBus}
spec={spec}
autoScrollingEnabled={this.props.config.state.autoScrollingEnabled}
error={errorMessages.reporterError(this.props.state.scriptError, spec.relative)}
firefoxGcInterval={this.props.config.firefoxGcInterval}
/>
/>}
</div>
<div
ref='container'
Expand Down
8 changes: 8 additions & 0 deletions packages/runner/src/lib/event-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ const eventManager = {
})

Cypress.on('collect:run:state', () => {
if (Cypress.env('NO_COMMAND_LOG')) {
return Promise.resolve()
}

return new Promise((resolve) => {
reporterBus.emit('reporter:collect:run:state', resolve)
})
Expand All @@ -315,6 +319,10 @@ const eventManager = {
cb()
}

if (Cypress.env('NO_COMMAND_LOG')) {
return beforeThenCb()
}

const wait = !config.appOnly && config.waitForCommandSynchronization

if (!config.appOnly) {
Expand Down
4 changes: 3 additions & 1 deletion packages/runner/src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const Runner = {
action('started', () => {
const config = JSON.parse(driverUtils.decodeBase64Unicode(base64Config))

const state = new State((config.state || {}).reporterWidth)
const NO_COMMAND_LOG = config.env && config.env.NO_COMMAND_LOG

const state = new State(NO_COMMAND_LOG ? 0 : (config.state || {}).reporterWidth)

Runner.state = state
Runner.configureMobx = configure
Expand Down