我已经React和我一起工作Redux了大约3年.我也redux-thunk用于异步的东西.
而且我非常喜欢它们,但最近我注意到我项目中几乎所有的鸭子都使用相同的动作,减速器,选择器等结构.
例如 - 您有一个应用程序,它有一些用户和事务(或类似)列表,项目详细信息和编辑功能.所有这些列表或项目都有自己的鸭子(动作,减少器,选择器等).
下面的代码将更清楚地显示问题:
// ACTIONS
const const setUser = user => ({
type: types.SET_USER,
payload: user,
});
const cleanUser = () => ({ type: types.CLEAN_USER });
const fetchUser = userId => dispatch =>
dispatch(fetchApi(userRequests.get(userId)))
.then(response => dispatch(setUser(response)))
.catch(error => showNotification(error));
// delete, update, etc... user actions
// REDUCER
const userReducer = (state = null, action) => {
switch (action.type) {
case types.SET_GROUP_ITEM:
return action.payload;
case types.CLEAN_GROUP_ITEM:
return null;
default:
return state; …Run Code Online (Sandbox Code Playgroud) 我现在使用nightwatch.js,mocha.js和selenium web驱动程序进行验收测试.我需要跳过一些测试,我该怎么做?
module.exports = {
"User logs in the WebPortal": function(browser) {
browser
.url(urlAdress)
.setValue('input#login', user.login)
.setValue('input#password', user.password)
.click('button.ui-button')
.waitForElementPresent('a[href="/logout"]', middleTimer)
.getText('a[href="/logout"] span', function(result) {
(result.value).should.be.exactly("logout")
})
.end()
},
"User logs out": function(browser) {
browser
.url(urlAdress)
.setValue('input#login', user.login)
.setValue('input#password', user.password)
.click('button.ui-button')
.waitForElementPresent('a[href="/logout"]', middleTimer)
.click('a[href="/logout"]')
.waitForElementPresent('button.ui-button', middleTimer)
.getText('button.ui-button', function(result) {
(result.value).should.be.exactly("Login")
})
.end()
}
}
Run Code Online (Sandbox Code Playgroud)
那么,如何跳过一个或多个测试?谢谢你的回答.