Skip to content

Commit

Permalink
fixed the environment variable related issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cerosh committed Sep 2, 2024
1 parent 3c482de commit 11f9208
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
48 changes: 48 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
},
"dependencies": {
"@faker-js/faker": "^8.4.1",
"dotenv": "^16.4.5",
"path": "^0.12.7",
"xmlbuilder": "^15.1.1"
}
}
8 changes: 5 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { defineConfig, devices } from "@playwright/test";
import dotenv from "dotenv";
import path from "path";

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

dotenv.config({ path: path.resolve(__dirname, ".env") });

/**
* See https://playwright.dev/docs/test-configuration.
Expand All @@ -19,7 +21,7 @@ export default defineConfig({
/* Retry on CI only */
retries: process.env.CI ? 0 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
workers: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
Expand Down
5 changes: 3 additions & 2 deletions utils/request.helper.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { APIRequestContext } from "@playwright/test";
import Base_URL from "../playwright.config";
import config from "../playwright.config";

let cachedToken: string | null = null;
let tokenGenerationTime: Date | null = null;

async function fetchChallengerToken(
request: APIRequestContext
): Promise<string> {
const response = await request.post(`${Base_URL}/challenger`);
const baseURL = config.use?.baseURL;
const response = await request.post(`${baseURL}/challenger`);

if (!response.ok()) {
throw new Error("Failed to fetch X-CHALLENGER token");
Expand Down

0 comments on commit 11f9208

Please sign in to comment.