@empiricalrun/test-gen 0.3.0 → 0.4.1
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/CHANGELOG.md +12 -0
- package/dist/bin/index.js +8 -1
- package/dist/bin/reporter/ci.d.ts +3 -0
- package/dist/bin/reporter/ci.d.ts.map +1 -0
- package/dist/bin/reporter/ci.js +22 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/bin/index.js
CHANGED
|
@@ -13,6 +13,7 @@ const eslint_1 = require("eslint");
|
|
|
13
13
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
14
14
|
const logger_1 = require("./logger");
|
|
15
15
|
const scenarios_1 = require("./scenarios");
|
|
16
|
+
const ci_1 = require("./reporter/ci");
|
|
16
17
|
dotenv_1.default.config({
|
|
17
18
|
path: [".env.local", ".env"],
|
|
18
19
|
});
|
|
@@ -132,6 +133,7 @@ async function generateTest(scenarios, file) {
|
|
|
132
133
|
const codePrompt = await generatePromptFromDirectory("./tests");
|
|
133
134
|
const pomPrompt = await generatePromptFromDirectory("./pages");
|
|
134
135
|
const testFileContent = fs_extra_1.default.readFileSync(file, "utf-8");
|
|
136
|
+
const generatedScenarios = [];
|
|
135
137
|
for (const i in scenarios) {
|
|
136
138
|
console.log("\n\n");
|
|
137
139
|
const scenario = scenarios[i];
|
|
@@ -229,7 +231,9 @@ async function generateTest(scenarios, file) {
|
|
|
229
231
|
errors = validateTypescript(file);
|
|
230
232
|
}
|
|
231
233
|
await formatCode(file);
|
|
234
|
+
generatedScenarios.push(scenario);
|
|
232
235
|
}
|
|
236
|
+
return generatedScenarios;
|
|
233
237
|
}
|
|
234
238
|
(async function main() {
|
|
235
239
|
if (process.argv.length != 3) {
|
|
@@ -238,12 +242,15 @@ async function generateTest(scenarios, file) {
|
|
|
238
242
|
}
|
|
239
243
|
const scenariosPath = process.argv[2];
|
|
240
244
|
const testGenConfigs = await (0, scenarios_1.generateScenarios)(scenariosPath);
|
|
245
|
+
const generatedTestScenarios = [];
|
|
241
246
|
for (const testGenConfig of testGenConfigs) {
|
|
242
247
|
const specPath = testGenConfig.specPath;
|
|
243
248
|
if (!fs_extra_1.default.existsSync(specPath)) {
|
|
244
249
|
logger.log(`Creating a new spec file: ${specPath}`);
|
|
245
250
|
fs_extra_1.default.createFileSync(specPath);
|
|
246
251
|
}
|
|
247
|
-
await generateTest(testGenConfig.scenarios, specPath);
|
|
252
|
+
const gen = await generateTest(testGenConfig.scenarios, specPath);
|
|
253
|
+
generatedTestScenarios.push(...gen);
|
|
248
254
|
}
|
|
255
|
+
await (0, ci_1.reportOnCI)(generatedTestScenarios);
|
|
249
256
|
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ci.d.ts","sourceRoot":"","sources":["../../../src/bin/reporter/ci.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,wBAAsB,UAAU,CAAE,SAAS,EAAE,QAAQ,EAAE,uBAatD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.reportOnCI = void 0;
|
|
7
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
async function reportOnCI(scenarios) {
|
|
9
|
+
if (process.env.CI && process.env.GITHUB_OUTPUT) {
|
|
10
|
+
const testNames = scenarios.map((s) => s.name).join(" ");
|
|
11
|
+
const scenariosOutput = scenarios.map((s) => {
|
|
12
|
+
return `**Scenario:** ${s.name} \n**Steps:**\n - ${s.steps.join("\n - ")} \n**Assert**:\n - ${s.assert}\n\n ----`;
|
|
13
|
+
}).join("\n ----- \n");
|
|
14
|
+
const envVars = [
|
|
15
|
+
`summary<<EOF\n${scenariosOutput}\nEOF`,
|
|
16
|
+
`test_names=${testNames}`,
|
|
17
|
+
].join('\n');
|
|
18
|
+
await fs_extra_1.default.appendFile(process.env.GITHUB_OUTPUT, envVars);
|
|
19
|
+
}
|
|
20
|
+
return scenarios;
|
|
21
|
+
}
|
|
22
|
+
exports.reportOnCI = reportOnCI;
|