我对我的组件进行了简单的快照测试。
import React from 'react';
import GridV1 from '../src/features/Gridv1/containers';
import {Provider} from 'react-redux'
import store from '../src/store/configureStore'
import renderer from 'react-test-renderer';
test('renders correctly', () => {
const tree = renderer.create(<Provider store={store()}><GridV1/></Provider>).toJSON();
expect(tree).toMatchSnapshot();
});
我的所有组件都已将主题变量作为主题从redux商店传递为道具,我在应用程序中定义了一些通用样式,并且每个组件都使用一种或两种通用样式。当我运行测试时,出现此参考错误:
测试 /GridV1.test.js ●测试套件无法运行
ReferenceError: getTextInputStyles is not defined
110 | });
111 |
> 112 | export default getTextInputStyles = (theme) => ({
| ^
113 | ...getBasic(theme),
114 | ...getIconRight(theme),
115 | ...getRouded(theme),
at Object.<anonymous> (src/global/styles/inputStyle.js:112:20)
at Object.<anonymous> (src/global/styles/index.js:4:42)
at Object.<anonymous> (src/features/splash/reducers/index.js:4:38)
我的应用程序运行正常且样式正常,但是开玩笑的快照测试在此行给我错误。为什么显示这种行为?