Skip to content

Commit

Permalink
moved username password consts used in Api unit tests to .env and set…
Browse files Browse the repository at this point in the history
…up jest to load the package specific .env file
  • Loading branch information
ahmednooor committed Jan 10, 2024
1 parent b5b18b3 commit b5bfef0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/sdk/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# for Api tests
# https://dummyjson.com/docs/auth
API_USERNAME=...
API_PASSWORD=...
4 changes: 4 additions & 0 deletions packages/sdk/jest-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// setup file for jest
import * as dotenv from 'dotenv';
import path from 'path';
dotenv.config({ path: path.resolve(__dirname, './.env') });
1 change: 1 addition & 0 deletions packages/sdk/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ export default {
moduleFileExtensions: ['ts', 'js', 'html'],
testEnvironment: 'node',
coverageDirectory: '../../coverage/packages/sdk',
setupFiles: ['./jest-setup.ts'],
};
4 changes: 2 additions & 2 deletions packages/sdk/src/lib/Api/Api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Api } from './Api';

describe('Api', () => {
let api: Api;
const USERNAME = 'kminchelle';
const PASSWORD = '0lelplR';
const USERNAME = process.env['API_USERNAME'] || '';
const PASSWORD = process.env['API_PASSWORD'] || '';

beforeAll(() => {
api = new Api();
Expand Down

0 comments on commit b5bfef0

Please sign in to comment.