Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter called with a function doesn't listen to options #3315

Closed
Lakitna opened this Issue Feb 4, 2019 · 3 comments

Comments

2 participants
@Lakitna
Copy link
Contributor

Lakitna commented Feb 4, 2019

Current behavior:

When you call filter with a function like the code below it will still be logged

cy.get()
  .filter((i, elem) => {
    return true;
  }, {log: false});

Will correctly filter and wrongly log the following
image

Bonus undocumented behavior:

cy.get()
  .filter((i, elem) => {
    return true;
  }, 'foo');

Will correctly filter and somehow log the following
image

This does not have any effect on the filtering itself.

Desired behavior:

Allow disabling logging for the filter command when its called with a function.

Steps to reproduce: (app code and test code)

Add the following code to a Cypress chain.

.filter((i, elem) => {
  return i == 0;
}, {log: false});

It will filter out everything but the first element, and it will (wrongly) output to the Cypress log.

Versions

Cypress 3.1.4
Electron 59

Note: I've been trying to locate the source for filter but have not been able to find it. I don't mind fixing this issue myself (as it seems pretty straightforward) if someone can point me to the correct file.

@jennifer-shehane

This comment has been minimized.

Copy link
Member

jennifer-shehane commented Feb 5, 2019

All of the querying commands' (including filter) behavior is borrowed directly from jQuery and run through this each method. So, the logging logic should be within there. Code here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/commands/traversals.coffee#L5

@Lakitna

This comment has been minimized.

Copy link
Contributor Author

Lakitna commented Feb 5, 2019

I believe I found the issue, but I'll have to try it when I get home. Somehow the corporate proxy or corporate machine I'm running interferes with building Cypress.

The issue is probably that _.isObject() (line 10 and 13) also matches functions.

@cypress-bot

This comment has been minimized.

Copy link

cypress-bot bot commented Mar 15, 2019

Released in 3.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.