Skip to content

Commit 8f12e6b

Browse files
chore: wait for correct console error in test (#1865)
**Issue number:** ### PR Type **What kind of change does this PR introduce?** * [ ] Feature * [ ] Bug Fix * [ ] Refactoring (no functional or API changes) * [ ] Documentation Update * [x] Maintenance (dependency updates, CI, etc.) ## Summary ### Changes Wait for console log to be print out. (without wait the vitest rarely is printing it in next test and triggering console error issue. ### User experience N/A. ## Checklist If an item doesn't apply to your changes, leave it unchecked. ### Review * [x] self-review - I have performed a self-review of this change according to the [development guidelines](https://splunk.github.io/addonfactory-ucc-generator/contributing/#development-guidelines) * [ ] Changes are documented. The documentation is understandable, examples work [(more info)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#documentation-guidelines) * [x] PR title and description follows the [contributing principles](https://splunk.github.io/addonfactory-ucc-generator/contributing/#pull-requests) * [ ] meeting - I have scheduled a meeting or recorded a demo to explain these changes (if there is a video, put a link below and in the ticket) ### Tests See [the testing doc](https://splunk.github.io/addonfactory-ucc-generator/contributing/#build-and-test). * [x] Unit - tests have been added/modified to cover the changes * [ ] Smoke - tests have been added/modified to cover the changes * [ ] UI - tests have been added/modified to cover the changes * [ ] coverage - I have checked the code coverage of my changes [(see more)](https://splunk.github.io/addonfactory-ucc-generator/contributing/#checking-the-code-coverage) **Demo/meeting:** *Reviewers are encouraged to request meetings or demos if any part of the change is unclear*
1 parent e7e0eeb commit 8f12e6b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

ui/src/components/table/tests/CustomTableCell.test.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
import { http, HttpResponse } from 'msw';
44
import { BrowserRouter } from 'react-router-dom';
55
import userEvent from '@testing-library/user-event';
6-
import { vi } from 'vitest';
6+
import { vi, expect } from 'vitest';
77

88
import TableWrapper, { ITableWrapperProps } from '../TableWrapper';
99
import { server } from '../../../mocks/server';
@@ -200,14 +200,23 @@ test('Error as custom cell without render method', async () => {
200200
});
201201

202202
test('Error as custom cell file is undefined', async () => {
203-
consoleError.mockImplementation(() => {});
204-
// mockCustomCellToUndefined();
203+
const mockConsoleError = vi.fn();
204+
consoleError.mockImplementation(mockConsoleError);
205+
205206
mockCustomCellModule('undefined');
206207
mocksAndRenderTable();
207208

208209
const row = await waitForRow();
209210
expect(row).toBeInTheDocument();
210211

212+
await waitFor(() => {
213+
expect(mockConsoleError).toHaveBeenCalledWith(
214+
expect.stringContaining(
215+
"[Custom Cell] Error loading custom control Error: Cannot find module '/custom/CustomInputCell.js' imported from"
216+
)
217+
);
218+
});
219+
211220
await waitFor(() => {
212221
const errorMessage = within(row).queryByText('Loaded module is not a constructor function');
213222
expect(errorMessage).toBeInTheDocument();

0 commit comments

Comments
 (0)