webworker: the scope between the extension vs. test code is not shared #938
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.
In a node.js context, when running unit tests the context is shared between the extension and unit test code. This means that the state created in the extension context is the same as what the unit tests are using.
For example, defining a variable in the global scope of the extension code will be accessible by the unit tests.
But in a web extension, when running with webworkers this context is separate between the extension and unit tests. They only share the globalThis object from what I could find.
This commit displays these differences by showing in the unit tests that there is a disconnect in globally defined values in a web context.
In the
helloword-web-sample
I've added tests that show how global values are not shared between the extension and test executions, thoughglobalThis
is.Similarily, in the
helloworld-test-sample
the tests show how a global value IS in the same context between the extension and test.