jest-serializer-path icon indicating copy to clipboard operation
jest-serializer-path copied to clipboard

configure replacement of `\`

Open hipstersmoothie opened this issue 7 years ago • 4 comments

I use the \ in some of my snapshots. i never test on windows so i don't need the character to be replaced. would be nice to be able to turn this functionality off somehow

hipstersmoothie avatar Jun 22 '18 23:06 hipstersmoothie

Hi, could you provide an example of how you're using \ in your snapshots? I'm guessing it's being affected by the normalization done with the slash package.

tribou avatar Jun 28 '18 04:06 tribou

it's an odd use case with special syntax

snapshot before this plugin:

"body": "# First Page /.firstPage\"

snapshot after this plugin:

"body": "# First Page /.firstPage/"

hipstersmoothie avatar Jun 28 '18 18:06 hipstersmoothie

If you want to ensure that \ has not been changed / to in your output, I would recommend writing a test that shows that outside of a snapshot.

const object = {
    body: '# First Page /.firstPage\\',
    other: true,
};

expect(object).toMatchSnapshot();
expect(object.body).toEqual('# First Page /.firstPage\\');

chrisblossom avatar Jun 28 '18 22:06 chrisblossom

Just chiming in that this is still an issue and is non trivial to debug. Would be nice to be able to configure it like @hipstersmoothie requested

Specifically, this is a problem if you test regular expressions

Aghassi avatar May 10 '23 14:05 Aghassi