测试套件无法运行
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
我的utils.test.js
npm测试src / utils / tests / utils.test.js
import { fixedZero } from '../utils';
// fixedZero test
describe('utils', () => {
it('fixedZero', () => {
expect(fixedZero(0)).toBe('00');
expect(fixedZero(5)).toBe('05');
expect(fixedZero(10)).toBe(10);
expect(fixedZero(55)).toBe(55);
});
});
在utils.js中,我从index.js中导入了一些东西
import store from '../index';
我的index.js,它在浏览器中可以正常工作,但是当我运行测试时,它没有通过
import '@babel/polyfill';
import 'formdata-polyfill';
import 'url-polyfill';
import dva from 'dva';
import createHistory from 'history/createBrowserHistory';
import createLoading from 'dva-loading';
import 'moment/locale/zh-cn';
import './rollbar';
import './zhuge';
import './index.less';
const app = dva({
history: createHistory({
basename: '',
}),
});
app.use(createLoading());
app.model(require('./models/global').default);
app.router(require('./router').default);
app.start('#root');
export default app._store;