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

Bigint does not display correctly in Command Log, throws error on print to console of 0n #16570

Closed
FFdhorkin opened this issue May 18, 2021 · 4 comments · Fixed by #16640
Closed
Labels
pkg/runner This is due to an issue in the packages/runner directory type: bug

Comments

@FFdhorkin
Copy link

FFdhorkin commented May 18, 2021

Current behavior

There are currently two issues with bigint in cypress.

  1. when it prints log output, it says {} instead of serializing the bigint. If you click on the assertion, it displays properly in the console:
    image
  2. If either the expected or actual value is 0n, you get an exception when you click on it:
    image

Desired behavior

  • Bigints assertions should display their values in the command log (possibly with truncation)
  • if you click on a bigint assertion that has 0n on expected or actual, no exception should occur

Test code to reproduce

describe('Bigint example', () => {
    it('Displays wrong', () => {
        expect(2n).to.equal(2n);
    });

    it('Exception on inspect', () => {
        expect(1n).to.equal(0n);
    })

    it('Exception on inspect 2', () => {
        expect(0n).to.equal(1n);
    })
});

Versions

This is present in 5.6.0 through 7.3.0, though you get different behavior for the exception in 5.6.0 and 7.3.0. In older versions, it doesn't show the exception and stack trace, but expected/actual are missing:
image
image

@jennifer-shehane
Copy link
Member

Our code tries to run lodash _.trim() on the value, so _.trim(0n) throws that Cannot mix BigInt error. Code is here: https://github.com/cypress-io/cypress/blob/develop/packages/runner/src/lib/logger.js#L32:L32

I'm not sure exactly why it displays as {} instead of the bigint.

We would accept a pull request to fix the display and error.

@jennifer-shehane jennifer-shehane added stage: ready for work The issue is reproducible and in scope type: bug labels May 18, 2021
@jennifer-shehane jennifer-shehane changed the title Bigint support in Cypress Bigint does not display correctly in Command Log, throws error on print to console of 0n May 18, 2021
@jennifer-shehane jennifer-shehane added the pkg/runner This is due to an issue in the packages/runner directory label May 18, 2021
@sainthkh
Copy link
Contributor

expect {} to be {} is happening because of chai bug. It's fixed recently in 4.3.4.

@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress labels May 24, 2021
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels May 26, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 26, 2021

The code for this is done in cypress-io/cypress#16640, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 7, 2021

Released in 7.5.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v7.5.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/runner This is due to an issue in the packages/runner directory type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants