@apolitical/testing
v2.1.4
Published
Node.js module to encapsulate Jest testing helpers (backend)
Maintainers
Readme
Apolitical Testing
Node.js module to encapsulate Jest testing helpers (backend)
Requirements
Requires the following to run:
Installation
Install with yarn:
yarn add -D @apolitical/testingUsage
First of all, include @apolitical/testing module:
const apoliticalTesting = require('@apolitical/testing');Request
The recommended way to use request helper is first by creating an instance with the session secret to encode the JWT tokens:
const instance = apoliticalTesting.request({ sessionSecret: 'hello' });Then, you can use your express app to generate supertests agents:
const agents = instance.generateAgents(app);The agents are:
loggedInloggedOutloggedInAdminloggedInMyself
The loggedInMyself agent can also be updated with custome token payload with the use of the assignTokenToMyself function.
