question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

0.26.2 to 0.27.0 causes node 10 to fail

See original GitHub issue

I got a setup checking both node 10, 12 and 14

The newest version keeps failing on node 10 but not the other node version.

I hope it’s okay that I provide a link to the github action that fails - since it will have much more details than I can provide:

https://github.com/Norfeldt/react-kitchen-sink/pull/113/checks?check_run_id=2007437692

Screenshot 2021-03-02 at 16 01 53
yarn run v1.22.5
$ react-scripts test --watchAll=false --coverage
FAIL src/components/SearchBox/index.test.jsx (5.78 s)
  ● Console

    console.warn
      [MSW] Found a redundant usage of query parameters in the request handler URL for "GET https://api.flickr.com/services/rest/?method=flickr.photos.search". Please match against a path instead, and access query parameters in the response resolver function:
      
      rest.get("/services/rest/", (req, res, ctx) => {
        const query = req.url.searchParams
        const method = query.get("method")
      })

       9 | 
      10 | const fakeServer = setupServer(
    > 11 |   rest.get('https://api.flickr.com/services/rest/?method=flickr.photos.search', (req, res, ctx) =>
         |        ^
      12 |     res(ctx.status(200), ctx.json({ photos: { photo: [1, 2, 3] } }))
      13 |   )
      14 | )

      at RestHandler.checkRedundantQueryParameters (node_modules/msw/lib/umd/index.js:6688:23)
      at new RestHandler (node_modules/msw/lib/umd/index.js:6678:16)
      at Object.get (node_modules/msw/lib/umd/index.js:7716:18)
      at Object.<anonymous> (src/components/SearchBox/index.test.jsx:11:8)

  ● it calls Flickr REST request when submitting search term and clears search field

    Network Error

      at createError (node_modules/axios/lib/core/createError.js:16:15)
      at XMLHttpRequestOverride.handleError [as onerror] (node_modules/axios/lib/adapters/xhr.js:84:14)
      at XMLHttpRequestOverride.trigger (node_modules/node-request-interceptor/src/interceptors/XMLHttpRequest/XMLHttpRequestOverride.ts:160:23)
      at node_modules/node-request-interceptor/src/interceptors/XMLHttpRequest/XMLHttpRequestOverride.ts:259:18

  ● it calls Flickr REST request when submitting search term and clears search field

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    Expected: [1, 2, 3]

    Number of calls: 0

    <html>
      <head />
      <body>
        <div>
          <section
            class="container"
          >
            <form
              action="none"
            >
              <input
                aria-label="Search Flickr"
                placeholder="What are you looking for?"
                value="Finding Walley"
              />
              <button
                aria-label="Submit search"
                type="submit"
              >
                <svg
                  height="1em"
                  viewBox="0 0 46 46"
                  width="1em"
                  xmlns="http://www.w3.org/2000/svg"
                >
                  <g
                    fill="currentColor"
                    fill-rule="evenodd"
                  >
                    <path
                      d="M14.6 28.6c-3.8 0-7.4-1.5-10.1-4.2C1.8 21.7.3 18.1.3 14.3S1.8 6.9 4.5 4.2C7.2 1.5 10.8 0 14.6 0S22 1.5 24.7 4.2c2.7 2.7 4.2 6.3 4.2 10.1s-1.5 7.4-4.2 10.1c-2.7 2.7-6.3 4.2-10.1 4.2zm0-26.5c-3.3 0-6.4 1.3-8.7 3.6-2.3 2.3-3.6 5.4-3.6 8.7 0 3.3 1.3 6.4 3.6 8.7 2.3 2.3 5.4 3.6 8.7 3.6 3.3 0 6.4-1.3 8.7-3.6 2.3-2.3 3.6-5.4 3.6-8.7 0-3.3-1.3-6.4-3.6-8.7-2.3-2.3-5.5-3.6-8.7-3.6zM39.7 45.9c-.5 0-1-.2-1.4-.6L26.1 33.1c-.8-.8-.8-2 0-2.8l4.4-4.4c.8-.8 2.1-.8 2.8 0L45.6 38c.8.8.8 2 0 2.8l-4.4 4.4c-.5.5-1 .7-1.5.7zM32 27.3l-4.4 4.4 12.2 12.2 4.4-4.4L32 27.3z"
                      fill-rule="nonzero"
                    />
                    <path
                      d="M24.654 23.443l4.95 4.95-1.414 1.414-4.95-4.95z"
                    />
                  </g>
                </svg>
              </button>
            </form>
          </section>
        </div>
      </body>
    </html>

      42 | 
      43 |   await waitFor(() => {
    > 44 |     expect(fakeSetPhotos).toHaveBeenCalledWith([1, 2, 3])
         |                           ^
      45 |     expect(inputField.value).toBe('')
      46 |   })
      47 | })

      at src/components/SearchBox/index.test.jsx:44:27
      at runWithExpensiveErrorDiagnosticsDisabled (node_modules/@testing-library/dom/dist/config.js:51:12)
      at checkCallback (node_modules/@testing-library/dom/dist/wait-for.js:127:77)
      at checkRealTimersCallback (node_modules/@testing-library/dom/dist/wait-for.js:119:16)
      at Timeout.task [as _onTimeout] (node_modules/jsdom/lib/jsdom/browser/Window.js:391:19)
import React from 'react'
import { render, fireEvent, waitFor, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { rest } from 'msw'
import { setupServer } from 'msw/node'

import SearchBox from '.'
import { act } from 'react-dom/test-utils'

const fakeServer = setupServer(
  rest.get('https://api.flickr.com/services/rest/?method=flickr.photos.search', (req, res, ctx) =>
    res(ctx.status(200), ctx.json({ photos: { photo: [1, 2, 3] } }))
  )
)

beforeAll(() => fakeServer.listen())
afterEach(() => fakeServer.resetHandlers())
afterAll(() => fakeServer.close())

test('an input field with a placeholder', () => {
  const { getByLabelText, getByPlaceholderText } = render(<SearchBox />)

  expect(getByLabelText('Search Flickr')).toBeInTheDocument()
  expect(getByPlaceholderText('What are you looking for?')).toBeInTheDocument()
})

test('a submit search term button appearance', () => {
  const { getByLabelText } = render(<SearchBox />)

  expect(getByLabelText('Submit search')).toBeInTheDocument()
})

test('it calls Flickr REST request when submitting search term and clears search field', async () => {
  const fakeSetPhotos = jest.fn(() => {})
  const { getByRole } = render(<SearchBox setPhotos={fakeSetPhotos} />)

  const inputField = getByRole('textbox', { name: /search flickr/i })
  const submitButton = getByRole('button', { name: /submit search/i })

  userEvent.type(inputField, 'Finding Walley')
  fireEvent.click(submitButton)

  await waitFor(() => {
    expect(fakeSetPhotos).toHaveBeenCalledWith([1, 2, 3])
    expect(inputField.value).toBe('')
  })
})
test('does not try to fetch if search term is empty', () => {
  const { getByRole } = render(<SearchBox setPhotos={() => {}} />)
  const inputField = getByRole('textbox', { name: /search flickr/i })
  const submitButton = getByRole('button', { name: /submit search/i })

  expect(inputField.value).toEqual('')
  // fireEvent.click(submitButton)

  // TODO: finish up this one
})

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisguttandincommented, Mar 4, 2021

I had a quick look at the cookies package. Apparently it doesn’t make use of Object.fromEntries(). It looks like it’s used inside msw instead.

https://github.com/mswjs/msw/blob/10cccc03f18e462dfaa12d42ded6ccc0a9e432f9/src/utils/request/setRequestCookies.ts#L9

1reaction
dagadbmcommented, Mar 2, 2021

Would be nice on the documentation to add the minimum requirements for msw to run on node (and browser while you are at it)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't install Sharp - node.js - Stack Overflow
I have solved this error by downgrading node version to 10.0.0 . It really works!
Read more >
Unable to run example - Google Groups
I ran "npm install", which failed, and then "node server.js" - which also failed: ... 10 verbose from cache E:\Bin\Desktop\everyauth-master\package.json.
Read more >
NEWS
Fixed an issue with custom classes assigned to dataframes causing an vctrs error when using dplyr functions. The classes are no longer needed...
Read more >
Changelog — lifelines 0.27.4 documentation
Fixed some overflow issues with AalenJohansenFitter 's variance calculations when using large datasets. Fixed an edgecase in AalenJohansenFitter that causing ...
Read more >
Troubleshooting App Deployment Errors - Dash Python
Failed to find attribute 'server' in 'app'. git push plotly main is successful, but the deployment fails and your app logs display [2022-11-10...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found