@dev-blinq/bvt-playwright-js 1.0.0-dev.1 → 1.0.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.mts +12 -3
- package/index.mjs +30 -15
- package/index.mjs.map +1 -1
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -9298,9 +9298,18 @@ export type BlinqTestFixtures = {
|
|
|
9298
9298
|
readonly bvt: BlinqTestRuntime;
|
|
9299
9299
|
};
|
|
9300
9300
|
/**
|
|
9301
|
-
* Build a Playwright `test` extended with a `bvt` fixture
|
|
9302
|
-
*
|
|
9303
|
-
*
|
|
9301
|
+
* Build a Playwright `test` extended with a `bvt` fixture and a `beforeEach`
|
|
9302
|
+
* hook that navigates to the resolved environment's `baseURL`.
|
|
9303
|
+
*
|
|
9304
|
+
* The environments file is read **synchronously, once** when this function
|
|
9305
|
+
* is called (i.e. when `support/bvt.ts` is evaluated). The resolved baseURL
|
|
9306
|
+
* is then used by a `test.beforeEach` hook that runs **first** before each
|
|
9307
|
+
* test — Playwright executes `beforeEach` hooks in registration order, and
|
|
9308
|
+
* because `createBlinqTest` runs at module-evaluation time, any
|
|
9309
|
+
* user-registered `beforeEach` runs after this one.
|
|
9310
|
+
*
|
|
9311
|
+
* Generated spec files import `test` from this function and call
|
|
9312
|
+
* `bvt.executeCommand(...)` inside `test.step` blocks.
|
|
9304
9313
|
*/
|
|
9305
9314
|
export declare function createBlinqTest(options?: CreateBlinqTestOptions): import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & BlinqTestFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
9306
9315
|
|
package/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import crypto$1, { randomUUID } from "node:crypto";
|
|
2
|
+
import { createWriteStream, readFileSync } from "node:fs";
|
|
2
3
|
import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
|
|
3
4
|
import { tmpdir } from "node:os";
|
|
4
5
|
import path, { dirname } from "node:path";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
6
7
|
import { chromium, firefox, webkit } from "playwright";
|
|
7
8
|
import { expect } from "playwright/test";
|
|
8
|
-
import {
|
|
9
|
-
import { mkdirSync, readFileSync, statSync } from "fs";
|
|
9
|
+
import { mkdirSync, readFileSync as readFileSync$1, statSync } from "fs";
|
|
10
10
|
import { dirname as dirname$1 } from "path";
|
|
11
11
|
import { createContext, runInContext } from "node:vm";
|
|
12
12
|
import { test } from "@playwright/test";
|
|
@@ -19468,7 +19468,7 @@ var Tester = class {
|
|
|
19468
19468
|
});
|
|
19469
19469
|
}
|
|
19470
19470
|
async uploadFile(presignedUrl, filePath) {
|
|
19471
|
-
const fileData = readFileSync(filePath);
|
|
19471
|
+
const fileData = readFileSync$1(filePath);
|
|
19472
19472
|
this.obs.logger.log(`Uploading file from ${filePath} (size=${fileData.byteLength} bytes) via PUT`);
|
|
19473
19473
|
const response = await fetch(presignedUrl, {
|
|
19474
19474
|
method: "PUT",
|
|
@@ -24014,11 +24014,10 @@ var PlaywrightRunner = class {
|
|
|
24014
24014
|
return scope;
|
|
24015
24015
|
}
|
|
24016
24016
|
};
|
|
24017
|
-
|
|
24017
|
+
function loadEnvironmentsFileSync(filePath) {
|
|
24018
24018
|
if (!filePath) return null;
|
|
24019
24019
|
try {
|
|
24020
|
-
|
|
24021
|
-
return JSON.parse(raw);
|
|
24020
|
+
return JSON.parse(readFileSync(filePath, "utf8"));
|
|
24022
24021
|
} catch (error) {
|
|
24023
24022
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return null;
|
|
24024
24023
|
throw error;
|
|
@@ -24037,9 +24036,18 @@ function resolveEnvironmentParameters(environments) {
|
|
|
24037
24036
|
};
|
|
24038
24037
|
}
|
|
24039
24038
|
/**
|
|
24040
|
-
* Build a Playwright `test` extended with a `bvt` fixture
|
|
24041
|
-
*
|
|
24042
|
-
*
|
|
24039
|
+
* Build a Playwright `test` extended with a `bvt` fixture and a `beforeEach`
|
|
24040
|
+
* hook that navigates to the resolved environment's `baseURL`.
|
|
24041
|
+
*
|
|
24042
|
+
* The environments file is read **synchronously, once** when this function
|
|
24043
|
+
* is called (i.e. when `support/bvt.ts` is evaluated). The resolved baseURL
|
|
24044
|
+
* is then used by a `test.beforeEach` hook that runs **first** before each
|
|
24045
|
+
* test — Playwright executes `beforeEach` hooks in registration order, and
|
|
24046
|
+
* because `createBlinqTest` runs at module-evaluation time, any
|
|
24047
|
+
* user-registered `beforeEach` runs after this one.
|
|
24048
|
+
*
|
|
24049
|
+
* Generated spec files import `test` from this function and call
|
|
24050
|
+
* `bvt.executeCommand(...)` inside `test.step` blocks.
|
|
24043
24051
|
*/
|
|
24044
24052
|
function createBlinqTest(options = {}) {
|
|
24045
24053
|
const environmentsFilePath = toFilePath(options.environmentsFilePath);
|
|
@@ -24047,13 +24055,16 @@ function createBlinqTest(options = {}) {
|
|
|
24047
24055
|
const runtimeFilePath = toFilePath(options.testDataFilePath);
|
|
24048
24056
|
const logger = options.logger ?? console;
|
|
24049
24057
|
const defaultParameters = options.parameters ?? {};
|
|
24050
|
-
|
|
24051
|
-
|
|
24058
|
+
const envResolved = resolveEnvironmentParameters(loadEnvironmentsFileSync(environmentsFilePath));
|
|
24059
|
+
const baseParameters = {
|
|
24060
|
+
...defaultParameters,
|
|
24061
|
+
...envResolved,
|
|
24062
|
+
...seedFilePath ? { testDataSeedFilePath: seedFilePath } : {}
|
|
24063
|
+
};
|
|
24064
|
+
const test$1 = test.extend({ bvt: async ({ page }, use, testInfo) => {
|
|
24052
24065
|
const runner = new PlaywrightRunner({ parameters: {
|
|
24053
|
-
...
|
|
24054
|
-
|
|
24055
|
-
scenarioId: defaultParameters.scenarioId ?? testInfo.testId,
|
|
24056
|
-
...seedFilePath ? { testDataSeedFilePath: seedFilePath } : {},
|
|
24066
|
+
...baseParameters,
|
|
24067
|
+
scenarioId: baseParameters.scenarioId ?? testInfo.testId,
|
|
24057
24068
|
...runtimeFilePath ? { testDataFilePath: runtimeFilePath } : { testDataFilePath: path.join(tmpdir(), `blinq-bvt-playwright-${process.pid}-${testInfo.workerIndex}-${testInfo.testId}.json`) }
|
|
24058
24069
|
} }, { logger });
|
|
24059
24070
|
runner.attach(page);
|
|
@@ -24071,6 +24082,10 @@ function createBlinqTest(options = {}) {
|
|
|
24071
24082
|
runner.detach();
|
|
24072
24083
|
}
|
|
24073
24084
|
} });
|
|
24085
|
+
test$1.beforeEach(async ({ page }) => {
|
|
24086
|
+
if (baseParameters.baseUrl) await page.goto(baseParameters.baseUrl);
|
|
24087
|
+
});
|
|
24088
|
+
return test$1;
|
|
24074
24089
|
}
|
|
24075
24090
|
|
|
24076
24091
|
//#endregion
|