Show a helpful message only if test fails

Inspired by the `ON FAIL` markup from the previous commit
0f2398295bcced3af3772bb4add1f42472c97893
This commit is contained in:
roschaefer 2019-09-12 16:57:05 +02:00
parent 0f2398295b
commit 9233049ff3

View File

@ -114,7 +114,7 @@ describe('slugifyMiddleware', () => {
}) })
describe('but if the client specifies a slug', () => { describe('but if the client specifies a slug', () => {
it('rejects CreatePost (on FAIL Neo4j constraints may not defined in database)', async () => { it('rejects CreatePost', async (done) => {
variables = { variables = {
...variables, ...variables,
title: 'Pre-existing post', title: 'Pre-existing post',
@ -122,18 +122,31 @@ describe('slugifyMiddleware', () => {
slug: 'pre-existing-post', slug: 'pre-existing-post',
categoryIds, categoryIds,
} }
await expect( try {
mutate({ await expect(mutate({ mutation: createPostMutation, variables })).resolves.toMatchObject({
mutation: createPostMutation, errors: [
variables, {
}), message: 'Post with this slug already exists!',
).resolves.toMatchObject({ },
errors: [ ],
{ })
message: 'Post with this slug already exists!', done()
}, } catch(error) {
], throw new Error(`
}) ${error}
Probably your database has no unique constraints!
To see all constraints go to http://localhost:7474/browser/ and
paste the following:
\`\`\`
CALL db.constraints();
\`\`\`
Learn how to setup the database here:
https://docs.human-connection.org/human-connection/neo4j
`)
}
}) })
}) })
}) })