test(ThemeProvider): update tests to catch console.error #2526
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Update
ThemeProvidertest to catchconsole.error()calls that show up when an invalid color scheme is provided.This prevents the following logs from being shown in the test suite:
Logs
console.error `foo` scheme not defined in `theme.colorSchemes` 224 | if (!theme.colorSchemes[colorScheme]) { 225 | // eslint-disable-next-line no-console > 226 | console.error(`\`${colorScheme}\` scheme not defined in \`theme.colorSchemes\``) | ^ 227 | 228 | // Apply the first defined color scheme 229 | const defaultColorScheme = Object.keys(theme.colorSchemes)[0] at error (src/ThemeProvider.tsx:226:13) at applyColorScheme (src/ThemeProvider.tsx:73:11) at mountMemo (node_modules/react-dom/cjs/react-dom.development.js:15846:19) at Object.useMemo (node_modules/react-dom/cjs/react-dom.development.js:16219:16) at Object.useMemo (node_modules/react/cjs/react.development.js:1532:21) at useMemo (src/ThemeProvider.tsx:72:54) at renderWithHooks (node_modules/react-dom/cjs/react-dom.development.js:14985:18) console.error `totally-invalid-colorscheme` scheme not defined in `theme.colorSchemes` 224 | if (!theme.colorSchemes[colorScheme]) { 225 | // eslint-disable-next-line no-console > 226 | console.error(`\`${colorScheme}\` scheme not defined in \`theme.colorSchemes\``) | ^ 227 | 228 | // Apply the first defined color scheme 229 | const defaultColorScheme = Object.keys(theme.colorSchemes)[0] at error (src/ThemeProvider.tsx:226:13) at applyColorScheme (src/ThemeProvider.tsx:73:11) at mountMemo (node_modules/react-dom/cjs/react-dom.development.js:15846:19) at Object.useMemo (node_modules/react-dom/cjs/react-dom.development.js:16219:16) at Object.useMemo (node_modules/react/cjs/react.development.js:1532:21) at useMemo (src/ThemeProvider.tsx:72:54) at renderWithHooks (node_modules/react-dom/cjs/react-dom.development.js:14985:18) console.error `totally-invalid-colorscheme` scheme not defined in `theme.colorSchemes` 224 | if (!theme.colorSchemes[colorScheme]) { 225 | // eslint-disable-next-line no-console > 226 | console.error(`\`${colorScheme}\` scheme not defined in \`theme.colorSchemes\``) | ^ 227 | 228 | // Apply the first defined color scheme 229 | const defaultColorScheme = Object.keys(theme.colorSchemes)[0] at error (src/ThemeProvider.tsx:226:13) at applyColorScheme (src/ThemeProvider.tsx:73:11) at mountMemo (node_modules/react-dom/cjs/react-dom.development.js:15846:19) at Object.useMemo (node_modules/react-dom/cjs/react-dom.development.js:16219:16) at Object.useMemo (node_modules/react/cjs/react.development.js:1532:21) at useMemo (src/ThemeProvider.tsx:72:54) at renderWithHooks (node_modules/react-dom/cjs/react-dom.development.js:14985:18) console.error `totally-invalid-colorscheme` scheme not defined in `theme.colorSchemes` 224 | if (!theme.colorSchemes[colorScheme]) { 225 | // eslint-disable-next-line no-console > 226 | console.error(`\`${colorScheme}\` scheme not defined in \`theme.colorSchemes\``) | ^ 227 | 228 | // Apply the first defined color scheme 229 | const defaultColorScheme = Object.keys(theme.colorSchemes)[0] at error (src/ThemeProvider.tsx:226:13) at applyColorScheme (src/ThemeProvider.tsx:73:11) at mountMemo (node_modules/react-dom/cjs/react-dom.development.js:15846:19) at Object.useMemo (node_modules/react-dom/cjs/react-dom.development.js:16219:16) at Object.useMemo (node_modules/react/cjs/react.development.js:1532:21) at useMemo (src/ThemeProvider.tsx:72:54) at renderWithHooks (node_modules/react-dom/cjs/react-dom.development.js:14985:18)