最近我与Jest (23.5.0)和WebStorm (2018.2.3) intellisense发生了争执。对于所有Jest方法(例如toHaveBeenCalledWith、toHaveLength),我收到一个Unresolved function or method "xxx"错误。
我让@types/jest在我所有的项目中工作,除了我最近的一个项目,它在我退出CRA后就停止了工作。奇怪的是,如果我删除了所有项目的node_modules,Jest上的intellisense就能正常工作--但一旦运行yarn install,intellisense就会停止工作,并
我想用酶来测试我的反应--世博管理项目中的天然成分。我跟踪的文档,但现在我得到了:
Test environment found at "/Users/raarts/myproject/node_modules/jest-environment-enzyme/lib/index.js" does not export a "getVmContext" method, which is mandatory from Jest 27. This method is a replacement for "runScript".
我的猜测是,jest-e
我正试着在反应中做些玩笑/酶试验
我有个测试:
import React from 'react';
import { shallow } from 'enzyme';
import { mount } from 'enzyme'
import WorkOutForm from './workOutForm';
describe('WorkOutForm', () => {
it('should start a new workoutForm with empty state'
我有一个反应成分:
export class Test extends React.Component<TestProps, TestState> {
...
//the constructor sets the state initially
constructor(props: TestProps) {
this.state = {
thisIsAState: 1;
}
}
//this function updates the state given the num param
updateStat
我想测试,看看一个图像是否正确地加载到一个反应应用程序。我已经决定检查嵌套在React组件中的img元素的img属性。我想使用Jest测试框架,如果需要的话,使用酶测试工具。
通过深入研究浅反应测试组件的Object.keys,我能够想出以下解决方案。我不确定的行是用星号表示的。
import React from 'react';
import {shallow} from 'enzyme';
import App from './App';
it('should have the logo image',
写测试我的反应应用与Jest &酶已经沉重打击我,因为我无法建立酶与Jest。
下面是当我在测试文件import React from 'react';中使用这一行时会遇到的错误
FAIL src\App.test.js
● Test suite failed to run
D:\experiements\react\my-app\src\App.test.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,g
我用的是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 {
我正试着用酶和玩笑为反应的天然成分写一个基本的测试。我得到了一个错误,暗示酶没有被正确地导入:
● SearchPage › it starts spinner when page is loading
- ReferenceError: _enzyme is not defined
at Spec.eval (__tests__/basic-test.js:12:16)
1 test failed, 0 tests passed (1 total in 1 test suite, run time 1.113s)
npm ERR! Test failed. See ab
我对单元测试很陌生,我刚刚开始为我的react项目编写单元测试。我的项目是使用创建-反应-应用程序创建的,我已经安装了所需的测试库,如酶、酶适配器-Reacti-16和jest-酶。
我在src目录中创建了一个新文件setupTests.js,并添加了酶配置。
当我试图使用命令npm test运行单元测试时,我收到了下面的错误,因此我的测试失败了。
src/App.test.js
● Test suite failed to run
Cannot find module '@babel/polyfill/lib/noConflict' from 'index.js