@bigbinary/neeto-playwright-commons 2.2.2 → 2.2.3
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.cjs.js +62 -0
- package/index.cjs.js.map +1 -1
- package/index.js +62 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -125719,6 +125719,66 @@ function requireMain () {
|
|
|
125719
125719
|
var mainExports = requireMain();
|
|
125720
125720
|
var dotenvExpand = /*@__PURE__*/getDefaultExportFromCjs(mainExports);
|
|
125721
125721
|
|
|
125722
|
+
const E2E_TEST_DIR = "e2e/tests";
|
|
125723
|
+
const LOG_PREFIX = "[playwright.config]";
|
|
125724
|
+
const logInfo = (message) => process.stdout.write(`${LOG_PREFIX} ${message}\n`);
|
|
125725
|
+
const logError = (message) => process.stderr.write(`${LOG_PREFIX} ${message}\n`);
|
|
125726
|
+
/**
|
|
125727
|
+
* Patterns are often anchored for paths under `e2e/tests`, but Playwright
|
|
125728
|
+
* matches `testMatch` against absolute paths — so we also allow the same
|
|
125729
|
+
* pattern after any path ending in `/e2e/tests/`.
|
|
125730
|
+
*/
|
|
125731
|
+
const normalizeSpecPattern = (pattern) => {
|
|
125732
|
+
if (!pattern.startsWith("^") || pattern.includes(E2E_TEST_DIR)) {
|
|
125733
|
+
return pattern;
|
|
125734
|
+
}
|
|
125735
|
+
return `(?:${pattern}|^.*\\/${E2E_TEST_DIR}\\/${pattern.slice(1)})`;
|
|
125736
|
+
};
|
|
125737
|
+
const compilePatterns = (patternStrings) => patternStrings.flatMap((pattern, index) => {
|
|
125738
|
+
const normalized = normalizeSpecPattern(pattern);
|
|
125739
|
+
try {
|
|
125740
|
+
return [new RegExp(normalized)];
|
|
125741
|
+
}
|
|
125742
|
+
catch (error) {
|
|
125743
|
+
logError(`Failed to compile spec pattern at index ${index}: ${pattern}. Normalized pattern: ${normalized}. ${error}`);
|
|
125744
|
+
return [];
|
|
125745
|
+
}
|
|
125746
|
+
});
|
|
125747
|
+
const parseSpecPatterns = () => {
|
|
125748
|
+
let parsed;
|
|
125749
|
+
const raw = process.env.PLAYWRIGHT_SPEC_PATTERNS_JSON?.trim();
|
|
125750
|
+
if (!raw) {
|
|
125751
|
+
logInfo("PLAYWRIGHT_SPEC_PATTERNS_JSON missing; using default test discovery.");
|
|
125752
|
+
return undefined;
|
|
125753
|
+
}
|
|
125754
|
+
logInfo(`PLAYWRIGHT_SPEC_PATTERNS_JSON received: ${raw}`);
|
|
125755
|
+
try {
|
|
125756
|
+
parsed = JSON.parse(raw);
|
|
125757
|
+
}
|
|
125758
|
+
catch (error) {
|
|
125759
|
+
logError(`Failed to parse PLAYWRIGHT_SPEC_PATTERNS_JSON; using default test discovery. ${error}`);
|
|
125760
|
+
return undefined;
|
|
125761
|
+
}
|
|
125762
|
+
if (!Array.isArray(parsed) || parsed.length === 0) {
|
|
125763
|
+
logError("Parsed spec patterns are empty or non-array; using default test discovery.");
|
|
125764
|
+
return undefined;
|
|
125765
|
+
}
|
|
125766
|
+
const patternStrings = parsed.filter((p) => typeof p === "string");
|
|
125767
|
+
if (patternStrings.length !== parsed.length) {
|
|
125768
|
+
logError(`Parsed spec patterns contain non-strings (${parsed.length - patternStrings.length}); using default test discovery.`);
|
|
125769
|
+
return undefined;
|
|
125770
|
+
}
|
|
125771
|
+
const compiledPatterns = compilePatterns(patternStrings);
|
|
125772
|
+
if (compiledPatterns.length === 0) {
|
|
125773
|
+
logError("No valid regex patterns compiled; using default test discovery.");
|
|
125774
|
+
return undefined;
|
|
125775
|
+
}
|
|
125776
|
+
logInfo(`Compiled spec regex patterns: ${compiledPatterns
|
|
125777
|
+
.map(pattern => pattern.toString())
|
|
125778
|
+
.join(", ")}`);
|
|
125779
|
+
return compiledPatterns;
|
|
125780
|
+
};
|
|
125781
|
+
|
|
125722
125782
|
// @ts-check
|
|
125723
125783
|
const loadEnv = (path) => dotenvExpand.expand(dotenv.config({ path, quiet: true }));
|
|
125724
125784
|
const envBasePath = "./e2e/config/.env";
|
|
@@ -125808,6 +125868,7 @@ const definePlaywrightConfig = (overrides) => {
|
|
|
125808
125868
|
],
|
|
125809
125869
|
];
|
|
125810
125870
|
}
|
|
125871
|
+
const specPatterns = parseSpecPatterns();
|
|
125811
125872
|
return test.defineConfig({
|
|
125812
125873
|
testDir: "./e2e/tests",
|
|
125813
125874
|
fullyParallel: true,
|
|
@@ -125816,6 +125877,7 @@ const definePlaywrightConfig = (overrides) => {
|
|
|
125816
125877
|
timeout: 5 * 60 * 1000,
|
|
125817
125878
|
workers: isCI ? 6 : 5,
|
|
125818
125879
|
reporter: isCI ? reporter : [["line"]],
|
|
125880
|
+
...(specPatterns && { testMatch: specPatterns }),
|
|
125819
125881
|
...(IS_DEV_ENV && {
|
|
125820
125882
|
webServer: [
|
|
125821
125883
|
{
|