Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pamella committed Jan 16, 2024
1 parent 878b038 commit 312b862
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@ on:
pull_request:
branches: [main]
push:
branches: [main]
branches: [main, pnpm-setup]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: pnpm/[email protected]
with:
version: 8

- name: Use Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'pnpm'

- name: Install Dependencies
run: npm ci
run: pnpm install

- name: Run Tests
run: npm test
run: pnpm run test
2 changes: 1 addition & 1 deletion packages/client/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import base from '../../jest.config.base.js';
export default {
...base,
testEnvironment: 'jest-environment-jsdom',
setupFiles: ['../../test-setup.ts'],
// setupFiles: ['../../test-setup.ts'],
setupFilesAfterEnv: ['../../test-setup-after-env.ts'],
};
2 changes: 1 addition & 1 deletion packages/server/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import base from '../../jest.config.base.js';
export default {
...base,
testEnvironment: 'node',
setupFiles: ['../../test-setup.ts'],
// setupFiles: ['../../test-setup.ts'],
setupFilesAfterEnv: ['../../test-setup-after-env.ts'],
};
11 changes: 11 additions & 0 deletions test-setup-after-env.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
const originalEnv = process.env;

beforeEach(() => {
jest.resetModules();
jest.clearAllMocks();
process.env = {
...originalEnv,
OPENAI_API_KEY: 'YOUR_MOCKED_VALUE',
};
});

afterEach(() => {
process.env = originalEnv;
});
2 changes: 1 addition & 1 deletion test-setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
process.env.OPENAI_API_KEY = 'test-api-key';
// process.env.OPENAI_API_KEY = 'test-api-key';

0 comments on commit 312b862

Please sign in to comment.