Skip to content

Latest commit

 

History

History
 
 

README.md

Angular (REST)

This repository illustrates how to use Mock Service Worker to mock a REST API for development, unit and E2E testing in an Angular project.

Technologies

Getting started

$ git clone https://github.com/mswjs/examples.git
$ cd examples
$ yarn
$ cd rest-angular

Running locally

$ yarn start

Tests

Unit tests

$ yarn test:unit

E2E tests

$ yarn test:e2e

Key points

Browser

  • src/mocks/browser.ts sets up the Service Worker.
  • src/main.ts conditionally enables mocking in development environment.
  • src/mockServiceWorker.js the Service Worker, created by running npx msw init src.
  • Add src/mockServiceWorker.js file to the assets list in your angular.json file.

NodeJS