Skip to content

Instantly share code, notes, and snippets.

/server.test.ts Secret

Created March 7, 2018 06:46
Show Gist options
  • Save anonymous/3cc961b940c1906bacaec36e192ba625 to your computer and use it in GitHub Desktop.
Save anonymous/3cc961b940c1906bacaec36e192ba625 to your computer and use it in GitHub Desktop.
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