This repo provides spec helpers to be used in conjunction with the psychic web framework.
- Add this repo as a dev dependency in your psychic project (this is done by default for psychic apps, but worth mentioning in case it has been removed from your repo).
yarn add --dev @rvohealth/psychic-spec-helpers
- import psychic spec helpers in your jest setup. This is automatically set up when provisioning a new psychic app, so you should only need to do this with an a-typical setup.
// spec/unit/setup/hooks.ts
import "@rvohealth/psychic-spec-helpers";
...
- import and use the provided spec helpers:
import { specRequest as request } from '@rvohealth/psychic-spec-helpers'
import { PsychicController } from '@rvohealth/psychic'
describe('V1/Host/PlacesController', () => {
let user: User
let host: Host
beforeEach(async () => {
await request.init(PsychicServer)
user = await createUser()
})
describe('GET index', () => {
function subject(expectedStatus: number = 200) {
return request.get('/v1/host/places', expectedStatus, {
headers: addEndUserAuthHeader(request, user, {}),
})
}
it('returns the index of Places', async () => {
const place = await createPlace({ style: 'cabin', name: 'My cabin' })
await createHostPlace({ host, place })
const results = (await subject()).body
expect(results).toEqual([
expect.objectContaining({
id: place.id,
style: 'cabin',
name: 'My cabin',
}),
])
})
})
})
-
Ask them on Stack Overflow, using the
[psychic]
tag.
Psychic is an open source library, so we encourage you to actively contribute. Visit our Contributing guide to learn more about the processes we use for submitting pull requests or issues.
Are you trying to report a possible security vulnerability? Visit our Security Policy for guidelines about how to proceed.