From d7e51312a6bc8e02ea6696ec982e37bab7619119 Mon Sep 17 00:00:00 2001 From: Matthias Giger Date: Sun, 4 Feb 2024 22:07:45 +0100 Subject: [PATCH] fix(test): need iCloud mock on CI for test suite to pass release-npm --- test/secret.test.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/test/secret.test.ts b/test/secret.test.ts index 3e671ca..eec8cd0 100644 --- a/test/secret.test.ts +++ b/test/secret.test.ts @@ -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)) { @@ -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',