Мой проект основан на настройке приложения Create-реагировать на приложение, и мой скрипт package.json для тестирования юнит-тестов имеет следующий вид:
"scripts": {
"test": "react-scripts test --coverage",
}
или
"test": "react-scripts test --coverage --collectCoverageFrom=src/**/*.{js,jsx}
Он выполняет тесты в Проверить папку, но не отображает отчет о покрытии. Вы можете помочь решить эту проблему. ![enter image description here](https://i.stack.imgur.com/KcvlG.png)
Моя файловая структура такая, как показано ниже. Src |--- Тест --- компоненты> moduleA> package1> package2> транзакция.js, abcd.js ... и т. Д.
ProcessEvent.test.js
describe('ProcessEvent Component', () => {
const expectedProps = {
"event": {iconStatus:'active', desc:'abc'}
}
it('should render without error', () => {
const component = <ProcessEvent {...expectedProps}/>
const wrapper = component.find('.eventclass');
expect(wrapper.length).toBe(1);
});
it('should receive valid props', () => {
const component = shallow(<ProcessEvent {...expectedProps}/>);
const wrapper = component.find('.eventclass');
expect(component.props).toBeDefined();
});
});