If you've ever written unit tests, you'll have needed to mock out API endpoints that are used in your components or stores.
With @nuxt/test-utils
this is really simple, because you get the registerEndpoint
utility method:
import { registerEndpoint } from '@nuxt/test-utils/runtime';import userTestData from './userTestData.json';registerEndpoint('/users/', () => userTestData);// ...tests
You can mock any server route (API endpoint), including external endpoints if you need.