在开玩笑测试中遇到错误

时间:2017-09-26 11:57:17

标签: javascript testing jest

我正在使用ARc入门套件(https://github.com/diegohaz/arc)并尝试测试我的容器并出现此错误。

我有contianer:

import {connect} from 'react-redux';
import { addTodoRequest } from 'store/actions';
import { AddTodo } from 'components'

export const mapDispatchToProps = {
  addTodo: addTodoRequest
}


export default connect(null, mapDispatchToProps)(AddTodo)

并测试它

import {mapDispatchToProps} from '../AddTodoContainer';
import { addTodoRequest } from 'store/actions';

describe('AddTodoContainer tests', () => {
  it('mapDispatchToProps test', () => {
    expect(mapDispatchToProps).toEqual({addTodo: addTodoRequest})
  })
})

出现此错误:

● AddTodoContainer tests › mapDispatchToProps test

    TypeError: iterator.next is not a function

      at printIteratorEntries (node_modules/pretty-format/build/collections.js:170:183)
      at printImmutableEntries (node_modules/pretty-format/build/plugins/immutable.js:44:39)
      at Object.<anonymous>.exports.serialize (node_modules/pretty-format/build/plugins/immutable.js:179:12)
      at printPlugin (node_modules/pretty-format/build/index.js:245:10)
      at printer (node_modules/pretty-format/build/index.js:290:12)
      at printObjectProperties (node_modules/pretty-format/build/collections.js:180:21)
      at printComplexValue (node_modules/pretty-format/build/index.js:232:42)
      at prettyFormat (node_modules/pretty-format/build/index.js:446:10)
      at pass (node_modules/expect/build/matchers.js:429:49)
      at getMessage (node_modules/expect/build/index.js:107:16)
      at Object.throwingMatcher [as toEqual] (node_modules/expect/build/index.js:215:23)
      at Object.<anonymous> (src/containers/__tests__/AddTodoContainer.test.js:6:50)

如果我是console.log(mapDispatchToProps)

TypeError: Cannot convert a Symbol value to a string

  at Proxy.<anonymous> (private/jest/actionsMock.js:5:67)
  at formatValue (util.js:351:36)
  at formatProperty (util.js:792:15)
  at util.js:652:12
  at Array.map (native)
  at formatObject (util.js:651:15)
  at formatValue (util.js:591:16)
  at inspect (util.js:185:10)
  at exports.format (util.js:71:24)
  at Object.<anonymous> (src/containers/__tests__/AddTodoContainer.test.js:9:13)

0 个答案:

没有答案