1
0
mirror of https://github.com/uetchy/namae.git synced 2025-09-18 21:15:02 +09:00
Files
namae/api/setupJest.js
2019-08-14 19:55:28 +09:00

20 lines
383 B
JavaScript

import nock from 'nock'
nock.disableNetConnect()
// nock.recorder.rec()
global.mockProvider = async (provider, query) => {
const req = {
query,
}
const res = {
status: jest.fn().mockReturnThis(),
send: jest.fn().mockReturnThis(),
json: jest.fn().mockReturnThis(),
setHeader: jest.fn(),
}
await provider(req, res)
return res.json.mock.calls[0][0]
}