@probolabs/playwright 1.4.0-rc.2 โ†’ 1.4.0-rc.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/dist/index.d.ts CHANGED
@@ -470,6 +470,7 @@ interface TestStatistics {
470
470
  interface TestSuiteRunOptions {
471
471
  outputDir?: string;
472
472
  includeReporter?: boolean;
473
+ playwrightArgs?: string[];
473
474
  onStatusUpdate?: (updates: Partial<{
474
475
  status: string;
475
476
  exit_code: number;
package/dist/index.js CHANGED
@@ -1656,7 +1656,6 @@ export default defineConfig({
1656
1656
  // Keep Playwright's default console output, plus HTML report${includeReporter ? ', plus Probo live progress reporter' : ''}.
1657
1657
  reporter: ${JSON.stringify(reporters)},
1658
1658
  use: {
1659
- headless: true,
1660
1659
  ignoreHTTPSErrors: true,
1661
1660
  actionTimeout: 30000,
1662
1661
  navigationTimeout: 30000,
@@ -1665,7 +1664,6 @@ export default defineConfig({
1665
1664
  trace: 'on',
1666
1665
  },
1667
1666
  retries: 0,
1668
- workers: 1,
1669
1667
  });
1670
1668
  `;
1671
1669
  }
@@ -6069,6 +6067,9 @@ class TestSuiteRunner {
6069
6067
  const testSuiteDir = outputDir || getDefaultTestSuiteDir(testSuiteId, testSuiteName);
6070
6068
  // Generate code for all scenarios
6071
6069
  const codeGenResult = await ProboCodeGenerator.generateCodeForTestSuite(testSuiteId, apiToken, apiUrl);
6070
+ if (codeGenResult.scenarios.length === 0) {
6071
+ throw new Error(`No scenarios found in test suite ${testSuiteId}. Cannot generate test files.`);
6072
+ }
6072
6073
  // Ensure directories exist
6073
6074
  ensureDirectoryExists(testSuiteDir);
6074
6075
  const testsDir = path.join(testSuiteDir, 'tests');
@@ -6094,8 +6095,35 @@ class TestSuiteRunner {
6094
6095
  */
6095
6096
  static async generatePackageJson(outputDir, codeGenResult) {
6096
6097
  // Check if any scenario has secrets by examining the generated code
6097
- // We'll check for dotenv imports in the generated code
6098
- const hasSecrets = codeGenResult.scenarios.some(scenario => scenario.code.includes("import { config } from 'dotenv'"));
6098
+ // We'll check for dotenv imports in the generated code (check for multiple patterns to be robust)
6099
+ let hasSecrets = codeGenResult.scenarios.some(scenario => {
6100
+ const code = scenario.code;
6101
+ return code.includes("from 'dotenv'") ||
6102
+ code.includes('from "dotenv"') ||
6103
+ code.includes("import { config } from 'dotenv'") ||
6104
+ code.includes('import { config } from "dotenv"') ||
6105
+ code.includes("require('dotenv')") ||
6106
+ code.includes('require("dotenv")');
6107
+ });
6108
+ // Fallback: if not detected in codeGenResult, check the actual written files
6109
+ // This handles edge cases where the code might have been modified or generated differently
6110
+ if (!hasSecrets) {
6111
+ const testsDir = path.join(outputDir, 'tests');
6112
+ if (fs.existsSync(testsDir)) {
6113
+ const specFiles = fs.readdirSync(testsDir).filter(f => f.endsWith('.spec.ts'));
6114
+ for (const specFile of specFiles) {
6115
+ const filePath = path.join(testsDir, specFile);
6116
+ const content = fs.readFileSync(filePath, 'utf-8');
6117
+ if (content.includes("from 'dotenv'") ||
6118
+ content.includes('from "dotenv"') ||
6119
+ content.includes("import { config } from 'dotenv'") ||
6120
+ content.includes('import { config } from "dotenv"')) {
6121
+ hasSecrets = true;
6122
+ break;
6123
+ }
6124
+ }
6125
+ }
6126
+ }
6099
6127
  const sanitizedName = slugify(codeGenResult.testSuiteName);
6100
6128
  const packageJsonContent = generatePackageJson({
6101
6129
  name: sanitizedName,
@@ -6129,7 +6157,7 @@ class TestSuiteRunner {
6129
6157
  * Generates files, installs dependencies, and executes tests
6130
6158
  */
6131
6159
  static async runTestSuite(testSuiteId, apiToken, apiUrl, testSuiteName, runId, options = {}) {
6132
- const { outputDir, includeReporter = true, onStatusUpdate, onStdout, onStderr, onReporterEvent, } = options;
6160
+ const { outputDir, includeReporter = true, playwrightArgs = [], onStatusUpdate, onStdout, onStderr, onReporterEvent, } = options;
6133
6161
  const testSuiteDir = outputDir || getDefaultTestSuiteDir(testSuiteId, testSuiteName);
6134
6162
  let currentRunId = runId;
6135
6163
  try {
@@ -6208,6 +6236,9 @@ class TestSuiteRunner {
6208
6236
  }
6209
6237
  // Run Playwright tests with streaming output
6210
6238
  console.log(`๐Ÿš€ Running Playwright tests in ${testSuiteDir}...`);
6239
+ if (playwrightArgs.length > 0) {
6240
+ console.log(`๐Ÿงช Playwright extra args: ${playwrightArgs.join(' ')}`);
6241
+ }
6211
6242
  return new Promise(async (resolve) => {
6212
6243
  var _a, _b;
6213
6244
  let stdout = '';
@@ -6224,7 +6255,7 @@ class TestSuiteRunner {
6224
6255
  let lastStepsUpdate = 0;
6225
6256
  const collectedSteps = [];
6226
6257
  // Use spawn for streaming output
6227
- const testProcess = spawn('npx', ['playwright', 'test'], {
6258
+ const testProcess = spawn('npx', ['playwright', 'test', ...playwrightArgs], {
6228
6259
  cwd: testSuiteDir,
6229
6260
  shell: true,
6230
6261
  stdio: ['ignore', 'pipe', 'pipe'],