Enzyme 反应:酶浅:“;预期:1;收到:未定义

Enzyme 反应:酶浅:“;预期:1;收到:未定义,enzyme,react-typescript,Enzyme,React Typescript,我正在为我的应用程序使用React-typescript。我真的是测试界的新手。我创建了两个组件。然后我将这些组件导入应用程序组件。我正在使用Enzyme's shallow测试组件。我正在看udemy中的一个教程。我完全按照视频中的测试代码进行了操作。但是我的测试失败了 这是我的应用程序组件 import React from 'react'; import CommentBox from './components/commentbox'; import CommentList from '

我正在为我的应用程序使用React-typescript。我真的是测试界的新手。我创建了两个组件。然后我将这些组件导入应用程序组件。我正在使用
Enzyme's shallow
测试组件。我正在看
udemy
中的一个教程。我完全按照视频中的测试代码进行了操作。但是我的测试失败了

这是我的应用程序组件

import React from 'react';
import CommentBox from './components/commentbox';
import CommentList from './components/commentlist'

function App() {
  return (
    <div className="App">
      <CommentBox />
      <CommentList />
    </div>
  );
}

export default App;
import { cleanup } from '@testing-library/react';
import App from '../App';
import CommentBox from '../components/commentbox';

describe('whole app component', () => {
  afterEach(cleanup)
  it('renders Comment Box component', () => {
    const wrapped = shallow(<App />);
    expect(wrapped.find(CommentBox).lenght).toEqual(1) //I Received Undefined
  });
});
从“React”导入React;
从“./components/CommentBox”导入CommentBox;
从“./components/CommentList”导入CommentList
函数App(){
返回(
);
}
导出默认应用程序;
这是我的测试

import React from 'react';
import CommentBox from './components/commentbox';
import CommentList from './components/commentlist'

function App() {
  return (
    <div className="App">
      <CommentBox />
      <CommentList />
    </div>
  );
}

export default App;
import { cleanup } from '@testing-library/react';
import App from '../App';
import CommentBox from '../components/commentbox';

describe('whole app component', () => {
  afterEach(cleanup)
  it('renders Comment Box component', () => {
    const wrapped = shallow(<App />);
    expect(wrapped.find(CommentBox).lenght).toEqual(1) //I Received Undefined
  });
});
从'@testing library/react'导入{cleanup};
从“../App”导入应用程序;
从“../components/CommentBox”导入CommentBox;
描述('整个应用程序组件',()=>{
每次之后(清理)
它('呈现注释框组件',()=>{
常数包装=浅();
expect(wrapped.find(CommentBox.length).toEqual(1)//我收到了未定义的
});
});