Я делаю некоторые юнит-тесты, используя Jest for React.
По какой-то причине, когда я ожидаю, что он не будет нулевым, в ответе он получил ноль.
describe('Components: FlightSummary', () => {
it('should render local time by default', () => {
const { queryByText } = render();
['18:10', '18:15', '18:18', '18:23', '18:30', '18:35'].forEach(
timeValue => {
expect(queryByText(timeValue)).not.toBeNull();
}
);
expect(received).not.toBeNull()
Received: null
62 | ['18:10', '18:15', '18:18', '18:23', '18:30', '18:35'].forEach(
63 | timeValue => {
> 64 | expect(queryByText(timeValue)).not.toBeNull();
| ^
65 | }
66 | );
И когда я изменяю код на ожидаемый нулевой, он получает значение в ответе.
describe('Components: FlightSummary', () => {
it('should render local time by default', () => {
const { queryByText } = render();
['18:10', '18:15', '18:18', '18:23', '18:30', '18:35'].forEach(
timeValue => {
expect(queryByText(timeValue)).toBeNull();
}
);
expect(received).toBeNull()
Received: <div>18:10</div>
62 | ['18:10', '18:15', '18:18', '18:23', '18:30', '18:35'].forEach(
63 | timeValue => {
> 64 | expect(queryByText(timeValue)).toBeNull();
| ^
65 | }
66 | );
Я понятия не имею, что происходит; никогда не видел этого раньше. ToT