@probolabs/playwright 1.4.0-rc.1 → 1.4.0-rc.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/dist/index.js CHANGED
@@ -6069,6 +6069,9 @@ class TestSuiteRunner {
6069
6069
  const testSuiteDir = outputDir || getDefaultTestSuiteDir(testSuiteId, testSuiteName);
6070
6070
  // Generate code for all scenarios
6071
6071
  const codeGenResult = await ProboCodeGenerator.generateCodeForTestSuite(testSuiteId, apiToken, apiUrl);
6072
+ if (codeGenResult.scenarios.length === 0) {
6073
+ throw new Error(`No scenarios found in test suite ${testSuiteId}. Cannot generate test files.`);
6074
+ }
6072
6075
  // Ensure directories exist
6073
6076
  ensureDirectoryExists(testSuiteDir);
6074
6077
  const testsDir = path.join(testSuiteDir, 'tests');
@@ -6094,8 +6097,35 @@ class TestSuiteRunner {
6094
6097
  */
6095
6098
  static async generatePackageJson(outputDir, codeGenResult) {
6096
6099
  // 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'"));
6100
+ // We'll check for dotenv imports in the generated code (check for multiple patterns to be robust)
6101
+ let hasSecrets = codeGenResult.scenarios.some(scenario => {
6102
+ const code = scenario.code;
6103
+ return code.includes("from 'dotenv'") ||
6104
+ code.includes('from "dotenv"') ||
6105
+ code.includes("import { config } from 'dotenv'") ||
6106
+ code.includes('import { config } from "dotenv"') ||
6107
+ code.includes("require('dotenv')") ||
6108
+ code.includes('require("dotenv")');
6109
+ });
6110
+ // Fallback: if not detected in codeGenResult, check the actual written files
6111
+ // This handles edge cases where the code might have been modified or generated differently
6112
+ if (!hasSecrets) {
6113
+ const testsDir = path.join(outputDir, 'tests');
6114
+ if (fs.existsSync(testsDir)) {
6115
+ const specFiles = fs.readdirSync(testsDir).filter(f => f.endsWith('.spec.ts'));
6116
+ for (const specFile of specFiles) {
6117
+ const filePath = path.join(testsDir, specFile);
6118
+ const content = fs.readFileSync(filePath, 'utf-8');
6119
+ if (content.includes("from 'dotenv'") ||
6120
+ content.includes('from "dotenv"') ||
6121
+ content.includes("import { config } from 'dotenv'") ||
6122
+ content.includes('import { config } from "dotenv"')) {
6123
+ hasSecrets = true;
6124
+ break;
6125
+ }
6126
+ }
6127
+ }
6128
+ }
6099
6129
  const sanitizedName = slugify(codeGenResult.testSuiteName);
6100
6130
  const packageJsonContent = generatePackageJson({
6101
6131
  name: sanitizedName,