@bigbinary/neeto-playwright-commons 2.2.2 → 2.2.4

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.js CHANGED
@@ -125698,6 +125698,66 @@ function requireMain () {
125698
125698
  var mainExports = requireMain();
125699
125699
  var dotenvExpand = /*@__PURE__*/getDefaultExportFromCjs(mainExports);
125700
125700
 
125701
+ const E2E_TEST_DIR = "e2e/tests";
125702
+ const LOG_PREFIX = "[playwright.config]";
125703
+ const logInfo = (message) => process.stdout.write(`${LOG_PREFIX} ${message}\n`);
125704
+ const logError = (message) => process.stderr.write(`${LOG_PREFIX} ${message}\n`);
125705
+ /**
125706
+ * Patterns are often anchored for paths under `e2e/tests`, but Playwright
125707
+ * matches `testMatch` against absolute paths — so we also allow the same
125708
+ * pattern after any path ending in `/e2e/tests/`.
125709
+ */
125710
+ const normalizeSpecPattern = (pattern) => {
125711
+ if (!pattern.startsWith("^") || pattern.includes(E2E_TEST_DIR)) {
125712
+ return pattern;
125713
+ }
125714
+ return `(?:${pattern}|^.*\\/${E2E_TEST_DIR}\\/${pattern.slice(1)})`;
125715
+ };
125716
+ const compilePatterns = (patternStrings) => patternStrings.flatMap((pattern, index) => {
125717
+ const normalized = normalizeSpecPattern(pattern);
125718
+ try {
125719
+ return [new RegExp(normalized)];
125720
+ }
125721
+ catch (error) {
125722
+ logError(`Failed to compile spec pattern at index ${index}: ${pattern}. Normalized pattern: ${normalized}. ${error}`);
125723
+ return [];
125724
+ }
125725
+ });
125726
+ const parseSpecPatterns = () => {
125727
+ let parsed;
125728
+ const raw = process.env.PLAYWRIGHT_SPEC_PATTERNS_JSON?.trim();
125729
+ if (!raw) {
125730
+ logInfo("PLAYWRIGHT_SPEC_PATTERNS_JSON missing; using default test discovery.");
125731
+ return undefined;
125732
+ }
125733
+ logInfo(`PLAYWRIGHT_SPEC_PATTERNS_JSON received: ${raw}`);
125734
+ try {
125735
+ parsed = JSON.parse(raw);
125736
+ }
125737
+ catch (error) {
125738
+ logError(`Failed to parse PLAYWRIGHT_SPEC_PATTERNS_JSON; using default test discovery. ${error}`);
125739
+ return undefined;
125740
+ }
125741
+ if (!Array.isArray(parsed) || parsed.length === 0) {
125742
+ logError("Parsed spec patterns are empty or non-array; using default test discovery.");
125743
+ return undefined;
125744
+ }
125745
+ const patternStrings = parsed.filter((p) => typeof p === "string");
125746
+ if (patternStrings.length !== parsed.length) {
125747
+ logError(`Parsed spec patterns contain non-strings (${parsed.length - patternStrings.length}); using default test discovery.`);
125748
+ return undefined;
125749
+ }
125750
+ const compiledPatterns = compilePatterns(patternStrings);
125751
+ if (compiledPatterns.length === 0) {
125752
+ logError("No valid regex patterns compiled; using default test discovery.");
125753
+ return undefined;
125754
+ }
125755
+ logInfo(`Compiled spec regex patterns: ${compiledPatterns
125756
+ .map(pattern => pattern.toString())
125757
+ .join(", ")}`);
125758
+ return compiledPatterns;
125759
+ };
125760
+
125701
125761
  // @ts-check
125702
125762
  const loadEnv = (path) => dotenvExpand.expand(dotenv.config({ path, quiet: true }));
125703
125763
  const envBasePath = "./e2e/config/.env";
@@ -125787,6 +125847,7 @@ const definePlaywrightConfig = (overrides) => {
125787
125847
  ],
125788
125848
  ];
125789
125849
  }
125850
+ const specPatterns = parseSpecPatterns();
125790
125851
  return defineConfig({
125791
125852
  testDir: "./e2e/tests",
125792
125853
  fullyParallel: true,
@@ -125795,6 +125856,7 @@ const definePlaywrightConfig = (overrides) => {
125795
125856
  timeout: 5 * 60 * 1000,
125796
125857
  workers: isCI ? 6 : 5,
125797
125858
  reporter: isCI ? reporter : [["line"]],
125859
+ ...(specPatterns && { testMatch: specPatterns }),
125798
125860
  ...(IS_DEV_ENV && {
125799
125861
  webServer: [
125800
125862
  {