Я получаю сообщение об ошибке при запуске команды npm run test
.
user@user-ps:~/documents/driver-app$ npm run test
> driverApp@0.0.1 test /home/user/documents/driver-app
> jest
FAIL __tests__/App-test.tsx
● Test suite failed to run
Cannot find module 'react-dom' from 'mobxreact.cjs.development.js'
However, Jest was able to find:
'../App.tsx'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17)
at Object.<anonymous> (node_modules/mobx-react/dist/mobxreact.cjs.development.js:10:16)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 9.031s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! driverApp@0.0.1 test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the driverApp@0.0.1 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2020-02-27T07_58_19_815Z-debug.log
Это мой тест App-test.tsx
файл
/**
* @format
*/
import 'react-native';
import React from 'react';
import { App } from './../App';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctly', () => {
renderer.create(<App />);
});
Я нашел информацию, чтобы решить мою проблему, но она мне не помогло.
https://github.com/mobxjs/mobx-react/issues/764#issuecomment -524507782
Моя jest
конфигурация в package.json
файле
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|@?react-navigation|@?react-native-community)"
],
"setupFiles": [
"./node_modules/react-native-gesture-handler/jestSetup.js"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
Почему не мой тестовый пропуск?