Integrates Ember with MSW and provides test helpers.
- Ember.js v3.20 or above
- Ember CLI v3.20 or above
- Node.js v12 or above
ember install ember-msw
Installation notes:
- MSW is a dependency and does not need to be installed separately
- The addon hosts mockServiceWorker.js, so you don't need to generate one in your app
Steps to use the provided test helpers:
- Call
setupRequestMocking
in your test-helper.js
// tests/test-helper.js
// ...
import { setupRequestMocking } from 'ember-msw/test-support'; // <---
// ...
setApplication(Application.create(config.APP));
setup(QUnit.assert);
setupRequestMocking(); // <---
start();
- Use the
setupRequestMockingTest
andgetWorker
in your tests: see example.
All argument to setupRequestMocking
are forwarded to MSW's setupWorker
:
// tests/test-helper.js
setupRequestMocking(
rest.get('/assets/*', () => {}) // Pass through requests to /assets/*
);
See the Contributing guide for details.
This project is licensed under the MIT License.