GithubHelp home page GithubHelp logo

Comments (13)

kentcdodds avatar kentcdodds commented on July 20, 2024 1

Thanks for the help in the workshop repo @marcosvega91. I'm working on fixing this here now :)

from react-hooks.

kentcdodds avatar kentcdodds commented on July 20, 2024 1

Actually... That reminds me!

@all-contributors please add @gugol2 for bugs

from react-hooks.

kentcdodds avatar kentcdodds commented on July 20, 2024

Ha! Dang it. Well, I know what I'm working on now 😅

I've been wanting to replace this with MSW anyway.

Thanks for letting me know.

from react-hooks.

gugol2 avatar gugol2 commented on July 20, 2024

Well, apparently it works randomly...

I think replacing it with something else in the long run is a good idea.

Thanks again for this material Kent!

from react-hooks.

marcosvega91 avatar marcosvega91 commented on July 20, 2024

Hey I can submit a PR with MSW implementation if you haven't done yet.
I have only a doubt about react-workshop-app because in the setup-tests.js window.fetch should be mocked.
Maybe an env variable like process.env.MSW_ENABLED can be passed from this repo to react-workshop-app 🤔

from react-hooks.

kentcdodds avatar kentcdodds commented on July 20, 2024

I wouldn't implement this as part of react-workshop-app, but rather in this repo directly. If you'd like to work on this that would be welcome. We could have a similar setup here that we have in the bookshelf app.

from react-hooks.

marcosvega91 avatar marcosvega91 commented on July 20, 2024

MSW will be imported in this repo but on react-workshop-app side we have this https://github.com/kentcdodds/react-workshop-app/blob/master/src/setup-tests.js that requires that fetch should be mocked
we can do in this way

test('displays the pokemon', async () => {
  window.fetch.mockRestore()
  .......
  jest.spyOn(window, 'fetch')
});

but is not really good

or we can not use the setup-test file from react-workshop-app and do the following in this repo

import '@testing-library/jest-dom/extend-expect'
import '@kentcdodds/react-workshop-app/dist/jest-expect-message'
import {server} from './test/server'

beforeAll(() => {
  jest.spyOn(console, 'info')
  console.info.mockImplementation(() => {})
  server.listen()
})
afterAll(() => {
  console.info.mockRestore()
  server.close()
})

beforeEach(() => console.info.mockClear())

afterEach(() => server.resetHandlers())

from react-hooks.

kentcdodds avatar kentcdodds commented on July 20, 2024

Ah, good point. Hmmmm... I set that up before I discovered MSW. I think the right approach here is to remove that from the react-workshop-app and add it to the individual apps and then later set up MSW instead.

from react-hooks.

marcosvega91 avatar marcosvega91 commented on July 20, 2024

It should be good. I'll make a PR there

from react-hooks.

marcosvega91 avatar marcosvega91 commented on July 20, 2024

Goood 🚀

from react-hooks.

gugol2 avatar gugol2 commented on July 20, 2024

Sorry I didn't realize you wanted collaboration for this issue @kentcdodds

from react-hooks.

kentcdodds avatar kentcdodds commented on July 20, 2024

No worries @gugol2 :) Glad that you reported the issue!

from react-hooks.

allcontributors avatar allcontributors commented on July 20, 2024

@kentcdodds

I've put up a pull request to add @gugol2! 🎉

from react-hooks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.