新的 React 脚手架创建的项目 运行报错
来源:5-4 Enzyme 的配置及使用

慕仙5575612
2020-07-20
报错代码第一张图 我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)
});
写回答
1回答
-
Dell
2020-07-25
你有改动过配置项没有?
022020-07-25
相似问题