From 3c8e3e7a6f106165b5352d516a7fb5f7e344d285 Mon Sep 17 00:00:00 2001 From: Technote Date: Wed, 20 Apr 2022 16:45:00 +0900 Subject: [PATCH 1/4] chore: tweaks --- .eslintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index cb319bac..5e8c02e7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -109,7 +109,7 @@ "sort-imports": 0, "import/order": [2, { "groups": ["type", "builtin", "external", "internal", "parent", "sibling", "index", "object"], - "alphabetize": { "order": "asc", "caseInsensitive": true }, + "alphabetize": { "order": "asc", "caseInsensitive": true } }] } } From 0220254647356e3c40eaa34e9bf2fc07e5d8bdf5 Mon Sep 17 00:00:00 2001 From: Technote Date: Wed, 20 Apr 2022 17:33:57 +0900 Subject: [PATCH 2/4] chore: tweaks --- vite.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index e30c1061..6bf1e60a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -9,7 +9,7 @@ export default defineConfig({ mockReset: true, restoreMocks: true, coverage: { - reporter: ['html', 'lcov'], + reporter: ['html', 'lcov', 'text'], }, }, }); From 6bdee0012a73ed2e0d9481d0c1339222aac8ede7 Mon Sep 17 00:00:00 2001 From: Technote Date: Wed, 20 Apr 2022 20:12:53 +0900 Subject: [PATCH 3/4] fix: type errors --- .eslintrc | 3 ++- src/command.ts | 6 +++--- src/utils.test.ts | 12 ++++++------ src/utils.ts | 12 ++++++------ tsconfig.json | 3 +-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.eslintrc b/.eslintrc index 5e8c02e7..801ea15b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -110,6 +110,7 @@ "import/order": [2, { "groups": ["type", "builtin", "external", "internal", "parent", "sibling", "index", "object"], "alphabetize": { "order": "asc", "caseInsensitive": true } - }] + }], + "@typescript-eslint/no-non-null-assertion": "off" } } diff --git a/src/command.ts b/src/command.ts index a96ff7ec..ceb90d9b 100644 --- a/src/command.ts +++ b/src/command.ts @@ -9,8 +9,8 @@ export const spyOnExportVariable = (): SpyInstance => vi.spyOn(core, 'expor export const exportVariableCalledWith = (spyOnMock: SpyInstance, pairs: { name: string, val: any }[]): void => { expect(spyOnMock).toBeCalledTimes(pairs.length); pairs.forEach(({ name, val }, index) => { - expect(spyOnMock.mock.calls[index][0]).toBe(name); - expect(spyOnMock.mock.calls[index][1]).toEqual(val); + expect(spyOnMock.mock.calls[index]![0]).toBe(name); + expect(spyOnMock.mock.calls[index]![1]).toEqual(val); }); }; @@ -19,6 +19,6 @@ export const spyOnAddPath = (): SpyInstance => vi.spyOn(core, 'addPath').mo export const addPathCalledWith = (spyOnMock: SpyInstance, paths: string[]): void => { expect(spyOnMock).toBeCalledTimes(paths.length); paths.forEach((path, index) => { - expect(spyOnMock.mock.calls[index][0]).toBe(path); + expect(spyOnMock.mock.calls[index]![0]).toBe(path); }); }; diff --git a/src/utils.test.ts b/src/utils.test.ts index 59edea96..8acc2f56 100644 --- a/src/utils.test.ts +++ b/src/utils.test.ts @@ -127,13 +127,13 @@ describe('testChildProcess, setChildProcessParams', () => { ]); expect(callback).toBeCalledTimes(2); expect(callback.mock.calls[0]).toHaveLength(3); - expect(callback.mock.calls[0][0]).toEqual(new Error('err1')); - expect(callback.mock.calls[0][1]).toBe('stdout1'); - expect(callback.mock.calls[0][2]).toBe('stderr1'); + expect(callback.mock.calls[0]![0]).toEqual(new Error('err1')); + expect(callback.mock.calls[0]![1]).toBe('stdout1'); + expect(callback.mock.calls[0]![2]).toBe('stderr1'); expect(callback.mock.calls[1]).toHaveLength(3); - expect(callback.mock.calls[1][0]).toEqual(new Error('err2')); - expect(callback.mock.calls[1][1]).toBe('stdout2'); - expect(callback.mock.calls[1][2]).toBe('stderr2'); + expect(callback.mock.calls[1]![0]).toEqual(new Error('err2')); + expect(callback.mock.calls[1]![1]).toBe('stdout2'); + expect(callback.mock.calls[1]![2]).toBe('stderr2'); }); it('should set mock params function 2', async() => { diff --git a/src/utils.ts b/src/utils.ts index 89267854..84bc479d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -93,7 +93,7 @@ export const testFs = (defaultExists = false): (boolean) => void => { // eslint-disable-next-line no-magic-numbers const result = count < existsData.length ? existsData[count] : existsData[existsData.length - 1]; count++; - return result; + return result!; })); }; const clearMock = (): void => { @@ -129,7 +129,7 @@ export const spyOnStdout = (): SpyInstance => global.mockStdout.write; export const stdoutCalledWith = (spyOnMock: SpyInstance, messages: string[]): void => { expect(spyOnMock).toBeCalledTimes(messages.length); messages.forEach((message, index) => { - expect(spyOnMock.mock.calls[index][0]).toBe(message + EOL); + expect(spyOnMock.mock.calls[index]![0]).toBe(message + EOL); }); }; export const stdoutContains = (spyOnMock: SpyInstance, messages: string[]): void => { @@ -146,13 +146,13 @@ export const execCalledWith = (spyOnMock: SpyInstance, messages: (string | any[ expect(spyOnMock).toBeCalledTimes(messages.length); messages.forEach((message, index) => { if (typeof message === 'string') { - expect(spyOnMock.mock.calls[index][0]).toBe(message); + expect(spyOnMock.mock.calls[index]![0]).toBe(message); } else { message.forEach((message, index2) => { - if (typeof spyOnMock.mock.calls[index][index2] === 'object') { - expect(spyOnMock.mock.calls[index][index2]).toEqual(message); + if (typeof spyOnMock.mock.calls[index]![index2] === 'object') { + expect(spyOnMock.mock.calls[index]![index2]).toEqual(message); } else { - expect(spyOnMock.mock.calls[index][index2]).toBe(message); + expect(spyOnMock.mock.calls[index]![index2]).toBe(message); } }); } diff --git a/tsconfig.json b/tsconfig.json index 565ba636..e0ed04bd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,8 +7,7 @@ "es2020" ], "noPropertyAccessFromIndexSignature": false, - "noImplicitAny": false, - "strictNullChecks": false + "noImplicitAny": false }, "include": [ "src" From 6dfd2fd2e07f3b24fb3d473bbcc6fa3208c50e73 Mon Sep 17 00:00:00 2001 From: Technote Date: Wed, 20 Apr 2022 20:13:52 +0900 Subject: [PATCH 4/4] feat: update package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fa6acdf4..4af99bc2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@technote-space/github-action-test-helper", - "version": "0.9.2", + "version": "0.9.3", "description": "Test helper for GitHub Actions.", "keywords": [ "github",