@@ -48,9 +48,12 @@ const _mount = (type: 'mount' | 'rerender', jsx: React.ReactNode, options: Mount
48
48
// @ts -ignore FIXME
49
49
const componentName = getDisplayName ( jsx . type , options . alias )
50
50
const displayName = options . alias || componentName
51
+
52
+ const jsxComponentName = `<${ componentName } ... />`
53
+
51
54
const message = options . alias
52
- ? `< ${ componentName } ... /> as "${ options . alias } "`
53
- : `< ${ componentName } ... />`
55
+ ? `${ jsxComponentName } as "${ options . alias } "`
56
+ : jsxComponentName
54
57
55
58
return cy
56
59
. then ( injectStyles ( options ) )
@@ -113,7 +116,7 @@ const _mount = (type: 'mount' | 'rerender', jsx: React.ReactNode, options: Mount
113
116
return cy . wrap < MountReturn > ( {
114
117
component : userComponent ,
115
118
rerender : ( newComponent ) => _mount ( 'rerender' , newComponent , options , key ) ,
116
- unmount,
119
+ unmount : ( ) => _unmount ( { boundComponentMessage : jsxComponentName , log : true } ) ,
117
120
} , { log : false } )
118
121
} )
119
122
// by waiting, we delaying test execution for the next tick of event loop
@@ -147,15 +150,28 @@ Cypress.on('run:start', () => {
147
150
})
148
151
```
149
152
*/
150
- export const unmount = ( options = { log : true } ) : globalThis . Cypress . Chainable < JQuery < HTMLElement > > => {
153
+ export const unmount = ( options = { log : true } ) : globalThis . Cypress . Chainable < JQuery < HTMLElement > > => _unmount ( options )
154
+
155
+ const _unmount = ( options : { boundComponentMessage ?: string , log : boolean } ) => {
151
156
return cy . then ( ( ) => {
152
157
const selector = `#${ ROOT_ID } `
153
158
154
159
return cy . get ( selector , { log : false } ) . then ( ( $el ) => {
155
160
const wasUnmounted = ReactDOM . unmountComponentAtNode ( $el [ 0 ] )
156
161
157
162
if ( wasUnmounted && options . log ) {
158
- cy . log ( 'Unmounted component at' , $el )
163
+ Cypress . log ( {
164
+ name : 'unmount' ,
165
+ type : 'parent' ,
166
+ message : [ options . boundComponentMessage ?? 'Unmounted component' ] ,
167
+ consoleProps : ( ) => {
168
+ return {
169
+ description : 'Unmounts React component' ,
170
+ parent : $el [ 0 ] ,
171
+ home : 'https://github.com/cypress-io/cypress' ,
172
+ }
173
+ } ,
174
+ } )
159
175
}
160
176
} )
161
177
} )
0 commit comments