Skip to content

Instantly share code, notes, and snippets.

/server.test.ts Secret

Created Mar 7, 2018
Embed
What would you like to do?
import request from 'supertest';
import app from './app';
const mockListen = jest.fn();
app.listen = mockListen;
afterEach(() => {
mockListen.mockReset();
});
test('Server works', async () => {
require('./server');
expect(mockListen.mock.calls.length).toBe(1);
expect(mockListen.mock.calls[0][0]).toBe(process.env.PORT || 3000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment