Resolves #115 (Jest & Supertest Configured for Unit Testing & CI)
Fixes #92 (type errors in strongly typed models - see relevant commit)
Notes:
Jest provides unit testing capabilities including stubs and mock objects.
Supertest provides endpoint testing capabilities.
Tests are kept in directory __tests__ in root.
Endpoint tests should run on a separate port (added TEST_PORT to .env.dist)
it('Succeeds to get the users endpoint', async done => {
// Sends GET Request to /test endpoint
const res = await request.get(`/users?key=${KEY}`);
expect(res.status).toBe(200);
expect(res.body).toBeDefined();
expect(getType(res.body)).toBe('array');
done();
})
Example of /events test:
it('Succeeds to get events by location with lat/long', async done => {
// Sends GET Request to /test endpoint
const res = await request.get(`/events?
index=location
&lat=39.9594667
&long=-75.2249542&key=**${KEY}**
&query={"category":"Music"}
&radius=2`);
expect(res.status).toBe(200);
expect(res.body).toBeDefined();
done()
})
Tests are now working on
/users
and/events
🥳Resolves #115 (Jest & Supertest Configured for Unit Testing & CI) Fixes #92 (type errors in strongly typed models - see relevant commit)
Notes:
Useful Documentation Here:
Example of
/users
test:Example of
/events
test: