我写了一个有趣的酶测试如下:
import React from 'react';
import ManageDrugTermPage from '../js/manageDrugTermPage.jsx';
import toJson from 'enzyme-to-json';
describe('manage drug term page test suite', () => {
it('snapshot test', () => {
const setRouteLeaveHook =
我用的是React v15.4,babel-jest v18和酵素v2.5.1
我有一个简单的反应组件:
import React, {Component} from 'react'
import {FormattedRelative} from 'react-intl'
import pageWithIntl from '../components/PageWithIntl'
import Layout from '../components/Layout'
class About extends Component {
我曾尝试过几篇关于如何做到这一点的文章,包括airbnb react-native和jest的酶指南(分别)。(例如:、或)
但每当我尝试渲染(不是挂载,而是崩溃)任何本机组件时,我都会收到很多警告(我有多组并发测试)。警告总是关于本机道具不被识别。
Warning: Unknown props `focus`, `secureTextEntry` on <TextInput> tag. Remove these props from the element.
in TextInput (created by TextInput)
in Te
我构建React应用程序已经有一段时间了,所以我想做一个React组件库。我一直在阅读有关方法的文章,并采用了一种方法,在这种方法中,您可以使用Webpack和Babel来绑定而不使用React,因为如果您不这样做,将会出现错误,因为将导入两个版本的React (一个在组件库中,一个在应用程序中)。无论如何,我有一个Jest安装文件,其中包含以下内容: import { configure } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
configure({ adapter: ne
我的组件如下
import React from 'react';
import { connect } from 'react-redux';
import { Button } from 'react-bootstrap';
import UserActions from '../../../actions/sampleUserAction';
import UserForm from '../../../views/sample/userForm';
import UsersList from '.
允许我将应用程序状态的逻辑放在一个位置(并避免redux)。现在它看起来像这样
// Using the Context API used in react 16.3 - https://www.youtube.com/watch?v=XLJN4JfniH4
const { Provider, Consumer: ContextConsumer } = React.createContext()
class ContextProvider extends Component {
...// lot of functions ...
render() {
return (