From a15561d3c0dcaf6d26a7a9b141f77183c8a07750 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Mon, 18 Apr 2022 07:18:58 +0200 Subject: [PATCH] Improve test readability --- .../src/__tests__/graphqlSchema.test.ts | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/internal/src/__tests__/graphqlSchema.test.ts b/packages/internal/src/__tests__/graphqlSchema.test.ts index ee75fc5a2764..424f9ab9f1ed 100644 --- a/packages/internal/src/__tests__/graphqlSchema.test.ts +++ b/packages/internal/src/__tests__/graphqlSchema.test.ts @@ -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