Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "[MSW] Mocking disabled." console message #485

Closed
yairkukielka opened this issue Dec 2, 2020 · 4 comments · Fixed by #493
Closed

Add "[MSW] Mocking disabled." console message #485

yairkukielka opened this issue Dec 2, 2020 · 4 comments · Fixed by #493
Assignees
Labels
feature scope:browser Related to MSW running in a browser

Comments

@yairkukielka
Copy link

Would currently get this console message when MSW is enabled: [MSW] Mocking enabled.

It would be great to add the [MSW] Mocking disabled. when it's disabled.

My use case:
I'm building a small web app to mesure the performance of a web library. I'm mocking backend calls with MSW. I added a checkbox that can be used to toggle activation, deactivation of the mocking and it would be great to have confirmation in the console with this message.

Thank you!

@kettanaito
Copy link
Member

Hey, @yairkukielka. Thanks for the suggestion.

Would you be interested in creating a pull request with this improvement? It should be a matter of adding the log as a part of .stop():

return function stop() {
context.worker?.postMessage('MOCK_DEACTIVATE')
context.events.removeAllListeners()
window.clearInterval(context.keepAliveInterval)
}

In the case of the [MSW] Mocking disabled message, it could be a simple console.log, as there is nothing to group. You can reference the implementation of the [MSW] Mocking enabled from .start() to see how such messages respect the quiet option:

if (!options?.quiet) {
console.groupCollapsed(
'%c[MSW] Mocking enabled.',
'color:orangered;font-weight:bold;',
)

@kettanaito kettanaito added the scope:browser Related to MSW running in a browser label Dec 2, 2020
@tigerabrodi
Copy link
Contributor

@kettanaito I'd love to work on it as you suggested in Discord, seems also like a great way for me to get a bit more familiar with the repo 💕

@kettanaito
Copy link
Member

That'd be awesome, @tigerabrodi! If you don't mind, I've assigned this issue to you, so others know somebody's taking care of it. Looking forward to our discussion on the code review.

@tigerabrodi
Copy link
Contributor

@kettanaito Defo, no worries, thanks for the opportunity 🥰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature scope:browser Related to MSW running in a browser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants