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

feat: add service worker scope and worker script URL to "Mocking enabled" message #1172

Merged
merged 2 commits into from Apr 4, 2022

Conversation

Poivey
Copy link
Contributor

@Poivey Poivey commented Mar 17, 2022

close #1103

As discussed, printing service worker scope & location in "Mocking enabled" message.
Scope and location are found in context to get effective service worker values and not just user raw options.

Question

Do we need to cover cases where these fields would not be present in context (Eg. worker or registration is null) ? I think it should not happen because mocking would not be enabled in this case anyway so we would not print this message, I would like your opinion on that as this is my first PR here.

Screenshot

Screenshot 2022-03-17 at 18 18 32

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 17, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit b6e1347:

Sandbox Source
MSW React Configuration

@Poivey Poivey force-pushed the feat/print-scope-and-worker-location branch from 15ff784 to ec3014f Compare March 17, 2022 18:01
Comment on lines 7 to 8
scope?: string
workerLocation?: string
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you adding them to PrintStartMessageArgs?

You don't seem to be using args.workerLocation or args.scope anywhere.

You are only using context e.g. context.worker?.scriptURL.

Copy link
Contributor Author

@Poivey Poivey Apr 4, 2022

Choose a reason for hiding this comment

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

You are right, I'm sorry I missed that. Thank you @kettanaito for fixing it.

@kettanaito
Copy link
Member

Hey, @Poivey. Thank you for your work on this!

I'd like to look closer at the changes and see if exposing a context to the print message function is the best course of action we could take. I lean towards printStartMessage remaining pure and letting the callee provide it with the data like worker script location upon invocation.

@kettanaito kettanaito force-pushed the feat/print-scope-and-worker-location branch from dc373c6 to 8e14f49 Compare April 3, 2022 23:26
@kettanaito kettanaito force-pushed the feat/print-scope-and-worker-location branch from 8e14f49 to fa89d93 Compare April 3, 2022 23:28
@kettanaito
Copy link
Member

Okay, so what I've tried is I removed the context from the printStartMessage, making the function contextless. It also reduced the setup we need to test it actually printing the worker info upon the activation message.

Renamed the commit to fix: since this is not a breaking change technically.

@kettanaito kettanaito force-pushed the feat/print-scope-and-worker-location branch from fa89d93 to f201a48 Compare April 3, 2022 23:31
@kettanaito kettanaito force-pushed the feat/print-scope-and-worker-location branch from f201a48 to b6e1347 Compare April 3, 2022 23:32
@kettanaito kettanaito changed the title feat: add service worker scope and location to "Mocking enabled" message feat: add service worker scope and worker script URL to "Mocking enabled" message Apr 3, 2022
@kettanaito kettanaito merged commit 6fc89f7 into mswjs:main Apr 4, 2022
@kettanaito
Copy link
Member

Welcome to contributors, @Poivey! 🎉

@kettanaito
Copy link
Member

Thank you for reviewing this, @MartinJaskulla!

@Poivey Poivey deleted the feat/print-scope-and-worker-location branch April 5, 2022 11:45
kettanaito added a commit that referenced this pull request Apr 18, 2022
…led" message (#1172)

* fix: add service worker scope and worker script url to "Mocking enabled" message

* chore(printStartMessage): remove context from the function

Co-authored-by: Artem Zakharchenko <kettanaito@gmail.com>
kettanaito added a commit that referenced this pull request Apr 18, 2022
…led" message (#1172)

* fix: add service worker scope and worker script url to "Mocking enabled" message

* chore(printStartMessage): remove context from the function

Co-authored-by: Artem Zakharchenko <kettanaito@gmail.com>
kettanaito added a commit that referenced this pull request May 17, 2022
…led" message (#1172)

* fix: add service worker scope and worker script url to "Mocking enabled" message

* chore(printStartMessage): remove context from the function

Co-authored-by: Artem Zakharchenko <kettanaito@gmail.com>
@kettanaito
Copy link
Member

Released: v0.40.0 🎉

This has been released in v0.40.0!

Make sure to always update to the latest version (npm i msw@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

imgbot bot pushed a commit to akadop/msw that referenced this pull request Dec 1, 2022
…led" message (mswjs#1172)

* fix: add service worker scope and worker script url to "Mocking enabled" message

* chore(printStartMessage): remove context from the function

Co-authored-by: Artem Zakharchenko <kettanaito@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Print the worker's scope in the "Mocking enabled" message
3 participants