Skip to content

test: filter noisy default-theme console warning in browser tests - #2698

Open
joyenjoyer wants to merge 1 commit into
masterfrom
INSTUI-5163-bypass-default-theme-warnings-in-test-logs
Open

test: filter noisy default-theme console warning in browser tests#2698
joyenjoyer wants to merge 1 commit into
masterfrom
INSTUI-5163-bypass-default-theme-warnings-in-test-logs

Conversation

@joyenjoyer

@joyenjoyer joyenjoyer commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

This PR bypasses the noise in test logs caused by adding: No theme provided for [InstUISettingsProvider], using default <canvas> theme. multiple times.

INSTUI-5163

Components rendered without an InstUISettingsProvider fall back to the
default canvas theme and log this warning on every render, drowning out
real warnings in CI. Filter it out via a plain console.warn reassignment
so it survives vi.restoreAllMocks() and stays in effect across all tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://instructure.design/pr-preview/pr-2698/

Built to branch gh-pages at 2026-08-26 11:37 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@joyenjoyer joyenjoyer self-assigned this Aug 26, 2026
@joyenjoyer
joyenjoyer requested review from HerrTopi and matyasf August 26, 2026 12:43

@matyasf matyasf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works well, just some stylistic changes

Comment thread vitest.setup.browser.ts
Comment on lines +43 to +49
// Components are rendered directly in tests, without wrapping them in an
// <InstUISettingsProvider>, so `useTheme()`/`getTheme()` always fall back to
// the default `canvas` theme and log this warning on every render. It's
// expected in this context and just drowns out real warnings in CI, so we
// filter it out here. This is a plain reassignment (not `vi.spyOn`), so it
// survives the `vi.restoreAllMocks()` above and stays in effect for every
// test, including ones that install their own `console.warn` spy on top of it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is way too verbose. I'd just write:

Do not let test components spam the logs because they are not wrapped in InstUISettingsProvider.

Comment thread vitest.setup.browser.ts
console.warn = (...args: Parameters<typeof console.warn>) => {
if (
typeof args[0] === 'string' &&
NOISY_WARNINGS.some((message) => (args[0] as string).includes(message))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would simplify this, no need for the array. Just do

'No theme provided for [InstUISettingsProvider], using default'.includes(message)

no need for the generic filter code

@HerrTopi HerrTopi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we print a warning at all? That's why we have a default, don't we? In this case, canvas (who is hyper sensitive to warnings) can't use this with the default option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants