README文件中的演示示例使用一个名为put()而不是dispatch()在worker saga中的函数.
...
// worker Saga: will be fired on USER_FETCH_REQUESTED actions
function* fetchUser(action) {
try {
const user = yield call(Api.fetchUser, action.payload.userId);
yield put({type: "USER_FETCH_SUCCEEDED", user: user});
} catch (e) {
yield put({type: "USER_FETCH_FAILED", message: e.message});
}
}
...
Run Code Online (Sandbox Code Playgroud) 我正在用 cypress 测试一个网络应用程序。
我登录了我的beforeEach函数。然后,在我的不同测试中,我从cy.visit('mysite.com/url').
我的问题是登录后,网站重定向到网站的特定页面。这种重定向发生在cy.visit我的测试之后。因此,我的测试在重定向页面上运行,它们失败了。
重定向似乎与我可以等待的任何请求无关。
我最终得到了,cy.wait(3000)但不是很令人满意。我的测试有时会失败,因为重定向可能需要 3 秒以上。我不想增加那个时间,因为运行我的测试需要很长时间。
有没有办法做这样的事情:
while (!cy.url().eq('mysite.com/redirection-url')) {
cy.wait(300);
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Jest并尝试比较是否将我的身体格式化为对象的结构{cart_id: 'string', payment: 'string', site: 'string'},但是当我执行以下操作时:
test('paymentRequest should be formatted', () => {
expect(paymentRequest(paymentBody)).objectContaining({
cart_id: expect.any(String),
payment: expect.any(String),
site: expect.any(String)
})
})
Run Code Online (Sandbox Code Playgroud)
我收到上面的错误。我查看了文档,但不确定是否要像他们的示例中的示例一样进行toBeCalled处理:https ://facebook.github.io/jest/docs/en/expect.html#expectobject containsobject
我是 React 的新手,并用他们的 API 构建了一个 Spotify 应用程序。我正在使用 Redux Promise 来解决所有的承诺。当我在数据的减速器中对其进行控制台时,我可以看到数据。但是当我检查我的控制台时,它显示 Connect(App) 中的 mapDispatchToProps() 必须返回一个普通对象。而是收到了 [object Promise]。我在想是不是因为我使用的是 Redux Promise 与 thunk,但它不应该也能解决它们吗?
减速器
import { NEW_RELEASES } from '../actions/types';
export default function(state = [] , action){
console.log(action)
switch(action.type){
case NEW_RELEASES:
return [ action.payload.data, ...state ];
}
return state
}
Run Code Online (Sandbox Code Playgroud)
店铺
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import App from './App';
import reducers from './reducers';
import ReduxPromise from …Run Code Online (Sandbox Code Playgroud) 我是 Cypress 的新手,我需要从我的应用程序中提取文本的动态部分。
<body>
<div>Hello World greeting number 9123</div>
</body>
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我需要从 div 中提取 9123,以便稍后在我的测试中使用。知道我应该怎么做吗?
我目前正在尝试在赛普拉斯测试时找到鼠标的位置。我正在尝试使用 WebGL 模型,因为我无法单独抓取这些模型并移动它们,所以我正在考虑使用页面坐标/鼠标位置,以便它足够接近。
我在 Cypress 的 github 上发现了一个关于此问题的已关闭问题,但它无法安装,因此如果你们中有人知道为什么它会抛出附加错误,或者有更简单的方法来找出位置,请告诉我!我们将不胜感激。
(抱歉,钢笔标记不好;试图写下我的姓氏)
我运行了已关闭问题中给出的代码:
npm i -D cypress-mouse-position
然后将它们添加到两个文件中:
cypress/plugins/index.js
module.exports = (on, config) => {
# ...
initCypressMousePositionPlugin(on);
# ...
}
Run Code Online (Sandbox Code Playgroud)
cypress/support/index.js
import 'cypress-mouse-position/commands';
Run Code Online (Sandbox Code Playgroud) 我正在尝试自己学习React,但是在为我的网页创建简单的导航栏时遇到了麻烦。我想将导航栏放置在index.jsx文件中,以便它显示在页面顶部;以下是index.jsx文件中的内容。
import React from 'react'
import { render } from 'react-dom'
import App from './components/App';
const node = document.querySelector('#app')
render(<App />, node);
Run Code Online (Sandbox Code Playgroud) 我需要在CSS文件的以下div上应用不同的背景颜色,而不使用类或ID
<div>This is Blue</div>
<div>This is Yello</div>
<div>This is Red</div>
Run Code Online (Sandbox Code Playgroud)
没有使用JavaScript或jQuery,有没有办法做到这一点
有人可以帮助我理解为什么:
const people = [{
name: "Carly",
yearOfBirth: 1942,
yearOfDeath: 1970,
},
{
name: "Ray",
yearOfBirth: 1962,
yearOfDeath: 2011,
},
{
name: "Jane",
yearOfBirth: 1912,
yearOfDeath: 1941,
},
];
const findTheOldest = function(array) {
let alivePeople = array.filter(function(person) {
console.log(person.yearOfDeath);
if (person.yearOfDeath === true) {
console.log(person);
return true;
}
});
return alivePeople;
};
console.log(findTheOldest(people))Run Code Online (Sandbox Code Playgroud)
正在显示https://i.stack.imgur.com/H3p5Q.png?
我期望它返回 people 数组中的所有对象。我试图编写代码来过滤掉没有死亡一年的人。
我正在尝试创建一个div,用户可以输入一些内容,内容长度最多只能扩展到300px(来自LHS)和高度100px.如果内容超过该内容,它应该开始在剩余的空间中显示它(如图所示的RHS).我不想创建多个div,因为它是一个CMS,用户只需按照自己的意愿输入文本,并且在填充一定高度后应自动将内容传播到第二个div.没有脚本可以实现吗?我试图尽可能地避免脚本
这是我到目前为止尝试的代码.但只能包装一行.不是第二个
div{
width:300px;
max-height:100px;
overflow:hidden;
text-align:justify;
word-break: break-all;
}Run Code Online (Sandbox Code Playgroud)
<div>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model …Run Code Online (Sandbox Code Playgroud)我有一个具有几个子组件的父组件。为子组件传递的道具都是相同的。例如
<TextQuestion questionInfo={this.props.questionInfo} key={this.props.questionInfo.module_question_id} handleChange={this.handleChange} />
<DropDown questionInfo={this.props.questionInfo} key={this.props.questionInfo.module_question_id} handleChange={this.handleChange} />
<Checkbox questionInfo={this.props.questionInfo} key={this.props.questionInfo.module_question_id} handleChange={this.handleChange} />
Run Code Online (Sandbox Code Playgroud)
有没有更有效的方法可以做到这一点?可能是一个返回道具并被添加到子组件的函数调用?
javascript ×10
reactjs ×4
cypress ×3
css ×2
html ×2
arrays ×1
e2e-testing ×1
filter ×1
jestjs ×1
jquery ×1
navbar ×1
object ×1
react-redux ×1
redux ×1
redux-saga ×1
testing ×1
wait ×1