-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not attempt to trim objects when printing to console (#18341)
- Loading branch information
Showing
2 changed files
with
35 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,43 @@ | ||
const sinon = require('sinon') | ||
const { logger } = require('./logger') | ||
import _ from 'lodash' | ||
|
||
describe('logger', () => { | ||
let spyLog = sinon.spy(logger, 'log') | ||
|
||
afterEach(() => { | ||
// reset after each unit test | ||
spyLog.resetHistory() | ||
}) | ||
|
||
// https://github.com/cypress-io/cypress/issues/17542 | ||
it('cy.log() shows all arguments in each line when there are multiple args', () => { | ||
const spy = sinon.spy(logger, 'log') | ||
|
||
logger.logFormatted({ args: [1, 2, 3] }) | ||
|
||
expect(spy).to.have.been.calledWith(`%cArgs:`, 'font-weight: bold') | ||
expect(spy).to.have.been.calledWith(`%c [0]:`, 'font-weight: bold', 1) | ||
expect(spy).to.have.been.calledWith(`%c [1]:`, 'font-weight: bold', 2) | ||
expect(spy).to.have.been.calledWith(`%c [2]:`, 'font-weight: bold', 3) | ||
expect(spyLog).to.have.been.calledWith(`%cArgs:`, 'font-weight: bold') | ||
expect(spyLog).to.have.been.calledWith(`%c [0]:`, 'font-weight: bold', 1) | ||
expect(spyLog).to.have.been.calledWith(`%c [1]:`, 'font-weight: bold', 2) | ||
expect(spyLog).to.have.been.calledWith(`%c [2]:`, 'font-weight: bold', 3) | ||
}) | ||
|
||
describe('_logValues', () => { | ||
let spyTrim = sinon.spy(_, 'trim') | ||
|
||
afterEach(() => { | ||
// reset after each unit test | ||
spyTrim.resetHistory() | ||
}) | ||
|
||
it('should not call trim', () => { | ||
logger._logValues({}) | ||
logger._logValues({ test: {} }) | ||
logger._logValues(null) | ||
logger._logValues(undefined) | ||
|
||
expect(spyTrim.getCalls()).to.have.length(0) | ||
}) | ||
|
||
// The positive unit tests to capture if log has been called are already written in | ||
// the 'cy.log() shows all arguments in each line when there are multiple args' unit test. | ||
}) | ||
}) |
7a4c59a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
7a4c59a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppVeyor has built the
win32 ia32
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
7a4c59a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppVeyor has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
7a4c59a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: