讓我們假設一個組件在 render 方法中返回 null,基于一些 prop。使用 expect 來確保不呈現組件的最佳方法是什么?例子:import React from 'react';import { render, fireEvent } from '@testing-library/react';import Pagination from '../Pagination';it('should not render if totaPages is 0', () => { const { container } = render(<Pagination activePage={1} totalPages={0} />); expect(container.firstChild).toBeNull();});上面的代碼夠嗎?
檢查組件是否未呈現的最佳實踐
慕斯709654
2021-06-29 06:18:10