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

chore: migrate to msw@2 #38

Merged
merged 23 commits into from
May 27, 2024
Merged

chore: migrate to msw@2 #38

merged 23 commits into from
May 27, 2024

Conversation

kettanaito
Copy link
Member

@kettanaito
Copy link
Member Author

The core has been migrated but tests need rewriting.

@kettanaito kettanaito mentioned this pull request May 20, 2024
@weyert
Copy link
Collaborator

weyert commented May 20, 2024

Hah, just started working on it today :)

Copy link
Collaborator

@weyert weyert left a comment

Choose a reason for hiding this comment

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

LGTM. I wanted to add delay config option to allow adding a random amount of extra delay when the har archive request has the time-property populated

@kettanaito
Copy link
Member Author

@weyert, good call. I think I've already added that with these changes:

if (entry.time) {
await delay(entry.time)
}

@@ -80,7 +80,7 @@ describe('fromTraffic', () => {
)

expect(handlers).toHaveLength(1)
expect(handlers[0].info.header).toEqual('GET https://api.stripe.com')
expect(handlers[0].info.header).toEqual('get https://api.stripe.com')
Copy link
Member Author

Choose a reason for hiding this comment

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

I've fixed this in inspectHandlers though. Once we introduce it here, we can write proper assertions on the generated handlers.

@kettanaito
Copy link
Member Author

@weyert, I've removed isEqualBytes in favor of the custom .toEqualBytes() assertion. Let's use that in the tests instead whenever we need to asserting two Uint8Array equality.

@kettanaito
Copy link
Member Author

All fromTraffic tests are passing!

 ✓ test/traffic/fromTraffic.test.ts (7)
 ✓ test/traffic/response-body.test.ts (4)
 ✓ test/traffic/response-order.test.ts (1)
 ✓ test/traffic/response-cookies.test.ts (1)
 ✓ test/traffic/response-stream.test.ts (1)
 ✓ test/traffic/response-timing.test.ts (2) 557ms

Now, to the fromOpenApi tests...

@kettanaito
Copy link
Member Author

The tests are passing and the migration is complete. I will go ahead and merge this.

@kettanaito kettanaito merged commit fa29e1b into main May 27, 2024
1 check passed
@kettanaito kettanaito deleted the chore/msw-v2 branch May 27, 2024 15:47
@kettanaito
Copy link
Member Author

Released: v0.1.0 🎉

This has been released in v0.1.0!

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


Predictable release automation by @ossjs/release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to MSW 2.0
2 participants