msw
nestia
Our great sponsors
msw | nestia | |
---|---|---|
148 | 37 | |
14,848 | 1,612 | |
2.3% | - | |
9.2 | 9.6 | |
1 day ago | 3 days ago | |
TypeScript | TypeScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
msw
-
Easier TypeScript API Testing with Vitest + MSW
However, I discovered a great combination that transformed my API call testing in TypeScript: Vitest and Mock Service Worker (MSW). Their well-crafted design makes them incredibly easy to use, enhancing the overall testing experience.
-
Creating mocks for testing react code
While mocks are effective, they require modifying the component's internal logic or mocking global functions like fetch. This can become cumbersome for complex components with numerous API interactions. Here's where MSW shines.
-
Storybook 8
> For those wondering what the use case is, you must not have tried it. It does take work to set up (with each version that's less), but it can be very nice to test in isolation esp in cases where a component is under a login, the 4th page of a 10 page form, etc. Also obviously if you're working on a component library that ships without an app, Storybook can be your development and/or demo app.
I have worked with storybook extensively over the past couple of years and my team is moving away from it in favour of MSW (https://mswjs.io).
For "4th page of a 10 page form" during the development there's hot reloading which is really stable nowadays and haven't failed me, although I understand that some setups are old and it might be easier to configure Storybook than good hot reloading.
I'm not entirely sure about the testing part of it and I'd be grateful if you could elaborate. I haven't felt the need for some special setup with SB because for unit tests, I can test a deeply nested component separately. For E2E tests, I usually test the whole form.
I agree on the component library part, this is probably the only use case where Storybook is 100% justified, but I'm unconvinced about the
Additionally, thank you to all our community launch partners across the frontend ecosystem for helping us bring Storybook 8 to the world! Thanks to Chromatic, Figma, ViteConf, Omlet, DivRiots, story.to.design, StackBlitz, UXpin, Nx, Mock Service Worker, Anima, Zeplin, zeroheight, kickstartDS, and Kendo UI.
-
I made "TypeScript Swagger Editor", new type of Swagger UI writing TypeScript code in the browser
similar with msw.js, but fully automated
-
Partial: how not to mock the whole world
they could be network mocks (use msw)
-
How to Automatically Consume RESTful APIs in Your Frontend
With orval, we can also integrate the API client in our unit tests. Orval provides first class support for mocking through the (Mock Service Worker)[https://mswjs.io/] library, and it can automatically generate the MSW handlers for testing server.
- Polly.js – Record, replay, and stub HTTP interactions
-
How to Successfully Integrate with Legacy APIs Using NodeJS
Consider a hypothetical scenario where data from a list of companies within an ERP needs to be retrieved. As a personal recommendation, leverage tools like MSW for top-level mocks, which can significantly enhance the testing process.
- How do you manage Dependency Injection in Next.js APPS?
nestia
-
I made "TypeScript Swagger Editor", new type of Swagger UI writing TypeScript code in the browser
For reference, if your backend application utilizes nestia (NestJS), you don't need to build the SDK (Software Development Kit) library by converting from the Swagger Documents. The nestia will automatically generate the much advanced SDK library, just by analyzing your backend application's source code.
-
[Typia] I made Protocol Buffer library of TypeScript, easiest in the world
Also, I'd introduced my another library nestia, which utilizes typia in the NestJS framework, so that boosts up backend server performance 30x up. And since typia analyzes the NestJS backend source code at the compiler level, I also provided convenient generators such as SDK and Mockup Simulator.
-
Good bye "typescript-is" (ancestor of "typia", 20,000x faster validator)
nestia: https://github.com/samchon/nestia
-
Migration tool from Swagger to NestJS - SDK generator and Mockup simulator for every backend stacks
/** * @controller BodyController.post() * @path POST /body * @nestia Generated by Nestia - https://github.com/samchon/nestia */ export async function post( connection: IConnection, body: IBbsArticle.IStore, ): Promise { return !!connection.simulate ? post.simulate( connection, body, ) : Fetcher.fetch( connection, post.ENCRYPTED, post.METHOD, post.path(), body, ); } export namespace post { export type Input = IBbsArticle.IStore; export type Output = IBbsArticle;
-
[Nestia] I made backend simulator for frontend developers (similar with MSW, but fully automated)
When you build backend simulator of nestia, nestia analyzes your backend server source codes, and writes fake scripts simulating the NestJS backend server. The simulator even includes request data validator and random mock-up data generator.
-
[NestJS] I made backend server simulator without backend server
/** * @packageDocumentation * @module api.functional.bbs.articles * @nestia Generated by Nestia - https://github.com/samchon/nestia */ //================================================================ import { Fetcher } from "@nestia/fetcher"; import type { IConnection } from "@nestia/fetcher"; import typia from "typia"; import { NestiaSimulator } from "./../../../utils/NestiaSimulator"; import type { IBbsArticle } from "./../../../structures/IBbsArticle"; /** * Update an article. * * @param section Section code * @param id Target article ID * @param input Content to update * @returns Updated content * * @controller BbsArticlesController.update() * @path PUT /bbs/:section/articles/:id * @nestia Generated by Nestia - https://github.com/samchon/nestia */ export async function update( connection: IConnection, section: string, id: string, input: update.Input, ): Promise { return !!connection.random ? update.simulate( connection, section, id, input, ) : Fetcher.fetch( connection, update.ENCRYPTED, update.METHOD, update.path(section, id), input, ); } export namespace update { export type Input = IBbsArticle.IStore; export type Output = IBbsArticle; export const METHOD = "PUT" as const; export const PATH: string = "/bbs/:section/articles/:id"; export const ENCRYPTED: Fetcher.IEncrypted = { request: false, response: false, }; export const path = (section: string, id: string): string => { return `/bbs/${encodeURIComponent(section ?? "null")}/articles/${encodeURIComponent(id ?? "null")}`; } export const random = (g?: Partial): Output => typia.random(g); export const simulate = async ( connection: IConnection, section: string, id: string, input: update.Input, ): Promise => { const assert = NestiaSimulator.assert({ method: METHOD, host: connection.host, path: path(section, id) }); assert.param("section")("string")(() => typia.assert(section)); assert.param("id")("uuid")(() => typia.assert(id)); assert.body(() => typia.assert(input)); return typia.random( typeof connection.random === 'object' && connection.random !== null ? connection.random : undefined ); } }
-
[Nestia] Make NestJS 30x faster with fastify
For reference, you can run the benchmark program on your computer by following below commands. After the benchmark, a report would be issued under nestia/benchmark/results/{YOUR-CPU-NAME} directory. If you send the result PR on my repo (https://github.com/samchon/nestia), I'd pleasure and appreciate it even more.
-
[Nestia] I made automatic e2e test functions generator for NestJS
I made automatic e2e test functions generator for NestJS, corresponding to every API endpoints. Just setup nestia following the guide documents, and run npx nestia e2e comnand, then you can get the automatically generated e2e functions.
- Nestia, make NestJS super-fast and super-easy
-
I made Express to be faster than Fastify (also NestJS)
Then what about using NestJS with nestia?
What are some alternatives?
Nock - HTTP server mocking and expectations library for Node.js
Nest - A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
rtk-query - Data fetching and caching addon for Redux Toolkit
typia - Super-fast/easy runtime validations and serializations through transformation
miragejs - A client-side server to build, test and share your JavaScript app
GraphQL-NestJS-MongoDB-TypeScript-Tutorial - A GraphQL API build on top of NextJS
mockoon - Mockoon is the easiest and quickest way to run mock APIs locally. No remote deployment, no account required, open source.
trpc-fe-boilerplate-next - ⚒️ Minimal tRPC frontend Nextjs boilerplate for separate BE-FE repositories. Easily consume fully typesafe APIs.
prism - Turn any OpenAPI2/3 and Postman Collection file into an API server with mocking, transformations and validations.
typescript-starter - Quickly create and configure a new library or Node.js project
axios - Promise based HTTP client for the browser and node.js
blockfrost-js - Node.js SDK for the Blockfrost.io API.