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

If the received is different from the expected in some obvious way, reject it without full diff #6976

Closed
cmdcolin opened this issue Sep 13, 2018 · 8 comments
Labels

Comments

@cmdcolin
Copy link

cmdcolin commented Sep 13, 2018

🚀 Feature Proposal

Create a way to reject the test without a full diff?

Motivation

This report comes from a instance where I had a unserialized class object with some internal data that I compared to serialized JSON (the expected) and the output was giving memory errors. I should have been serializing the classes themselves but when I forgot to do so I questioned my sanity and the code because of these memory errors and jest never terminating

Example

This code produces the "bug" but since this sort of thing is potentially outside of the scope of bugs I am filing it as feature request
https://github.com/cmdcolin/jest_neverfinish

My only proposal is that somehow this would be "caught" without running forever or producing memory errors but potentially this is misguided

Pitch

If this feature was added to clearly reject something by partially diffing, then it would save headaches that make you think your actual code is faulty instead of the test being faulty!

@cmdcolin
Copy link
Author

I actually did not dig into it to see where the exact reason for the long running is but I figured it was diffing, hence my suggestion for partial diffing. I'd be curious also why this instance just takes a long time in general if it is an issue with the diffing?

@pedrottimark
Copy link
Contributor

@cmdcolin Thank you for link to repo!

With local version of pending improvement #6961, jest-diff call runs in 14 seconds on node 8.12.0

The size of diff output is 6266344

The test still fails for reason that will take some more time to investigate:

 ● Test suite failed to run

    RangeError: Maximum call stack size exceeded
        at RegExp.[Symbol.match] (<anonymous>)
        at String.match (native)

      at exports.separateMessageFromStack.content (node_modules/jest-message-util/build/index.js:368:32)
          at Array.map (<anonymous>)

@cmdcolin
Copy link
Author

Interesting, thanks for taking a look at it and I'm definitely interested to see how this new diff performs. I was basically unsure whether my request was within the scope of jest but it's great to see that there might be some solutions :)

@pedrottimark
Copy link
Contributor

Interesting, with or without improvement to diff-sequences package, the test fails successfully if I replace fs.readFileSync('test.txt') with fs.readFileSync('test.txt', 'utf8')

That is, whether pretty-format package serializes a file buffer (as array of integers) versus a multiline text string. That has come up before. This might make a good minimal reproduction.

@cmdcolin Without revealing proprietary details, does internal data of your class include a buffer?

@cmdcolin
Copy link
Author

Indeed it did include buffers and that was particularly why I reproduced it in the test

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 25, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions
Copy link

github-actions bot commented May 1, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants