Skip to content

Commit 1f14ce1

Browse files
committed
feat: add parent/child log type detection
1 parent b58f747 commit 1f14ce1

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

cypress/integration/find.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,28 @@ describe('find* dom-testing-library commands', () => {
200200
.findByText('Button Text 1')
201201
.should('exist')
202202
})
203+
204+
it('findByText should show as a parent command if it starts a chain', () => {
205+
const assertLog = (attrs, log) => {
206+
if(log.get('name') === 'findByText') {
207+
expect(log.get('type')).to.equal('parent')
208+
cy.off('log:added', assertLog)
209+
}
210+
}
211+
cy.on('log:added', assertLog)
212+
cy.findByText('Button Text 1')
213+
})
214+
215+
it('findByText should show as a child command if it continues a chain', () => {
216+
const assertLog = (attrs, log) => {
217+
if(log.get('name') === 'findByText') {
218+
expect(log.get('type')).to.equal('child')
219+
cy.off('log:added', assertLog)
220+
}
221+
}
222+
cy.on('log:added', assertLog)
223+
cy.get('body').findByText('Button Text 1')
224+
})
203225
})
204226

205227
/* global cy */

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ function createCommand(queryName, implementationName) {
7474

7575
if (options.log) {
7676
options._log = Cypress.log({
77+
type: prevSubject ? 'child' : 'parent',
7778
name: queryName,
7879
message: inputArr,
7980
consoleProps: () => consoleProps,

0 commit comments

Comments
 (0)