Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit dd37ec0

Browse files
Global setup of ignoreHTTPSErrors (#32)
API Tests PR: 32 - set ignoreHTTPSErrors in the global `use`. E.g. ```js export default defineConfig({ use: { ignoreHTTPSErrors: true, } ``` The idea is to apply it to all project configurations - The project `api` had `baseURL: process.env.TRUSTIFY_URL,` being defined in its own project but that is redundant as it is defined already in the global `export default defineConfig({})` definition --------- Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
1 parent 155427e commit dd37ec0

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

playwright.config.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const testDir = defineBddConfig({
1515

1616
const DESKTOP_CONFIG = {
1717
viewport: { height: 961, width: 1920 },
18-
ignoreHTTPSErrors: true,
1918
};
2019

2120
/**
@@ -40,6 +39,8 @@ export default defineConfig({
4039

4140
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
4241
trace: "on-first-retry",
42+
43+
ignoreHTTPSErrors: true,
4344
},
4445

4546
/* Configure projects for major browsers */
@@ -93,27 +94,18 @@ export default defineConfig({
9394
name: "api",
9495
testDir: "./tests/api/features",
9596
testMatch: /.*\.ts/,
96-
use: {
97-
baseURL: process.env.TRUSTIFY_URL,
98-
},
9997
dependencies: ["setup-api-data"],
10098
},
10199
{
102100
name: "setup-api-data",
103101
testDir: "./tests/api/dependencies",
104102
testMatch: "*.setup.ts",
105103
teardown: "cleanup-api-data",
106-
use: {
107-
...DESKTOP_CONFIG,
108-
},
109104
},
110105
{
111106
name: "cleanup-api-data",
112107
testDir: "./tests/api/dependencies",
113108
testMatch: "*.teardown.ts",
114-
use: {
115-
...DESKTOP_CONFIG,
116-
},
117109
},
118110

119111
/* Test against mobile viewports. */

tests/api/fixtures.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Client, createClient } from "@hey-api/client-axios";
22
import { test as base, expect } from "@playwright/test";
33
import axios, { AxiosInstance } from "axios";
4+
import https from "https";
45

56
import { logger } from "../common/constants";
67

@@ -128,19 +129,31 @@ type ApiClientFixture = {
128129
};
129130

130131
export const test = base.extend<ApiClientFixture>({
131-
axios: async ({ baseURL }, use) => {
132-
const axiosInstance = axios.create({ baseURL });
132+
axios: async ({ baseURL, ignoreHTTPSErrors }, use) => {
133+
const axiosInstance = axios.create({
134+
baseURL,
135+
httpsAgent: ignoreHTTPSErrors
136+
? new https.Agent({
137+
rejectUnauthorized: false,
138+
})
139+
: undefined,
140+
});
133141

134142
if (process.env.TRUSTIFY_AUTH_ENABLED === "true") {
135143
await initAxiosInstance(axiosInstance, baseURL);
136144
}
137145

138146
await use(axiosInstance);
139147
},
140-
client: async ({ baseURL }, use) => {
148+
client: async ({ baseURL, ignoreHTTPSErrors }, use) => {
141149
const client = createClient({
142150
baseURL,
143151
throwOnError: true,
152+
httpsAgent: ignoreHTTPSErrors
153+
? new https.Agent({
154+
rejectUnauthorized: false,
155+
})
156+
: undefined,
144157
});
145158

146159
if (process.env.TRUSTIFY_AUTH_ENABLED === "true") {

0 commit comments

Comments
 (0)