nfl / react-helmet

A document head manager for React
MIT License
17.33k stars 659 forks source link

Helmet.peek() returns undefined on CI server #461

Closed bitttttten closed 5 years ago

bitttttten commented 5 years ago

Locally the inline snapshot passes, but on circleci is fails as Helmet.peek() returns undefined.

 FAIL  
  ● <Privacy> › renders meta tags

    expect(received).toMatchInlineSnapshot(snapshot)

    Snapshot name: `<Privacy> renders meta tags 1`

    - Snapshot
    + Received

    - Object {
    -   "baseTag": Array [],
    -   "bodyAttributes": Object {},
    -   "defer": true,
    -   "encode": true,
    -   "htmlAttributes": Object {},
    -   "linkTags": Array [],
    -   "metaTags": Array [
    -     Object {
    -       "content": "/privacy",
    -       "property": "og:url",
    -     },
    -   ],
    -   "noscriptTags": Array [],
    -   "onChangeClientState": [Function],
    -   "scriptTags": Array [],
    -   "styleTags": Array [],
    -   "title": "Privacy Policy",
    -   "titleAttributes": Object {},
    - }
    + undefined

I omitted a lot of the data in the test below, but it highlights the point.

    test('renders meta tags',() => {
        const { getByText } = customRender(<Privacy />)
        expect(Helmet.peek()).toMatchInlineSnapshot(`
            Object {
              "baseTag": Array [],
              "bodyAttributes": Object {},
              "defer": true,
              "encode": true,
              "htmlAttributes": Object {},
              "linkTags": Array [],
              "metaTags": Array [
                Object {
                  "content": "/privacy",
                  "property": "og:url",
                },
              ],
              "noscriptTags": Array [],
              "onChangeClientState": [Function],
              "scriptTags": Array [],
              "styleTags": Array [],
              "title": "Privacy Policy",
              "titleAttributes": Object {},
            }
        `)
    })

Is this test wrong? Is it just a race condition?

react-helmet@6.0.0-beta 
react@16.8.6 
react-dom@16.8.6 
node v10.15.2
bitttttten commented 5 years ago

This can be closed, as the component was actually returning null under a certain condition which was a race condition/bug, and nothing to do with react-helmet.