Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Commit 615bd04

Browse files
committed
feat: respect log false
1 parent ad51a71 commit 615bd04

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

cypress/component/basic/styles/css-file/css-file-spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe('cssFile', () => {
3434
'cypress/component/basic/styles/css-file/base.css',
3535
'cypress/component/basic/styles/css-file/index.css',
3636
],
37+
log: false,
3738
})
3839

3940
// check the style from the first css file

cypress/component/basic/styles/style/style-spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('style', () => {
4848
const Component = () => <button className="green">Green button</button>
4949
mount(<Component />, {
5050
styles: indexStyle,
51+
log: false,
5152
})
5253

5354
cy.get('button')

lib/hooks.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/** Initialize an empty document with root element */
22
function renderTestingPlatform() {
3-
cy.log('Prepearing to ReactDOM rendering')
4-
53
const document = cy.state('document') as Document
64
if (document.getElementById('cypress-jsdom')) {
75
return

lib/index.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,17 @@ export const mount = (jsx: React.ReactElement, options: MountOptions = {}) => {
4848
return cy
4949
.window({ log: false })
5050
.then(() => {
51-
Cypress.log({
52-
name: 'mount',
53-
message: [`ReactDOM.render(<${displayname} ... />)`],
54-
consoleProps() {
55-
return {
56-
props: jsx.props,
57-
}
58-
},
59-
})
51+
if (options.log !== false) {
52+
Cypress.log({
53+
name: 'mount',
54+
message: [`ReactDOM.render(<${displayname} ... />)`],
55+
consoleProps() {
56+
return {
57+
props: jsx.props,
58+
}
59+
},
60+
})
61+
}
6062
})
6163
.then(injectStyles(options))
6264
.then(() => {

lib/utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ function insertSingleCssFile(
3030
cssFilename: string,
3131
document: Document,
3232
el: HTMLElement,
33+
log?: boolean,
3334
) {
34-
return cy.readFile(cssFilename).then(css => {
35+
return cy.readFile(cssFilename, { log }).then(css => {
3536
const style = document.createElement('style')
3637
style.appendChild(document.createTextNode(css))
3738
document.body.insertBefore(style, el)
@@ -46,9 +47,10 @@ function insertLocalCssFiles(
4647
cssFilenames: string[],
4748
document: Document,
4849
el: HTMLElement,
50+
log?: boolean,
4951
) {
5052
return Cypress.Promise.mapSeries(cssFilenames, cssFilename =>
51-
insertSingleCssFile(cssFilename, document, el),
53+
insertSingleCssFile(cssFilename, document, el, log),
5254
)
5355
}
5456

@@ -57,7 +59,7 @@ function insertLocalCssFiles(
5759
* into the given document.
5860
*/
5961
export const injectStylesBeforeElement = (
60-
options: Partial<StyleOptions>,
62+
options: Partial<StyleOptions & { log: boolean }>,
6163
document: Document,
6264
el: HTMLElement,
6365
) => {
@@ -110,5 +112,5 @@ export const injectStylesBeforeElement = (
110112
cssFiles = cssFiles.concat(options.cssFiles)
111113
}
112114

113-
return insertLocalCssFiles(cssFiles, document, el)
115+
return insertLocalCssFiles(cssFiles, document, el, options.log)
114116
}

0 commit comments

Comments
 (0)