i am using jest-serializer-html-string
and preact-render-to-string
for my snapshots tests but the problem is that when i run the snapshot test update for a component that have htmlFor="" like this:
<Label htmlFor={input.name}>{label}</Label>
it generates a snapshot like this :
<label for="checkbox">label</label>
here is my jest snapshot configuration in package json:
"snapshotSerializers": [
"jest-serializer-html-string"
],
and i am creating my snapshot tests like that:
it(`renders markup correctly`, () => {
const tree = renderer(<SomeComponent />);
expect(tree).toMatchSnapshot();
});
the problem is that htmlFor
is converted to for
in the snapshot file and that is causing me problems.
it was converted right before but recently, it starts to convert it to for
, hope there is any way to keep htmlFor
attribute as it is in the snapshots tests.
it seems that the right behaviour is to convert htmlFor
to for in snapshots.
so I managed to solve the problem by converting all htmlFor
attributes I have in my components to for
attribute.