-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Snapshotting <select>.options breaks in pretty-format #7121
Comments
@pedrottimark mind taking a look at this? Note that using a more complex |
@SimenB Thanks for cc. Notice HTML elements from Problem:
Solution: Explicitly convert it('snapshots select options', () => {
const select = document.createElement('select');
select.innerHTML = '<option value="one">one</option>';
expect(Array.from(select.options)).toMatchSnapshot();
}); it('snapshots select options', () => {
const select = document.createElement('select');
select.innerHTML = '<option value="one">one</option>';
expect(Array.from(select.children)).toMatchSnapshot();
}); Here is the stored snapshot: exports[`snapshots select options 1`] = `
Array [
<option
value="one"
>
one
</option>,
]
`; Although the thought has crossed my mind whether built-in plugins could support @theneva If this change to the assertion works for you, can you please close the issue? |
Yeah, I know. @theneva is a coworker of mine, he showed me Jest's process abort using React (though rendering in jsdom, so kinda similar), the example in the OP is a smaller reproduction of what we believe to be the same issue.
I might agree with not serializing it by default if the hit is high, but currently jest aborts, which is not OK (the example in the OP just takes a stupid amount of time before giving an error). I'd rather throw and tell the user to add a custom plugin. However, is the hit adding Fun fact,
|
Y’all taught me a new DOM interface, for sure. Was the original error also array-like object versus array as received value?
Ja, good thought. I need to see if plugin can detect |
No, the node process crashes because it runs out of memory
I'd prefer implementing support for the collections in https://github.com/facebook/jest/blob/master/packages/pretty-format/src/plugins/dom_collection.js and potentially pulling it if it turns out that this slows down e.g. test suites. Bailing early should be the backup plan 🙂 |
Yes, I agree with you to support array-like collections in the plugin. Ha ha, wrong day to search for other related classes under Web APIs on MDN:
|
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. |
🐛 Bug Report
Snapshotting the
options
property on a<select>
element breaks inpretty-format
.Jest v22.1.2 on node v7.4.0 (the provided repl.it, see below) fails with:
Jest v23.6.0 on Node 10.11.0 (locally) fails with:
To Reproduce
Create a
<select>
with at least one<option>
, then attempt to snapshotselect.options
:Expected behavior
A snapshot should be created with the content of the options collection.
Link to repl or repo (highly encouraged)
https://repl.it/repls/CurvyKnobbyModel
Run
npx envinfo --preset jest
Paste the results here:
System: OS: macOS High Sierra 10.13.6 CPU: x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Binaries: Node: 10.11.0 - /usr/local/bin/node Yarn: 1.10.1 - /usr/local/bin/yarn npm: 6.4.1 - /usr/local/bin/npm npmPackages: jest: ^23.6.0 => 23.6.0
The text was updated successfully, but these errors were encountered: