-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
Do you want to request a feature or report a bug?
I suppose this could be considered a feature request.
What is the current behavior?
Jest throws an error when I try to serialize a DOMStringMap or NamedNodeMap. The output is:
RangeError: Invalid string length
If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install and yarn test.
The test is very simple:
const el = document.createElement('div');
el.dataset.foo = 'bar';
expect(el.dataset).toMatchSnapshot();Same behavior for NamedNodeMap
const el = document.createElement('div');
el.dataset.foo = 'bar';
expect(el.attributes).toMatchSnapshot();What is the expected behavior?
Jest should be able to serialize DOMStringMap and NamedNodeMap so I can reduce snapshot output to the values which I am interested in.
As a workaround, I spread the values into a new object.
expect({...el.dataset}).toMatchSnapshot();Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.