@probolabs/playwright 1.4.0-rc.2 → 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.cjs CHANGED
@@ -6088,6 +6088,9 @@ export default class ProboReporter implements Reporter {
6088
6088
  const testSuiteDir = outputDir || getDefaultTestSuiteDir(testSuiteId, testSuiteName);
6089
6089
  // Generate code for all scenarios
6090
6090
  const codeGenResult = await ProboCodeGenerator.generateCodeForTestSuite(testSuiteId, apiToken, apiUrl);
6091
+ if (codeGenResult.scenarios.length === 0) {
6092
+ throw new Error(`No scenarios found in test suite ${testSuiteId}. Cannot generate test files.`);
6093
+ }
6091
6094
  // Ensure directories exist
6092
6095
  ensureDirectoryExists(testSuiteDir);
6093
6096
  const testsDir = path__namespace.join(testSuiteDir, 'tests');
@@ -6113,8 +6116,35 @@ export default class ProboReporter implements Reporter {
6113
6116
  */
6114
6117
  static async generatePackageJson(outputDir, codeGenResult) {
6115
6118
  // Check if any scenario has secrets by examining the generated code
6116
- // We'll check for dotenv imports in the generated code
6117
- const hasSecrets = codeGenResult.scenarios.some(scenario => scenario.code.includes("import { config } from 'dotenv'"));
6119
+ // We'll check for dotenv imports in the generated code (check for multiple patterns to be robust)
6120
+ let hasSecrets = codeGenResult.scenarios.some(scenario => {
6121
+ const code = scenario.code;
6122
+ return code.includes("from 'dotenv'") ||
6123
+ code.includes('from "dotenv"') ||
6124
+ code.includes("import { config } from 'dotenv'") ||
6125
+ code.includes('import { config } from "dotenv"') ||
6126
+ code.includes("require('dotenv')") ||
6127
+ code.includes('require("dotenv")');
6128
+ });
6129
+ // Fallback: if not detected in codeGenResult, check the actual written files
6130
+ // This handles edge cases where the code might have been modified or generated differently
6131
+ if (!hasSecrets) {
6132
+ const testsDir = path__namespace.join(outputDir, 'tests');
6133
+ if (fs__namespace.existsSync(testsDir)) {
6134
+ const specFiles = fs__namespace.readdirSync(testsDir).filter(f => f.endsWith('.spec.ts'));
6135
+ for (const specFile of specFiles) {
6136
+ const filePath = path__namespace.join(testsDir, specFile);
6137
+ const content = fs__namespace.readFileSync(filePath, 'utf-8');
6138
+ if (content.includes("from 'dotenv'") ||
6139
+ content.includes('from "dotenv"') ||
6140
+ content.includes("import { config } from 'dotenv'") ||
6141
+ content.includes('import { config } from "dotenv"')) {
6142
+ hasSecrets = true;
6143
+ break;
6144
+ }
6145
+ }
6146
+ }
6147
+ }
6118
6148
  const sanitizedName = slugify(codeGenResult.testSuiteName);
6119
6149
  const packageJsonContent = generatePackageJson({
6120
6150
  name: sanitizedName,