酶wrapper.find()不是函数

时间:2018-12-13 12:20:54

标签: javascript reactjs jestjs enzyme babel-jest

运行npm run jest时出现错误

  

wrapper.find()不是函数;

然后我将mount更改为渲染或浅色,这没用,

但是当我得到shpshop时,它运行良好, 所以我想知道如何解决这个问题

let store;
let wrapper;
beforeEach(() => {
  store = configureStore({
    maker: {
      pageInfo: {
        tmplId: '',
        content: {
          pageConfig: {
            type: '',
            config: ''
          },
          modules: [],
          publishStatus: ''
        }
      },
      module: {},
      appList: applist.appList,
      templateList: [],
      data: {
        isCapturingCoverImage: false,
        dataIndirty: false
      }, // 保存的全局的信息
      message: {
        appInput: ''
      } //用来保存每一个模块对应的消息
    }
  })
  wrapper = toJson(Enzyme.shallow( 
    <Provider store={store}>
        <AppInput />
    </Provider>
  ))
})
describe('XJAppInput', () => {
  it('renders correctly', () => {
    expect(wrapper).toMatchSnapshot();
  });

  it('click work', () => {
    // console.log(wrapper)
    expect(wrapper.find('.xj-appinput-item').length).to.equal(2);
  })
})

0 个答案:

没有答案
相关问题