Custom matcher for ui logger #552
Labels
💡 good first issue
good for newcomers
🆘 help wanted
assistance is required
🔬 testing
writing tests
🤓 UX
UX improvement for CLI users
Milestone
User story
As a developer I want to have a good signal to noise ration and want to write my tests with as less boilerplate as possible.
Therefor I need a custom matcher for the UI logger.
Bad example:
Suggested matcher:
expect(ui()).toHaveLogged('...')
expect(ui()).toHaveLoggedNth(1, '...')
expect(ui()).not.toHaveLogged())
Conversation: #487 (comment)
Good example:
Acceptance criteria
I want to be able to use the custom matcher in the following libs:
Internal logic:
expect(msg.replace(/\u001B\[\d+m/g, '')).toBe("[ blue(info) ] This is is blue in terminal")
toMatchPlainCharacter
instead ofremoveColorCodes
(optional)I want to be able to have different matcher present:
toHaveLoggedLevel('...')
toHaveLoggedLevelNth(1, '...')
toHaveLoggedMessage('...')
toHaveLoggedMessageNth(1, '...')
Implementation details
Usage in
global-setup.ts
The text was updated successfully, but these errors were encountered: