Comments (13)
Thanks for the help in the workshop repo @marcosvega91. I'm working on fixing this here now :)
from react-hooks.
Actually... That reminds me!
@all-contributors please add @gugol2 for bugs
from react-hooks.
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.
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.
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.
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.
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.
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.
It should be good. I'll make a PR there
from react-hooks.
Goood 🚀
from react-hooks.
Sorry I didn't realize you wanted collaboration for this issue @kentcdodds
from react-hooks.
No worries @gugol2 :) Glad that you reported the issue!
from react-hooks.
I've put up a pull request to add @gugol2! 🎉
from react-hooks.
Related Issues (20)
- The deployed app displays 'Uncaught RangeError` HOT 1
- Needed Code Missing In Exercise 2 HOT 1
- Using template strings instead of escaping JSX HOT 1
- Changelog HOT 1
- ErrorBoundary seems to not work with development mode HOT 1
- npm ERR! code ELIFECYCLE HOT 1
- Thoughts arising from the optimization of useState HOT 1
- I guess using index as item key is considered a very bad and dangerous practice HOT 3
- Unhandled Rejection (Error): [MSW] Failed to register a Service Worker when using network IP HOT 1
- Bug report (w/ proposed solution): 02 exercise solution shows incorrect text sometimes. HOT 2
- React imports could be shorten HOT 1
- reset fails to udpate states other than 'squares' HOT 1
- [MSW] Stay integrated to browser HOT 2
- include v18 updates in next branch HOT 1
- Code syntax highlight not working on any of the workshop repos including this one. HOT 4
- workshop-setup: command not found HOT 1
- React 18 state batching HOT 1
- Exercise 6 - Extra credit 8 - use resetKeys HOT 1
- Node setup doesn't support Node.js 20 HOT 4
- local-state-key-change example has a syntax error if there's a name in local storage already HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-hooks.