jest-community / jest-snapshots-svg

Take a React component tree, and render it into an SVG.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

handle cyclic references

orta opened this issue · comments

describe("layout", () => {
  it("renders as expected", () => {
    const homeComponent = renderer.create(<Home home={homeProps(3, 3, 3).home}/>).toJSON()

    expect(homeComponent).toMatchSnapshot()
    console.log(homeComponent)

    const jsonRep = JSON.stringify(homeComponent)
    fs.writeFileSync("home-component.json", jsonRep)

    expect(homeComponent).toMatchSVGSnapshot(620, 480)
  })
})

Can't even generate JSON:

  ● layout › renders as expected

    TypeError: Converting circular structure to JSON
        at JSON.stringify (<anonymous>)
      
      at Object.it (src/lib/containers/__tests__/file:/Users/orta/dev/projects/artsy/ios/emission/src/lib/containers/__tests__/home-tests.tsx:43:26)