Industry standard API mocking for JavaScript.

Joined June 2020
105 Photos and videos
The biggest change. The brightest change. Available for everyone to use. Migrate today and enjoy standard-driven API mocking!
πŸŽ‰ Announcing MSW 2.0! πŸŽ‰ 🌎 Migration guidelines: mswjs.io/docs/migrations/1.x… πŸ“° Release notes: github.com/mswjs/msw/release… 365 days in development, 200 commits, 40 contributors involved. The future of API mocking is here, and it has never been brighter.
3
13
88
31,037
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
Good news for all Cloudflare users! First-party MSW integration is out. Seamless, standard-first, and powerful as you came to expect. Try this in your tests and submit any issues you find! Thanks.
Does your Cloudflare Worker interact with the wider internet? msw.js has a new release which makes it easier than ever to mock HTTP, GraphQL and Websocket calls. We'd love your feedback. Give it a try and tell me what you think github.com/mswjs/cloudflare
4
32
6,354
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
Enjoy this introduction into E2E testing from my latest workshop "React End-to-End Testing with Playwright"! πŸŽ‰ Let's talk about what E2E testing is, how it has nothing to do with the browser, and what is its true goal.
2
5
44
10,143
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
More and more people are asking me about testing resources so let's put everything I've written in one post. Bookmark, share, and, most importantly, please read these. The True Purpose of Testing epicweb.dev/the-true-purpose… Developers often overlook the fundamentals and rush into writing tests without properly understanding what a test is and what is its function. No test is inherently useful just because it exists. Read this one to learn what makes it useful. The Golden Rule of Assertions epicweb.dev/the-golden-rule-… There's a lot of debate over what makes a good test. In this one, I'm defining a short and objective way to grade a test's quality no matter the language or the tested system. This is, without a tinge of exaggeration, a game-changer in how you approach your tests. Anatomy of a Test epicweb.dev/anatomy-of-a-tes… Let's talk about the building blocks that make up any automated test. From JavaScript to Go and Rustβ€”these blocks power tests everywhere. Know your blocks. Implicit Assertions epicweb.dev/implicit-asserti… Did you know there's a way to express expectations in tests without writing "expect"? Those are called implicit assertions and they are tremendously powerful because they help you express more by writing less. Inverse Assertions epicweb.dev/inverse-assertio… Sometimes you need to assert that something did not happen. That can be tricky, especially if that something is asynchronous. The last thing you want are false positives. What you actually want is inverse assertions. Making Use of Code Coverage epicweb.dev/making-use-of-co… Code coverage has been an ongoing debate in the engineering circles. Is 100% code coverage in tests good? Bad? When should you strive for it? Why do people say it's harmful? I'm answering all those questions in this one and giving you practical tips on when to use (and not to use) code coverage. Good Code, Testable Code. epicweb.dev/good-code-testab… You've gathered by now that some code is easier to test than the other. But why? Let's take a look at the characteristic of code's testability, what defines it, what is its relationship with complexity, and how to make your code more testable. What is a Test Boundary? epicweb.dev/what-is-a-test-b… Automated tests rarely involve your entire system (yes, even the end-to-end ones have exceptions). There's often a place where you draw the line. The boundary. Learn what it is and how to use test boundaries efficiently to focus on the exact behaviors you want to test. Be S.M.A.R.T. About Flaky Tests epicweb.dev/be-smart-about-f… Flakiness is the scourge of reliability. If you've written a test before, you likely had experience with flakiness. But what is it at its core and what causes it? And how should you deal with flakiness? Writing Tests That Fail epicweb.dev/writing-tests-th… You write tests for them to fail. We all enjoy a green CI, but the true value of tests is when they fail. What matters is when and how they fail.
4
46
376
43,334
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
I'm excited to announce "React End-to-end Testing with Playwright"! πŸŽ‰ Complete your testing journey by learning how to use Playwright to test your entire app. I'm talking full browser automation, user journeys, auth, search, test setup, debugging tips... Here's what's inside πŸ‘‡
7
14
96
18,585
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
πŸ“¦ msw@2.14.4 introduces a new API called "finalize" for scheduling cleanups after the request handler is finished. This is your go-to choice for managing side effect cleanup in your mocks.
2
2
52
5,365
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
It's undocumented, but I released an "onUpgrade" callback to handle connection upgrades from HTTP to WebSocket for matching handlers. This is only relevant for Node.js and custom environments.
2
12
2,571
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
Indeed! And as easy to do with API mocking as 1-2-3:
Best thing you can do in local development is to add artificial latency to your API to ensure you are testing against more realistic conditions. Our dev server defaults to random delay between 100-300ms. And we can easily increase that with env vars to test with really bad conditions. And then if you do it right, real production feels SO fast.
4
4
91
13,084
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
I built Data as the means to do data-first API mocking, but it turned out that all you need is schema seeding and ORM-like querying, which are general purpose. Could you give it a try? Experiment, try breaking it, that kind of stuff. Thanks! github.com/mswjs/data
4
6
76
7,269
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
πŸ§‘β€πŸ”¬ JSON Server vs MSW. These two solutions might look similar, but the way they approach the same problem cannot be more different. Here's why.
5
1
41
6,606
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
Replying to @jarredsumner
@jarredsumner Hi, Jarred πŸ‘‹ I think it's time we made MSW work in Bun. I'm working on the new architecture right now that might actually make that possible. Would you be interested in sponsoring my work and bring first-class API mocking to all Bun users?
2
2
60
7,510
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
πŸ’‘ Fun fact: Nock uses MSW's interception algorithm under the hood! I've created it as a standalone library anyone can use to build their own MSW and it warms my heart to see Nock adopt it for powerful and unified interception for everyone. kettanaito.com/blog/mocking-…
1
2
24
1,178
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
πŸ§‘β€πŸ”¬ Nock vs Mock Service Worker. Here's a detailed comparison between the two API mocking libraries to help you understand them better. Enjoy.
4
10
132
14,717
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
If you're building anything AI-related, you should be using @ApiMocking for testing and then sponsoring the project. Just saying 😊
1
12
1,499
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
Super excited to announce that @coderabbitai is joining MSW partners to help make the future of API mocking on the web more sustainable. Huge thank you! πŸŽ‰
3
8
34
6,320
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
Would you pay a small one-time fee to download hand-crafted agent skills for MSW? Best practices, common mistakes, getting the most out of your mocks. This kind of stuff.
29% Yes
71% No
90 votes β€’ Final results
1
1
1,409
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
If you like MSW and would like to help make it more sustainable, please consider nominating it at endowment.dev/funding/ Share a short feedback about how it improved your development life. Costs you nothing. Might be a game-changer for its future. Thank you ❀️
2
5
16
4,559
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
Every time I talk to a team that doesn't use mswjs.io:
1
7
1,375
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
Ever needed to handle API mocking? Our final speaker, @kettanaito, is the creator of @ApiMocking. He'll be joining us to talk about how the library became a standard for modern development. We're just 2 days away! Grab one of the last spots! See you thereπŸ’›
1
2
5
1,125
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
MSW has nearly doubled in downloads since last year. Huge.
2
1
27
1,466
Mock Service Worker πŸ‡ΊπŸ‡¦ retweeted
I genuinely want to understand developers that struggle with MSW. If you are one, please share your feedback! I've worked so hard to make it the best API mocking solution on the web. It's years ahead of the "competition", promotes web standards, has the richest feature set you can find. But there are still developers who struggle with it, apparently. I want to turn those struggles into features I can add and bugs I can fix. But I need to know them first! In Node.js, using MSW is no different than using any other solution you're familiar with. Some of them literally use MSW under the hood, providing a different flavor of UX. That part is subjective and I'm fine if some prefer other APIs to what MSW offers. As long as you're using the interception algorithm that doesn't diminish the value of your tests. In the browser, the only inconvenience I can think of is having to register a Service Worker. I get it, it's an extra step, not everybody is familiar with what that is and why that's needed. I used to wish to get rid of this step, but I find it both educational and secure. There is no better way to intercept the network in the browser than a Service Worker. And that means learning a bit about them and keeping your worker yours. Please share the things you struggled with in MSW, if any. I'd be grateful.
3
2
8
1,239