Skip to content

Commit

Permalink
Improve test readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe committed Apr 24, 2022
1 parent c2d3905 commit a15561d
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions packages/internal/src/__tests__/graphqlSchema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,17 @@ test('Prints error message when schema loading fails', async () => {
try {
await generateGraphQLSchema()

expect(console.error).toHaveBeenNthCalledWith(
1,
'Schema loading failed.',
'Unknown type: "Shelf".'
)
expect(console.error).toHaveBeenNthCalledWith(
3,
'It looks like you have a Shelf model in your database schema.'
)
expect(console.error).toHaveBeenNthCalledWith(
4,
'Try running the generator you just used for that model first instead'
)
const invocation1to4 = (console.error as jest.Mock).mock.calls.slice(0, 4)
const invocation5 = (console.error as jest.Mock).mock.calls[4]

expect(invocation1to4).toEqual([
['Schema loading failed.', 'Unknown type: "Shelf".'],
[''],
['It looks like you have a Shelf model in your database schema.'],
['Try running the generator you just used for that model first instead'],
])
expect(invocation5[0]).toMatch('Schema loading failed')
expect(invocation5[1].toString()).toMatch('Error: Unknown type: "Shelf".')
} finally {
console.error = oldConsoleError
delete process.env.RWJS_CWD
Expand Down

0 comments on commit a15561d

Please sign in to comment.