From a44bb8318299ae7b016934107ecea3b45defebf3 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Thu, 19 Apr 2018 00:26:07 -0500 Subject: [PATCH] fix(logs): log the command properly --- cypress/integration/commands.spec.js | 12 +++--------- src/index.js | 13 ++++++++++++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/cypress/integration/commands.spec.js b/cypress/integration/commands.spec.js index 7f18b34..3c0b8a6 100644 --- a/cypress/integration/commands.spec.js +++ b/cypress/integration/commands.spec.js @@ -10,9 +10,7 @@ describe('dom-testing-library commands', () => { }) it('getByText', () => { - cy - .getByText('Button Text') - .click() + cy.getByText('Button Text').click() }) it('getByLabelText', () => { @@ -23,15 +21,11 @@ describe('dom-testing-library commands', () => { }) it('getByAltText', () => { - cy - .getByAltText('Image Alt Text') - .click() + cy.getByAltText('Image Alt Text').click() }) it('getByTestId', () => { - cy - .getByTestId('image-with-random-alt-tag') - .click() + cy.getByTestId('image-with-random-alt-tag').click() }) }) diff --git a/src/index.js b/src/index.js index 97528bd..8961a2c 100644 --- a/src/index.js +++ b/src/index.js @@ -17,7 +17,17 @@ const commands = Object.keys(queries) } `, )(commandImpl) - return cy.window({log: false}).then(thenHandler) + return cy + .window({log: false}) + .then(thenHandler) + .then(subject => { + Cypress.log({ + $el: subject, + name: queryName, + message: args, + }) + return subject + }) }, } }) @@ -25,3 +35,4 @@ const commands = Object.keys(queries) export {commands} /* eslint no-new-func:0 */ +/* globals Cypress */