From 1085f844fdd6f37a6d8f8637e350cd296c82b250 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Sun, 21 Jul 2024 12:27:14 +0200 Subject: [PATCH] chore(test): Document vitest issue in cli-helper test (#11032) --- .../src/lib/__tests__/project.test.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/cli-helpers/src/lib/__tests__/project.test.ts b/packages/cli-helpers/src/lib/__tests__/project.test.ts index 322fba9786cb..82eef65df9c6 100644 --- a/packages/cli-helpers/src/lib/__tests__/project.test.ts +++ b/packages/cli-helpers/src/lib/__tests__/project.test.ts @@ -54,15 +54,10 @@ describe('addEnvVar', () => { describe('addEnvVar adds environment variables as part of a setup task', () => { beforeEach(() => { - vi.spyOn(fs, 'existsSync').mockImplementation(() => { - return true - }) + vi.spyOn(fs, 'existsSync').mockReturnValue(true) - // @ts-expect-error We're only returning a string rather than the expected Buffer | string - // which is determined by the options parameter passed to the real fs.readFileSync - vi.spyOn(fs, 'readFileSync').mockImplementation(() => { - return envFileContent - }) + // @ts-expect-error https://github.com/vitest-dev/vitest/issues/6182 + vi.spyOn(fs, 'readFileSync').mockImplementation(() => envFileContent) vi.spyOn(fs, 'writeFileSync').mockImplementation((envPath, envFile) => { expect(envPath).toContain('.env') @@ -130,12 +125,9 @@ describe('addEnvVar', () => { describe('updateTomlConfig', () => { describe('updateTomlConfig configures a new CLI plugin', () => { beforeEach(() => { - vi.spyOn(fs, 'existsSync').mockImplementation(() => { - return true - }) + vi.spyOn(fs, 'existsSync').mockReturnValue(true) - // @ts-expect-error We're only returning a string rather than the expected Buffer | string - // which is determined by the options parameter passed to the real fs.readFileSync + // @ts-expect-error https://github.com/vitest-dev/vitest/issues/6182 vi.spyOn(fs, 'readFileSync').mockImplementation(() => { return toml.stringify(defaultRedwoodToml) })