Skip to content

Commit

Permalink
fix(test): need iCloud mock on CI for test suite to pass
Browse files Browse the repository at this point in the history
release-npm
  • Loading branch information
tobua committed Feb 4, 2024
1 parent 71de27f commit d7e5131
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions test/secret.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { test, expect, beforeEach, afterEach } from 'bun:test'
import { existsSync, readFileSync, writeFileSync, rmSync } from 'fs'
import { join } from 'path'
import { test, expect, beforeEach, afterEach, beforeAll } from 'bun:test'
import { existsSync, readFileSync, writeFileSync, rmSync, mkdirSync } from 'fs'
import { join, dirname } from 'path'
import { homedir } from 'os'
import { execSync } from 'child_process'

console.log(process.cwd())

const configurationPath = join(
homedir(),
'Library/Mobile Documents/com~apple~CloudDocs/Documents/.env-variables',
)

// Create iCloud store mock in CI.
beforeAll(() => {
if (process.env.CI) {
mkdirSync(dirname(configurationPath), {
recursive: true,
})
}
})

let initialContents = ''
beforeEach(() => {
if (existsSync(configurationPath)) {
Expand All @@ -28,8 +35,6 @@ afterEach(() => {
test('Creates configuration file if none is found.', () => {
expect(existsSync(configurationPath)).toBe(false)

console.log(process.cwd())

const output = execSync('bun cli/secret.ts', {
cwd: '.',
stdio: 'pipe',
Expand Down

0 comments on commit d7e5131

Please sign in to comment.