1.0.1 • Published 7 years ago

nextjs-mock-app v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

NextJS Mock App

Build Status

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);
  });
});