#snapshots and testing lib react strange outputs

1 messages · Page 1 of 1 (latest)

undone swift
#

After converting to bun and running bun test.

My snapshots are massive json document fragments instead of pretty html, why is this happening and is there a way to fix this.

const { asFragment, container } = render(
      <Suspense fallback={<Text text='Loading...' />}>
        <LazyText text='hi' />
      </Suspense>
    );

    expect(asFragment()).toMatchSnapshot();

this is the code im running and it outputs the contents of the file i attached

#

How do i make this look like it used to which is

exports[`useWhyChange stays quiet if updates never happen 1`] = `
<DocumentFragment>
  Loading...
</DocumentFragment>
`;

exports[`useWhyChange stays quiet if updates never happen 2`] = `
<DocumentFragment>
  hi
</DocumentFragment>
`;
undone swift
#

Bump

woeful tartan
#

What's render in your test file?

undone swift
#

@woeful tartan render is the render function from @testing-libary/react

undone swift
#

Any idea as to why it's not outputting as HTML?

undone swift
#

Bump need help?

undone swift
#

Bump

tropic lichen
#

Before anything, did you confirm this works in node + jest?

undone swift
#

i thought it did give me 2 secs and ill check it on my node jest branch

tropic lichen
#

Yeah do that

undone swift
#

just got to rebuild the packages as it takes like 3 mins on node

#

Yeah works fine on Node i get this output on node

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`useWhyChange stays quiet if updates never happen 1`] = `
<DocumentFragment>
  Loading...
</DocumentFragment>
`;

exports[`useWhyChange stays quiet if updates never happen 2`] = `
<DocumentFragment>
  hi
</DocumentFragment>
`;

#

which is what it should be

#

@tropic lichen

tropic lichen
#

Got it, there might be a missing property in how you're running bun test or you definitely find a bug. I would make an issue if confirmed that it's not something missing in the cli arguments, they fix stuff pretty fast

undone swift
#

i just run bun test there isnt any arguments that i can think of.

#

the only thing im using different is happydom.ts for dom support

#

so maybe its a happy dom issue

#

is there a way i can mock the dom without using happy dom

undone swift
undone swift
#

I have found a solution to this but it needs some sort of official stance on it. I have added a comment onto the issue above.

woeful tartan