Visitar URL original
Introduction - Mock Service Worker
Skip to content

Introduction

Data querying library for testing JavaScript applications.

Data is a library for modeling and querying data when testing and developing JavaScript applications. It acts as a convenient way of creating schema-based fixtures and querying them with a familiar ORM-inspired syntax. You can use it standalone or together with Mock Service Worker for a seamless mocking experience on both the network and the data layers.

ts
import { 
Collection
} from '@msw/data'

Features ​

  • Standard Schema. Relies on Standard Schema instead of inventing a proprietary modeling syntax you have to learn. Describe your data with any compliant library, like Zod, ArkType, Valibot, yup, and many others.
  • Runtime and type safety. Records are validated against your schema and typed from it.
  • Powerful querying inspired by Prisma.
  • Relations for database-like behaviors, inspired by Drizzle.
  • Extensions, including custom ones, for things like cross-tab collection synchronization or record persistence.

Start here ​

If you've never used Data before, here's the best place to start:

Getting started

Create a collection, seed it with records, and query them.