{"_id":"95thmsw","name":"95thmsw","dist-tags":{"latest":"0.42.0"},"versions":{"0.42.0":{"name":"95thmsw","version":"0.42.0","description":"Seamless REST/GraphQL API mocking library for browser and Node.js.","main":"./lib/index.js","types":"./lib/index.d.ts","bin":{"msw":"cli/index.js"},"engines":{"node":">=14"},"scripts":{"start":"tsup --watch","clean":"rimraf ./lib","lint":"eslint \"{cli,config,src,test}/**/*.ts\"","build":"cross-env NODE_ENV=production tsup","test":"yarn test:unit && yarn test:integration","test:unit":"cross-env BABEL_ENV=test jest --maxWorkers=3","test:integration":"jest --config=./test/jest.config.js --maxWorkers=1","test:smoke":"./config/scripts/smoke.sh","test:ts":"yarn tsc -p ./test/typings/tsconfig.json","prepare":"yarn simple-git-hooks init","prepack":"yarn build","release":"release publish","postinstall":"node -e \"try{require('./config/scripts/postinstall')}catch(e){}\""},"lint-staged":{"*.ts":["eslint"]},"homepage":"https://mswjs.io/","repository":{"type":"git","url":"https://github.com/mswjs/msw"},"author":{"name":"Artem Zakharchenko","url":"https://github.com/kettanaito"},"license":"MIT","funding":{"type":"opencollective","url":"https://opencollective.com/mswjs"},"keywords":["api","mock","mocking","worker","prototype","server","service","handler"],"sideEffects":false,"dependencies":{"@mswjs/cookies":"^0.2.0","95thinterceptors":"0.17.0","@open-draft/until":"^1.0.3","@types/cookie":"^0.4.1","@types/js-levenshtein":"^1.1.1","chalk":"4.1.1","chokidar":"^3.4.2","cookie":"^0.4.2","graphql":"^16.3.0","headers-polyfill":"^3.0.4","inquirer":"^8.2.0","is-node-process":"^1.0.1","js-levenshtein":"^1.1.6","node-fetch":"^2.6.7","outvariant":"^1.3.0","path-to-regexp":"^6.2.0","statuses":"^2.0.0","strict-event-emitter":"^0.2.0","type-fest":"^1.2.2","yargs":"^17.3.1"},"devDependencies":{"@babel/core":"^7.17.2","@babel/preset-env":"^7.16.11","@commitlint/cli":"^16.1.0","@commitlint/config-conventional":"^16.0.0","@open-draft/test-server":"^0.2.3","@ossjs/release":"^0.3.0","@types/fs-extra":"^9.0.13","@types/jest":"26","@types/json-bigint":"^1.0.1","@types/node":"^14.14.31","@types/node-fetch":"^2.5.11","@types/puppeteer":"^5.4.4","@typescript-eslint/eslint-plugin":"^5.11.0","@typescript-eslint/parser":"^5.11.0","babel-loader":"^8.2.3","babel-minify":"^0.5.1","commitizen":"^4.2.4","cross-env":"^7.0.3","cross-fetch":"^3.1.5","cz-conventional-changelog":"3.3.0","eslint":"^7.30.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^3.4.0","fs-extra":"^10.0.0","fs-teardown":"^0.3.0","jest":"26","json-bigint":"^1.0.0","lint-staged":"^11.0.1","page-with":"^0.5.0","prettier":"^2.3.2","regenerator-runtime":"^0.13.9","rimraf":"^3.0.2","simple-git-hooks":"^2.7.0","ts-jest":"26","ts-loader":"^9.2.6","ts-node":"^10.1.0","tsup":"^5.12.8","typescript":"^4.7.2","url-loader":"^4.1.1","webpack":"^5.68.0","webpack-dev-server":"^3.11.2"},"peerDependencies":{"typescript":">= 4.2.x <= 4.7.x"},"peerDependenciesMeta":{"typescript":{"optional":true}},"resolutions":{"chokidar":"3.4.1"},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"licenseText":"MIT License\n\nCopyright (c) 2018–present Artem Zakharchenko\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"95thmsw@0.42.0","dist":{"shasum":"ff0349f1cc4939bc55acc11667f7211077fdf294","integrity":"sha512-sedZ/LUqj6a9tOiGtgTjbzlG+SGsauy02xWkKmmOJtpkGcvOIziVZYEFMOg04RIDVs7DM0AbHiU9oCZH+MbIPg==","tarball":"https://registry.npmjs.org/95thmsw/-/95thmsw-0.42.0.tgz","fileCount":36,"unpackedSize":1714705,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCUQiqywPMhd9VxuyDnPdLj1PcZD9MC5attOG+UnunZEwIhALNp/kL3k5t1vTZNvzQZnDqh2v507ynXxL56vvJ9NLmA"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJinM6bACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoqzxAAgwHFsj1E7oIO8MimWDCHT32s4CV7Xq02FuGU7iwT4G9/E4EM\r\nlB2RRHvdkOvSpza/moJsmHBeycTEkLKv2NfvlCqXUj43rhfephWwV5295waH\r\nb13J2xEDjhu6ii+XZcmJR1C79dumdFt9IIpDpLuvFL4f1zpZqxLaICNWj8Fe\r\nZrZLJtGvHFN+01bRJEVurpCXo0nrZGchWYlscupzhltp+5B6M/wqIanhsaJM\r\nt4JWKp547XVifdroVlQEQ2DODclFnJgmsCSSNUJWQZufvtdFQHce2QRbkUSP\r\niaFdtFObTedgjiRTswh7VKadI/d/sGzuXlG6x4DLXMS4AFeR5X1YwbkJ1m8w\r\nMNxq+CqaK0gzu2IMcTw1yQJXsdmCEEaFllUdBn6WLerp7G2WGF5qLFUO/wK4\r\nRLKH2nT2hE1HK3o0ld+xAB78WA98nk1BVrOm601b48BKmN05jqaJVlp4fSzV\r\nG4iX+BUfXBvR2J9fdJwzQAivceOITFGTFUGWqfBuMJQ+K16ZMJ/VP5OLmMtG\r\nsbIa2upCdUP61DXS0UAgkqOy98S9R/xAMQABT7noTFI0BekIR+hqtv2Z+Z/U\r\n1FxCwNE6mdiYlaZ6dpEqXewuoLVv+MO6yVsKpdsdX35DdQFpDe91EZmLrNTI\r\nuDsA5+UDaaEjFvkkLzjsWbUDwSUgSGLM2Z4=\r\n=To1T\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"vargwin","email":"user.gurwinder@gmail.com"},"directories":{},"maintainers":[{"name":"vargwin","email":"user.gurwinder@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/95thmsw_0.42.0_1654443675004_0.20451144366654717"},"_hasShrinkwrap":false}},"time":{"created":"2022-06-05T15:41:15.003Z","0.42.0":"2022-06-05T15:41:15.219Z","modified":"2022-06-05T15:41:15.336Z"},"maintainers":[{"name":"vargwin","email":"user.gurwinder@gmail.com"}],"description":"Seamless REST/GraphQL API mocking library for browser and Node.js.","homepage":"https://mswjs.io/","keywords":["api","mock","mocking","worker","prototype","server","service","handler"],"repository":{"type":"git","url":"https://github.com/mswjs/msw"},"author":{"name":"Artem Zakharchenko","url":"https://github.com/kettanaito"},"license":"MIT","readme":"<br />\n\n<p align=\"center\">\n  <img src=\"media/msw-logo.svg\" width=\"100\" alt=\"Mock Service Worker logo\" />\n</p>\n\n<h1 align=\"center\">Mock Service Worker</h1>\n<p align=\"center\">Mock Service Worker (MSW) is an API mocking library for browser and Node.js.</p>\n\n<p align=\"center\">\n  <a href=\"https://www.npmjs.com/package/msw\" target=\"_blank\">\n    <img src=\"https://img.shields.io/npm/v/msw.svg?style=for-the-badge&label=Latest&color=black\" alt=\"Package version\" />\n  </a>\n  <a href=\"https://circleci.com/gh/mswjs/msw\" target=\"_blank\">\n    <img src=\"https://img.shields.io/circleci/project/github/mswjs/msw/master.svg?style=for-the-badge&color=black\" alt=\"Build status\" />\n  </a>\n  <a href=\"https://www.npmjs.com/package/msw\" target=\"_blank\">\n    <img src=\"https://img.shields.io/npm/dm/msw?style=for-the-badge&color=black\" alt=\"Downloads per month\" />\n  </a>\n   <a href=\"https://kcd.im/discord\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/chat-online-green?style=for-the-badge&color=black\" alt=\"Discord server\" />\n  </a>\n</p>\n\n<br />\n\n## Features\n\n- **Seamless**. A dedicated layer of requests interception at your disposal. Keep your application's code and tests unaware of whether something is mocked or not.\n- **Deviation-free**. Request the same production resources and test the actual behavior of your app. Augment an existing API, or design it as you go, when there is none.\n- **Familiar & Powerful**. Use [Express](https://github.com/expressjs/express)-like routing syntax to capture outgoing requests. Use parameters, wildcards, and regular expressions to match requests, and respond with necessary status codes, headers, cookies, delays, or completely custom resolvers.\n\n---\n\n> \"_I found MSW and was thrilled that not only could I still see the mocked responses in my DevTools, but that the mocks didn't have to be written in a Service Worker and could instead live alongside the rest of my app. This made it silly easy to adopt. The fact that I can use it for testing as well makes MSW a huge productivity booster._\"\n>\n> – [Kent C. Dodds](https://twitter.com/kentcdodds)\n\n## Documentation\n\n- [Documentation](https://mswjs.io/docs)\n- [**Getting started**](https://mswjs.io/docs/getting-started/install)\n- [Recipes](https://mswjs.io/docs/recipes)\n- [FAQ](https://mswjs.io/docs/faq)\n\n## Examples\n\n- See the list of [**Usage examples**](https://github.com/mswjs/examples)\n\n## Browser\n\n- [Learn more about using MSW in a browser](https://mswjs.io/docs/getting-started/integrate/browser)\n- [`setupWorker` API](https://mswjs.io/docs/api/setup-worker)\n\n### How does it work?\n\nBrowser usage is what sets Mock Service Worker apart from other tools. Utilizing the [Service Worker API](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API), which can intercept requests for the purpose of caching, Mock Service Worker responds to captured requests with your mock definition on the network level. This way your application knows nothing about the mocking.\n\n**Watch a 30 seconds explanation on how Mock Service Worker works in a browser:**\n\n[![What is Mock Service Worker?](https://raw.githubusercontent.com/mswjs/msw/main/media/msw-video-thumbnail.jpg)](https://youtu.be/HcQCqboatZk)\n\n### How is it different?\n\n- Intercepts requests on the network level, not the application level.\n- If you think of your application as a box, Mock Service Worker lives in its own box next to yours, instead of opening and altering it for the purpose of mocking.\n- Agnostic of request-issuing libraries, so you can use it with `fetch`, `axios`, `react-query`, you-name-it.\n- The same mock definition can be reused for unit, integration, E2E testing, and debugging.\n\n### Usage example\n\n```js\n// src/mocks.js\n// 1. Import mocking utils.\nimport { setupWorker, rest } from 'msw'\n\n// 2. Define request handlers and response resolvers.\nconst worker = setupWorker(\n  rest.get('https://github.com/octocat', (req, res, ctx) => {\n    return res(\n      ctx.delay(1500),\n      ctx.status(202, 'Mocked status'),\n      ctx.json({\n        message: 'Mocked response JSON body',\n      }),\n    )\n  }),\n)\n\n// 3. Start the Service Worker.\nworker.start()\n```\n\nPerforming a `GET https://github.com/octocat` request in your application will result into a mocked response that you can inspect in your browser's \"Network\" tab:\n\n![Chrome DevTools Network screenshot with the request mocked](https://github.com/mswjs/msw/blob/main/media/msw-quick-look-network.png?raw=true)\n\n> **Tip:** Did you know that although Service Worker runs in a separate thread, your mock definition executes on the client-side? That way you can use the same languages (i.e. TypeScript), third-party libraries, and internal logic in mocks.\n\n## Node\n\n- [Learn more about using MSW in Node.js](https://mswjs.io/docs/getting-started/integrate/node)\n- [`setupServer` API](https://mswjs.io/docs/api/setup-server)\n\n### How does it work?\n\nAlthough Service Worker is a browser-specific API, this library allows reusing of the same mock definition to have API mocking in Node.js through augmenting native request issuing modules.\n\n### How is it different?\n\n- Prevents from stubbing `fetch`/`axios`/etc. as a part of your test, allowing you to treat API mocking as a pre-requisite and focus on what actually matters during testing.\n- The same mock definition you use for local development can be reused for testing.\n\n### Usage example\n\nHere's an example of an actual integration test in Jest that uses [React Testing Library](https://github.com/testing-library/react-testing-library) and Mock Service Worker:\n\n```js\n// test/LoginForm.test.js\nimport '@testing-library/jest-dom'\nimport React from 'react'\nimport { rest } from 'msw'\nimport { setupServer } from 'msw/node'\nimport { render, screen } from '@testing-library/react'\nimport userEvent from '@testing-library/user-event'\nimport Login from '../src/components/Login'\n\nconst server = setupServer(\n  rest.post('/login', (req, res, ctx) => {\n    // Respond with a mocked user token that gets persisted\n    // in the `sessionStorage` by the `Login` component.\n    return res(ctx.json({ token: 'mocked_user_token' }))\n  }),\n)\n\n// Enable API mocking before tests.\nbeforeAll(() => server.listen())\n\n// Reset any runtime request handlers we may add during the tests.\nafterEach(() => server.resetHandlers())\n\n// Disable API mocking after the tests are done.\nafterAll(() => server.close())\n\ntest('allows the user to log in', async () => {\n  render(<Login />)\n  userEvent.type(\n    screen.getByRole('textbox', { name: /username/i }),\n    'john.maverick',\n  )\n  userEvent.type(\n    screen.getByRole('textbox', { name: /password/i }),\n    'super-secret',\n  )\n  userEvent.click(screen.getByText(/submit/i))\n  const alert = await screen.findByRole('alert')\n\n  // Assert successful login state\n  expect(alert).toHaveTextContent(/welcome/i)\n  expect(window.sessionStorage.getItem('token')).toEqual(fakeUserResponse.token)\n})\n\ntest('handles login exception', () => {\n  server.use(\n    rest.post('/login', (req, res, ctx) => {\n      // Respond with \"500 Internal Server Error\" status for this test.\n      return res(\n        ctx.status(500),\n        ctx.json({ message: 'Internal Server Error' }),\n      )\n    }),\n  )\n\n  render(<Login />)\n  userEvent.type(\n    screen.getByRole('textbox', { name: /username/i }),\n    'john.maverick',\n  )\n  userEvent.type(\n    screen.getByRole('textbox', { name: /password/i }),\n    'super-secret',\n  )\n  userEvent.click(screen.getByText(/submit/i))\n\n  // Assert meaningful error message shown to the user\n  expect(alert).toHaveTextContent(/sorry, something went wrong/i)\n  expect(window.sessionStorage.getItem('token')).toBeNull()\n})\n```\n\n> **Tip:** Did you know that although the API is called `setupServer`, there are no actual servers involved? The name is chosen for familiarity, and the API is designed to resemble operating with an actual server.\n\n## Sponsors\n\n### Golden Sponsors\n\n> Become our first golden sponsor and get featured right here, enjoying other perks like issue prioritization and a personal consulting session with us.\n>\n> **Learn more on our [GitHub Sponsors profile](https://github.com/sponsors/mswjs)**.\n\n### Silver Sponsors\n\n> Become our _silver sponsor_ and get your profile image and link featured right here.\n>\n> **Learn more on our [GitHub Sponsors profile](https://github.com/sponsors/mswjs)**.\n\n<br />\n\n<a href=\"https://www.chromatic.com/\" target=\"_blank\">\n  <img src=\"media/sponsors/chromatic.svg#1\" alt=\"Chromatic\" width=\"75\" />\n</a>\n\n### Bronze Sponsors\n\n> Become our first _bronze sponsor_ and get your profile image and link featured in this section.\n>\n> **Learn more on our [GitHub Sponsors profile](https://github.com/sponsors/mswjs)**.\n\n## Awards & Mentions\n\n<table>\n  <tr valign=\"middle\">\n    <td width=\"124\">\n      <img src=\"https://raw.githubusercontent.com/mswjs/msw/main/media/tech-radar.png\" width=\"124\" alt=\"Technology Radar\">\n    </td>\n    <td>\n      <h4>Solution Worth Pursuing</h4>\n      <p><em><a href=\"https://www.thoughtworks.com/radar/languages-and-frameworks/mock-service-worker\">Technology Radar</a> (2020–2021)</em></p>\n    </td>\n  </tr>\n  <tr>\n    <td width=\"124\">\n      <img src=\"https://raw.githubusercontent.com/mswjs/msw/main/media/os-awards.png\" width=\"124\" alt=\"Open Source Awards 2020\">\n    </td>\n    <td>\n      <h4>The Most Exciting Use of Technology</h4>\n      <p><em><a href=\"https://osawards.com/javascript/2020\">Open Source Awards</a> (2020)</em></p>\n    </td>\n  </tr>\n</table>\n","readmeFilename":"README.md"}