我正在尝试测试一个Redux动作但是我在终端中出现了这个错误:
AssertionError:期望{type:' LOG_IN',电子邮件:'电子邮件' }等于{type:' LOG_IN',电子邮件:'电子邮件' } + expected - actual
问题:两个对象似乎相同,它们具有相同的值,具有相同的值。我希望他们是平等的。但据报道它们并不相同。
myActions.js
import { LOG_IN,LOG_OUT } from './actionTypes';
export function logIn(email) {
return {
type: LOG_IN,
email: email
};
}
userReducer.test.js
import * as actions from '../actions/userActions';
import * as types from '../actions/actionTypes';
import user from '../reducers/userReducer';
describe('user login reducer test', () => {
it('should update initialState to include email', () => {
const email = 'email'
const expectedAction = {
type: LOG_IN,
email: 'email'
}
const result = actions.logIn(email);
expect(result).to.equal(expectedAction);
})
})
actiontypes.js
export const LOG_IN = 'LOG_IN';
export const LOG_OUT = 'LOG_OUT';