Slide 44
Slide 44 text
Allen Moore • @creativeallen • #syntaxcon • allenmoore.me/syntaxcon-2017
1 import test from 'tape';
2 import request from 'supertest';
3
4 const app = 'http://localhost:3000';
5
6 test( 'GET /posts', ( assert ) => {
7 request( app )
8 .get( '/posts' )
9 .expect( 200 )
10 .expect( 'Content-Type', 'application/json; charset=utf-8' )
11 .end( ( err, res ) => {
12 const expected = [{
13 id: 1,
14 title: 'A new test post'
15 }, {
16 id: 2,
17 title: 'Another test post'
18 }],
19 actual = res.body;
20
21 assert.error( err, 'No error' );
22 assert.same( actual, expected, 'Retrieve list of posts' );
23 assert.end();
24 } );
25 } );