用mocha和enzyme测试Tabs组件
测试代码:
import React from 'react'
import { expect } from 'chai'
import { shallow } from 'enzyme'
import { Tabs } from 'antd-mobile'
describe ("enzyme example", function() {
it ("use Tabs component", function() {
const wrapper = shallow(<Tabs />)
expect(wrapper.find('.foo')).to.have.length(0)
})
})

确认下使用了 babel-plugin-import
@warmhug 使用了,组件都可以正常引用。还需提供什么信息?
@sorrycc 帮忙看下
babel 没配对吧,JSX 都没解析成功。
@donnydfwx web 版本测试纯 mocha,没办法配置 webpack 的 extensions,你可以改用 https://github.com/karma-runner/karma 或者 https://github.com/ant-tool/atool-test
@eastling
兄弟这个问题是怎么解决的
@eastling 问题解决了嘛
@silentcloud 到官方sample里面加一个业务代码测试配置的例子?
在package.json 中 jest中加入
"moduleFileExtensions": [
"web.js",
"js",
"jsx",
"json"
],
主要是web.js;antd-mobile 不同于 antd,以web.js结尾。
@OPY-bbt
hello 你的意思是把mocha->转换为jest吗
@GZWZC mocha 的话,看我上面的回复
https://leozdgao.me/modern-karma/ 这里有篇帖子,使用了karma可以解决
Most helpful comment
在package.json 中 jest中加入
"moduleFileExtensions": [
"web.js",
"js",
"jsx",
"json"
],
主要是web.js;antd-mobile 不同于 antd,以web.js结尾。