nextjs-mock-app
v1.0.1
Published
A typed mock NextJS app for use with testing suites like Jest.
Downloads
3
Maintainers
Readme
NextJS Mock App
A typed mock NextJS app for use with testing suites like Jest.
Usage
import { Request } from 'jest-express/lib/request';
import { Response } from 'jest-express/lib/response';
import mockApp from 'nextjs-mock-app';
const html = '<div>Success</div>';
describe('Express middleware render', () => {
beforeEach(() => {
req = new Request();
res = new Response();
});
afterEach(() => {
req.resetMocked();
res.resetMocked();
});
it('should send the rendered html', async () => {
mockApp.renderToHTML = renderToHTML;
await render(mockApp, req, res);
expect(res.send).toBeCalledWith(html);
});
});