我开始开玩笑地测试react native应用程序我开始测试App.js
文件并发现节点模块出现“依赖”错误。但是我无法解决的错误之一就是这个。
我不理解错误,也不知道如何解决
__tests__/App.js
import 'react-native'
import React from 'react';
import renderer from 'react-test-renderer';
import App from '../App';
describe('Some component', () => {
beforeAll(() => {
jest.mock('@react-native-community/async-storage');
});
it('renders correctly', () => {
const tree = renderer.create(
<App/>
).toJSON();
expect(tree).toMatchSnapshot();
});
});
package.json
...
"jest": {
"preset": "react-native",
"cacheDirectory": "./cache",
"coveragePathIgnorePatterns": [
"./app/utils/vendor"
],
"coverageThreshold": {
"global": {
"statements": 80
}
},
"transformIgnorePatterns": [
"/node_modules/(?!react-native|react-clone-referenced-element|react-navigation|native-base-shoutem-theme|native-base|lodash|static-container|@react-navigation|react-native-rfid-nfc-scanner)"
],
"setupFiles": [
"./node_modules/react-native-gesture-handler/jestSetup.js"
]
},
...