From 45aee95b079e741589e1736addde3d3a50a36961 Mon Sep 17 00:00:00 2001 From: Ray Foss Date: Tue, 5 Oct 2021 23:34:01 -0500 Subject: [PATCH] [dove/cli] Address strictNullCheck error on app.test.ts Strict null checks are on in our tsconfig.json... so we run into the following error without this PR. https://stackoverflow.com/a/58401023/370238 ``` test/app.test.ts:36:28 - error TS2532: Object is possibly 'undefined'. 36 assert.strictEqual(response.data.name, 'NotFound') ~~~~~~~~ ``` --- packages/cli/_templates/app/base/ts/app.test.ts.t | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/cli/_templates/app/base/ts/app.test.ts.t b/packages/cli/_templates/app/base/ts/app.test.ts.t index 91f67dfd48..3fad9ab02a 100644 --- a/packages/cli/_templates/app/base/ts/app.test.ts.t +++ b/packages/cli/_templates/app/base/ts/app.test.ts.t @@ -33,11 +33,14 @@ describe('Feathers application tests', () => { }); assert.fail('should never get here'); } catch (error) { - const { response } = error; - - assert.strictEqual(response.status, 404); - assert.strictEqual(response.data.code, 404); - assert.strictEqual(response.data.name, 'NotFound'); + if (axios.isAxiosError(error)) { + const { response } = error + assert.strictEqual(response?.status, 404) + assert.strictEqual(response?.data?.code, 404) + assert.strictEqual(response?.data?.name, 'NotFound') + } else { + assert.fail('Response is not an AxiosError') + } } }); });