-
Notifications
You must be signed in to change notification settings - Fork 87
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
test(monorepo): update MSW and othr dependencies to latest #1629
Conversation
WalkthroughThis update primarily focuses on enhancing testing environments and server response handling across various components of a JavaScript analytics framework. It introduces a shift from using REST to HTTP for better control over responses, streamlines polyfills, and extends the JSDOM environment for improved testing compatibility. Additionally, it revises the handling of JavaScript file loading and updates server mock setups, ensuring a more robust and efficient testing strategy. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
@coderabbitai review |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to path filters (14)
package-lock.json
is excluded by:!**/*.json
package.json
is excluded by:!**/*.json
packages/analytics-js-common/package.json
is excluded by:!**/*.json
packages/analytics-js-common/tsconfig.spec.json
is excluded by:!**/*.json
packages/analytics-js-integrations/tsconfig.spec.json
is excluded by:!**/*.json
packages/analytics-js-plugins/package.json
is excluded by:!**/*.json
packages/analytics-js-plugins/tsconfig.spec.json
is excluded by:!**/*.json
packages/analytics-js-service-worker/package.json
is excluded by:!**/*.json
packages/analytics-js-service-worker/tsconfig.spec.json
is excluded by:!**/*.json
packages/analytics-js/tsconfig.spec.json
is excluded by:!**/*.json
packages/analytics-v1.1/package.json
is excluded by:!**/*.json
packages/analytics-v1.1/tsconfig.spec.json
is excluded by:!**/*.json
packages/loading-scripts/tsconfig.spec.json
is excluded by:!**/*.json
packages/sanity-suite/__fixtures__/sourceConfig1.json
is excluded by:!**/*.json
Files selected for processing (13)
- jest.preset.js (1 hunks)
- jest/jest.polyfills.js (2 hunks)
- jest/jsdom-extended.js (1 hunks)
- packages/analytics-js-common/fixtures/msw.handlers.ts (1 hunks)
- packages/analytics-js-common/tests/services/ExternalSrcLoader/ExternalSrcLoader.test.ts (6 hunks)
- packages/analytics-js-plugins/fixtures/msw.handlers.js (2 hunks)
- packages/analytics-js-service-worker/fixtures/msw.server.ts (1 hunks)
- packages/analytics-js-service-worker/tests/Analytics.test.ts (3 hunks)
- packages/analytics-js/fixtures/msw.handlers.ts (1 hunks)
- packages/analytics-js/tests/components/configManager/ConfigManager.test.ts (2 hunks)
- packages/analytics-v1.1/fixtures/msw.handlers.js (2 hunks)
- packages/analytics-v1.1/tests/transformationHandler.test.js (5 hunks)
- patches/nx+18.0.5.patch (2 hunks)
Files skipped from review due to trivial changes (1)
- jest/jest.polyfills.js
Additional comments: 19
packages/analytics-js-service-worker/__fixtures__/msw.server.ts (2)
- 1-3: The import statements for
setupServer
frommsw/node
, andhttp
,HttpResponse
frommsw
are correctly updated to reflect the new usage patterns introduced by the MSW library update. This aligns with the PR's objective to update dependencies and improve HTTP request handling in tests.- 5-11: The setup of the MSW server using
http.post
to handle POST requests to${dummyDataplaneHost}/v1/batch
with a 200 status response is correctly implemented. This change from the previousrest
handlers tohttp
handlers is in line with the MSW update and enhances the control over server responses. The use ofHttpResponse
to specify the response status is appropriate and follows best practices for testing HTTP interactions.jest/jsdom-extended.js (1)
- 1-26: The extension of
JSDOMEnvironment
to include polyfills forReadableStream
,TextDecoder
,TextEncoder
,Blob
,File
,Headers
,FormData
,Request
,Response
, andfetch
is correctly implemented. This ensures compatibility with MSW v2 by providing the necessary global objects that might be used by MSW or tests. The inclusion ofstructuredClone
is also a good practice, as it's a modern API for deep cloning objects. This setup is essential for tests that rely on these APIs being available in the JSDOM environment.packages/analytics-js-plugins/__fixtures__/msw.handlers.js (2)
- 1-1: The import statement correctly updates to use
http
andHttpResponse
frommsw
, aligning with the PR's objective to leverage the latest MSW functionalities for handling HTTP requests in a more controlled manner.- 10-41: The update to use
http.post
for defining request handlers and the use ofHttpResponse
for specifying responses is correctly implemented across various scenarios (success
,partialSuccess
,invalidResponse
,badRequest
,accessDenied
,serverDown
). This change enhances the flexibility and control over the mock server's responses, allowing for more detailed specification of response content and headers. It's also consistent with the PR's goal of updating to the latest MSW version and improving HTTP request handling in tests.packages/analytics-v1.1/__fixtures__/msw.handlers.js (2)
- 1-1: The import statement correctly updates to use
http
andHttpResponse
frommsw
, aligning with the PR's objective to leverage the latest MSW functionalities for handling HTTP requests in a more controlled manner.- 10-47: The update to use
http.post
for defining request handlers and the use ofHttpResponse
for specifying responses is correctly implemented across various scenarios (success
,partialSuccess
,invalidResponse
,badRequest
,accessDenied
,serverDown
). This change enhances the flexibility and control over the mock server's responses, allowing for more detailed specification of response content and headers. It's also consistent with the PR's goal of updating to the latest MSW version and improving HTTP request handling in tests.packages/analytics-js-common/__tests__/services/ExternalSrcLoader/ExternalSrcLoader.test.ts (10)
- 42-42: Appending
.js
to the URL ensures that scripts are loaded correctly with the updated file extensions. This change is consistent with the PR's objectives and appears to be correctly applied here.- 47-47: The URL for loading the JavaScript file correctly includes the
.js
extension, aligning with the changes made elsewhere in this file. This consistency is crucial for the correct loading of scripts.- 81-81: Again, the
.js
extension is correctly appended to the URL, ensuring consistency across the test cases. This change is necessary for the correct loading of scripts with the updated file extensions.- 93-96: The creation of a script element with a URL that includes the
.js
extension is consistent with the PR's objectives. This ensures that the script is loaded correctly with the updated file extensions.- 100-100: The assertion checks the script's
src
attribute for the correct URL, including the.js
extension. This is a good practice to ensure that the script is loaded as expected.- 110-113: Creating a script element with the
.js
extension in the URL is consistent with the changes made throughout this file. This consistency is important for the correct loading of scripts.- 116-116: Inserting a script with the
.js
extension in the URL ensures that the script is loaded correctly. This change aligns with the PR's objectives and is applied consistently.- 129-129: The script element's
src
attribute correctly includes the.js
extension, ensuring that the script is loaded as expected. This consistency with the PR's objectives is crucial.- 154-154: The assertion checks for the correct
src
attribute, including the.js
extension. This ensures that the script is loaded correctly, aligning with the PR's objectives.- 161-161: Loading a JavaScript file with the URL correctly including the
.js
extension is consistent with the changes made elsewhere in this file. This consistency is crucial for the correct loading of scripts.packages/analytics-js/__tests__/components/configManager/ConfigManager.test.ts (2)
- 2-2: The import of
http
andHttpResponse
frommsw
is correctly added to replace the previousrest
usage. This change aligns with the PR's objectives to enhance HTTP request handling in tests.- 139-146: The replacement of
rest
withhttp
for making a GET request and the use ofHttpResponse
for specifying the response is correctly implemented. This change enhances the control over server responses by allowing for more detailed specification of response content and headers, aligning with the PR's objectives.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1629 +/- ##
===========================================
- Coverage 54.70% 52.32% -2.39%
===========================================
Files 581 581
Lines 17740 16592 -1148
Branches 3236 3239 +3
===========================================
- Hits 9704 8681 -1023
+ Misses 6623 6436 -187
- Partials 1413 1475 +62 ☔ View full report in Codecov by Sentry. |
size-limit report 📦
|
PR Description
update MSW and othr dependencies to latest
Linear task (optional)
Linear task link
Cross Browser Tests
Please confirm you have tested for the following browsers:
Sanity Suite
Security
Summary by CodeRabbit