当我在描述和值部分输入详细信息并点击绿色箭头时,我收到错误。有人能看看我这边出了什么问题吗!请参考以下链接https://jsfiddle.net/5wdb0eco/错误消息:app.js:86 Uncaught TypeError: Cannot read property 'replace' of undefinedat Object.addListItem (app.js:86)at HTM
2020-03-13
我收到TypeError: (0 , _expect2.default)(...).toBeDefined 不是函数,通常的修复方法是将 /'node_modules'/ 更改为不使用引号。这没有帮助。输出是$ jestFAIL __tests__/test_fake_add_component.js● Add fake tests › Add › Add requires onAdd prop
2017-05-30
我正在使用 Enzyme/Jest 为容器上的一个函数编写测试,该函数通过复选框组件的 onChange 触发。我试图模拟“更改”,但是不知何故,“更改”并未触发要调用的 onChange 函数。不确定这里发生了什么……我尝试将模拟更改为“单击”,删除目标对象,但仍然不起作用。容器export class Data extends React.PureComponent {constructor(
2017-07-19
我第一次尝试在 React 中运行一些测试,但是收到了一些错误,但不知道这些是什么。2018-05-30 16:47 node[3217] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)2018-05-30 16:47 node[3217
2018-05-30
我的 reactjs 组件 Alerts 按日期/名称对 json 数据进行排序,该组件可以正常工作,但单元测试无法正常工作,它在实用程序函数中中断了该测试,这就是问题所在。Alertscomponent 的一部分使用了实用程序函数 createAlertsWithName 的一部分。它所做的就是将 2 个数组“合并”为 1 个(因为 alerts 数组不包含名称,而我需要它进行排序):expor
2019-01-27
我正在尝试使用 jest / digest 运行 React JS 的单元测试。测试目前失败。不太清楚为什么,也许我没有正确调用 expect(wrapper.find)。这是我的测试的一部分: File.test.jsit('renders modal when open flag is true', () => {const props = { isOpen: true };const wra
2019-02-04
我正在遵循 Jest 的文档,但是我无法解决以下错误。expect(dummyFunction).toHaveBeenNthCalledWith 不是函数除非我遗漏了什么,否则我很确定我已将dummyFunction正确设置为jest.fn()。我甚至在测试中使用dummyFunction之前就对其输出进行了控制台处理,这就是输出。dummyFunction console.log 输出 {
我在测试 React 应用时遇到此错误:TypeError:expect(...).toBeString 不是函数。我使用的代码是:import React from "react";import { configure, shallow } from "enzyme";import Adapter from "enzyme-adapter-react-16";import Footer from
tsconfig.json{"extends": "./node_modules/pcf-scripts/tsconfig_base.json","compilerOptions": {"typeRoots": ["node_modules/@types"],"allowJs": true,"skipLibCheck": true,"esModuleInterop": true,"allowSyn
2020-03-05
我有一个Users组件,其中包含我从服务器获取的用户数据,如下所示export const Users: FunctionComponent<any> = () => {const [usersData, setUsersData] = useState<TableConfig>();let initialLoad = false;useEffect(() => {if (!usersData)
2020-10-07
我在使用 toHaveBeenCalled 时遇到错误,请纠正我哪里出错了code:jsx <itemonClick={ load ? undefined : onClick}>testtest('render', () => {const MockItems = jest.fn()const prop = {onClick: MockItems,}const onclickProp= outp
2020-11-18
我想这真的很简单,但我似乎无法实现它。我有这个代码片段...var choice = location.href.split("?")[1].split("=")[1];它工作正常,直到“选择”为空,然后抛出以下错误....TypeError: location.href.split(...)[1] is undefined我理解这是因为您不能对未定义的变量调用拆分,我认为我的解决方案是存储变量,
2013-02-05
因此,我尝试使用一个简单的 javascript 字谜函数来比较两个字符串,但是每当我尝试在排序函数中使用 .split 操作时,我的代码都会出错: var wd;function sortword(word){wd = word;var w = wd.split("");w.sort();return w;}导致“TypeError:undefined 不是对象(评估‘wd.split’)”ht
2014-11-14
我尝试进行身份验证以连接到 Google API 以便使用 Google Analytics。这是我的代码:'use strict'const fs = require('fs')const open = require('open')const Fs = require('fs')const Google = require('googleapis')const Url = require('u
2015-11-29
使用下面定义的配置,运行webpack时控制台会抛出一个错误:TypeError: element.loader.split is not a functionwebpack.config.jsmodule.exports = {devtool: 'eval',entry: {chiffr: getEntrySources(['./src/index',]),},output: {path: pa
2016-07-05