报错代码第一张图 我test.js的代码第二张图
● Validation Error:
Module <rootDir>/node_modules/babel-jest in the transform option was not found.
<rootDir> is: D:\learn\tdd-react-jest
Configuration Documentation:
https://jestjs.io/docs/configuration.html
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tdd-react-jest@0.1.0 test: `node scripts/test.js`
npm ERR! Exit status 1
import React from 'react';
import { render } from '@testing-library/react';
import App from './App';
import Enzyme,{ shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });
test('renders learn react link', () => {
// const { getByText } = render(<App />);
// const linkElement = getByText(/hello/i);
// expect(linkElement).toBeInTheDocument();
const wrapper = shallow(<App />)
// expect(wrapper.find('.App')).to.have.lengthOf(1);
console.log(wrapper.find('.App').length)
expect(wrapper.find('.App').length).toBe(1)
});
自动化测试实战 Vue / React 项目,让技术水平和架构思维双提升
了解课程