摘要: If you have a component that makes HTTP requests, you’ll probably want to mock those out for UI unit and integration tests. Let’s see how to use jest’ 阅读全文
posted @ 2020-04-30 19:24 Zhentiw 阅读(305) 评论(0) 推荐(0)
摘要: While not all of accessibility testing of a web application can be automated, much of it can be and quite easily using axe-core and jest-axe. Let’s se 阅读全文
posted @ 2020-04-30 19:09 Zhentiw 阅读(249) 评论(0) 推荐(0)
摘要: You can use 'rerender' for a component when its props changed. Then if you wnat to check the alert message has gone when we rerender, you need to use 阅读全文
posted @ 2020-04-30 18:57 Zhentiw 阅读(200) 评论(0) 推荐(0)
摘要: The User Event module is part of the Testing Library family of tools and lets you fire events on DOM nodes that more closely resemble the way your use 阅读全文
posted @ 2020-04-30 18:45 Zhentiw 阅读(154) 评论(0) 推荐(0)
摘要: The fireEvent utility in React Testing Library supports all the events that you regularly use in the web (change, click, etc.). Let’s see how we can t 阅读全文
posted @ 2020-04-30 18:00 Zhentiw 阅读(407) 评论(1) 推荐(0)
摘要: While you’re writing your tests it can be helpful to see what the DOM looks like. You can do this with React Testing Library’s debug function which wi 阅读全文
posted @ 2020-04-30 17:50 Zhentiw 阅读(193) 评论(0) 推荐(0)
摘要: Component: import React from 'react' function FavoriteNumber({ min = 1, max = 9 }) { const [number, setNumber] = React.useState(0) const [numberEntere 阅读全文
posted @ 2020-04-30 17:47 Zhentiw 阅读(186) 评论(0) 推荐(0)
摘要: We can use 'jest.spyOn', similr to 'spyOn' in Jasmine. jest.spyOn(utils, 'getWinner') We get 'getWinner' as a method. Jest has mockImplementation: // 阅读全文
posted @ 2020-04-30 15:01 Zhentiw 阅读(219) 评论(0) 推荐(0)
摘要: import { SET_STATUS, FETCH_FULFILLED, FETCH_FAILED, RESET, } from '../actions/beerActions' import lensProp from 'ramda/es/lensProp' import set from 'r 阅读全文
posted @ 2020-04-30 02:00 Zhentiw 阅读(151) 评论(0) 推荐(0)
摘要: Epic: import { ofType } from 'redux-observable' import { of, concat, merge, fromEvent, race, forkJoin } from 'rxjs' const buildAPI = (apiBase, perPage 阅读全文
posted @ 2020-04-30 01:57 Zhentiw 阅读(405) 评论(0) 推荐(0)
摘要: Let's say we are using 'React.lazy()' to lazy load some Router: const Home = React.lazy(() => import('./screens/home')) const User = React.lazy(() => 阅读全文
posted @ 2020-04-30 00:27 Zhentiw 阅读(346) 评论(0) 推荐(0)
摘要: Our <Query /> component is a render prop based component that the <User /> component uses. But because it doesn't render anything, we can actually jus 阅读全文
posted @ 2020-04-30 00:15 Zhentiw 阅读(228) 评论(0) 推荐(0)