▲ Server-Render like a Pro /w Redux-First Router in 10 steps at medium.com▼11 up and 3 down, posted by faceyspacey 2662 days ago 5 comments
faceyspacey 2660 days ago. link parent 1 point ▲ ▼So it's another way to accomplish what you might do with supertest right: *server/index.js:* ``` export default function startServer() { const app = express() // ... regular app.use stuff etc const server = http.createServer(app) if (process.env.NODE_ENV !== 'test') { server.listen(process.env.PORT || 80, () => { console.log('Listening on %j', server.address()) }) return server } ``` *__tests__/server.js:* ``` import request from 'supertest' import startServer from '../server' it('REQUEST: /', async () => { const server = startServer() const path = '/' const res = await request(server).get(path) expect(res.status).toEqual(200) }) ``` ??
tracker1 2657 days ago. link 1 point ▲ ▼No, it's a way to do unit tests without actually starting a server. but could work for your supertest example for more integration like testing.