嘿伙计们,我制作了一个仪表板,并在那里使用了一些带有 chart.js 的图表,现在在它运行良好之后我的测试失败了,我不知道为什么请帮忙
这是我的仪表板
import React from 'react';
import styles from './SuperAdminDashboard.module.css';
import { Line } from 'react-chartjs-2';
const line_state = {
labels: [
'January',
'February',
'March',
],
datasets: [
{
label: 'Uptime',
backgroundColor: 'rgba(75,192,192,1)',
borderColor: 'rgba(0,0,0,1)',
borderWidth: 2,
data: [65, 59, 80],
},
],
};
function SuperAdminDashboard(): JSX.Element {
return (
<>
<div className={styles.first_box}>
<h2>Dashboard</h2>
<h4>API Uptime Statistics</h4>
<div>
<Line
type
data={line_state}
options={{
maintainAspectRatio: false,
}}
/>
</div>
</div>
</>
);
}
export default SuperAdminDashboard;
这是我的测试文件
import React from 'react';
import { render, screen } from '@testing-library/react';
import SuperAdminDashboard from './SuperAdminDashboard';
describe('Testing the LoginPage', () => {
test('should show the text on the website', () => {
render(<SuperAdminDashboard />);
expect(screen.getByText('Dashboard')).toBeInTheDocument();
expect(screen.getByText('API Uptime Statistics')).toBeInTheDocument();
});
这就是我遇到的问题