Skip to content

Commit 4b79740

Browse files
Update endpoint testing recipe to use correct options for got
Co-authored-by: Sindre Sorhus <[email protected]>
1 parent baaf99a commit 4b79740

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

docs/recipes/endpoint-testing.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,20 @@ const app = require('../app');
1717

1818
test.before(async t => {
1919
t.context.server = http.createServer(app);
20-
t.context.baseUrl = await listen(t.context.server);
20+
t.context.prefixUrl = await listen(t.context.server);
2121
});
2222

2323
test.after.always(t => {
2424
t.context.server.close();
2525
});
2626

2727
test.serial('get /user', async t => {
28-
const res = await got('/user', { baseUrl: t.context.baseUrl, json: true });
29-
t.is(res.body.email, '[email protected]');
28+
const {email} = await got('user', {prefixUrl: t.context.prefixUrl}).json();
29+
t.is(email, '[email protected]');
3030
});
3131
```
3232

3333
Other libraries you may find useful:
3434

3535
- [`supertest`](https://github.com/visionmedia/supertest)
3636
- [`get-port`](https://github.com/sindresorhus/get-port)
37-

0 commit comments

Comments
 (0)