Skip to content

Commit

Permalink
chore(test): Document vitest issue in cli-helper test (#11032)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Jul 21, 2024
1 parent 2c3b78a commit 1085f84
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions packages/cli-helpers/src/lib/__tests__/project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
})
Expand Down

0 comments on commit 1085f84

Please sign in to comment.