Warn on use of plugin parameters as function#14661
Merged
philipp-spiess merged 2 commits intoOct 14, 2024
Merged
Conversation
| test('theme keys can read from the CSS theme', () => { | ||
| let theme = new Theme() | ||
| theme.add('--color-green', 'green') | ||
| let originalWarn = console.warn |
Contributor
There was a problem hiding this comment.
I'd probably just mock console for the entire test file — it'll help cleanup the test and makes adding / testing additional warnings in the future simpler:
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
afterAll(() => warn.mockReset()); expect(warn).toHaveBeenCalledWith(
'Using the plugin object parameter as the theme function is deprecated. Please use the `theme` property instead.',
)
Contributor
Author
There was a problem hiding this comment.
Not a fan of mocking apis like this too broadly since it can lead to us hiding warnings somewhere where we don't want it. Can put this test into a describe block to scope this and still use the same pattern though 👍 (or can use the onTestFinished hook to clean up and have it inside the single test only.. 🤔)
| let warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined) | ||
| onTestFinished(() => { | ||
| warn.mockReset() | ||
| }) |
Contributor
There was a problem hiding this comment.
ooh I forgot this existed 💯
thecrypticace
approved these changes
Oct 14, 2024
philipp-spiess
added a commit
that referenced
this pull request
Oct 14, 2024
This reverts commit a64e209.
adamwathan
pushed a commit
that referenced
this pull request
Oct 14, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Quick follow-up to #14659 base don @thecrypticace's idea: