@empiricalrun/test-gen 0.46.10 → 0.47.0
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/README.md +8 -28
- package/dist/agent/browsing/utils.d.ts.map +1 -1
- package/dist/agent/browsing/utils.js +10 -1
- package/dist/bin/index.js +7 -7
- package/dist/bin/utils/index.d.ts +1 -1
- package/dist/bin/utils/index.d.ts.map +1 -1
- package/dist/bin/utils/index.js +59 -7
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.47.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9481edf: fix: import createTest from dist location instead of local package installation
|
|
8
|
+
|
|
9
|
+
## 0.46.11
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 0def0a2: feat: add inquirer prompts for missing CLI options
|
|
14
|
+
|
|
3
15
|
## 0.46.10
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,38 +1,12 @@
|
|
|
1
1
|
# test-gen
|
|
2
2
|
|
|
3
|
-
Our agents that generate Playwright tests. There are 2 agents
|
|
4
|
-
|
|
5
|
-
- browsing agent
|
|
6
|
-
- code editing agent
|
|
7
|
-
|
|
8
3
|
## Usage
|
|
9
4
|
|
|
10
5
|
```sh
|
|
11
|
-
npx @empiricalrun/test-gen --token TEST_GEN_TOKEN
|
|
6
|
+
npx @empiricalrun/test-gen@latest --token TEST_GEN_TOKEN
|
|
12
7
|
```
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```sh
|
|
17
|
-
npx @empiricalrun/test-gen --token TEST_GEN_TOKEN
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
- This will trigger browsing agent to write a new test for this scenario
|
|
21
|
-
- See [Test gen token: Base64 payload](#test-gen-token-base64-payload)
|
|
22
|
-
|
|
23
|
-
### Update existing test
|
|
24
|
-
|
|
25
|
-
```sh
|
|
26
|
-
npx @empiricalrun/test-gen --token TEST_GEN_TOKEN
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
- If the test case is already present in the file, the test gen agent will update the existing test as per the steps provided in the payload
|
|
30
|
-
- This will trigger code editing agent to write a new test for this scenario
|
|
31
|
-
- See [Test gen token: Base64 payload](#test-gen-token-base64-payload)
|
|
32
|
-
|
|
33
|
-
### Test gen token: Base64 payload
|
|
34
|
-
|
|
35
|
-
Convert this object into a base64 payload - for new and update test.
|
|
9
|
+
To generate a token, use the below
|
|
36
10
|
|
|
37
11
|
```js
|
|
38
12
|
const scenario = {
|
|
@@ -46,3 +20,9 @@ const scenario = {
|
|
|
46
20
|
};
|
|
47
21
|
btoa(JSON.stringify(scenario));
|
|
48
22
|
```
|
|
23
|
+
|
|
24
|
+
### During development
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
npx /path/to/packages/test-gen/.
|
|
28
|
+
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI7E,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAsBvD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI7E,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAsBvD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AAwGD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,aAAa,EACxB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,CAAC,CA0DjB;AAyBD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBA2HxD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,QAIjD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CAM/B;AAWD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,oBAAoB,EACtC,gBAAgB,GAAE,MAAM,EAAU,GACjC,OAAO,CAAC,MAAM,CAAC,CA+CjB;AAED,qBAAa,eAAe;IACd,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,MAAM;IACrC,OAAO,CAAC,aAAa,CAAqB;YAE5B,mBAAmB;YAUnB,gBAAgB;IAsBjB,OAAO;IAuBb,SAAS;CAKjB"}
|
|
@@ -28,6 +28,15 @@ function prepareBrowsingAgentTask(steps) {
|
|
|
28
28
|
return task;
|
|
29
29
|
}
|
|
30
30
|
exports.prepareBrowsingAgentTask = prepareBrowsingAgentTask;
|
|
31
|
+
async function addImportForCreateTest(testFilePath) {
|
|
32
|
+
// Instead of using "@empiricalrun/test-gen", we use the local dist file
|
|
33
|
+
// This is to avoid assuming that the test-gen package is installed in the project
|
|
34
|
+
const importSource = path_1.default.join(__dirname, "../../../dist/index.js");
|
|
35
|
+
if (!fs_extra_1.default.existsSync(importSource)) {
|
|
36
|
+
throw new Error(`createTest import source not found at ${importSource}`);
|
|
37
|
+
}
|
|
38
|
+
await fs_extra_1.default.writeFile(testFilePath, (0, web_1.addNewImport)(await fs_extra_1.default.readFile(testFilePath, "utf-8"), ["createTest"], importSource));
|
|
39
|
+
}
|
|
31
40
|
/**
|
|
32
41
|
* Function to prepare test file for update scenarios for master agent to run
|
|
33
42
|
* @param {TestGenConfig} genConfig
|
|
@@ -76,7 +85,7 @@ async function prepareFileForUpdateScenario(genConfig, trace) {
|
|
|
76
85
|
createTestFilePath,
|
|
77
86
|
},
|
|
78
87
|
});
|
|
79
|
-
await
|
|
88
|
+
await addImportForCreateTest(createTestFilePath);
|
|
80
89
|
updateFileSpan?.end();
|
|
81
90
|
const { pomPrompt, nonSpecFilePrompt } = await (0, context_1.contextForGeneration)(createTestFilePath);
|
|
82
91
|
await (0, fix_ts_errors_1.validateAndFixTypescriptErrors)({
|
package/dist/bin/index.js
CHANGED
|
@@ -160,13 +160,13 @@ async function runAgent(testGenConfig, testGenToken) {
|
|
|
160
160
|
.option("--suites <suites>", "Comma separated list of describe blocks")
|
|
161
161
|
.parse(process.argv);
|
|
162
162
|
const options = program.opts();
|
|
163
|
-
(0, utils_2.
|
|
164
|
-
const testGenConfig =
|
|
165
|
-
? (0, scenarios_1.loadTestConfigs)(
|
|
166
|
-
: (0, scenarios_1.buildTestConfigFromOptions)(
|
|
167
|
-
const testGenToken =
|
|
168
|
-
?
|
|
169
|
-
: (0, scenarios_1.buildTokenFromOptions)(
|
|
163
|
+
const completedOptions = await (0, utils_2.validateAndCompleteCliOptions)(options);
|
|
164
|
+
const testGenConfig = completedOptions.token
|
|
165
|
+
? (0, scenarios_1.loadTestConfigs)(completedOptions.token)
|
|
166
|
+
: (0, scenarios_1.buildTestConfigFromOptions)(completedOptions);
|
|
167
|
+
const testGenToken = completedOptions.token
|
|
168
|
+
? completedOptions.token
|
|
169
|
+
: (0, scenarios_1.buildTokenFromOptions)(completedOptions);
|
|
170
170
|
(0, reporter_1.setReporterConfig)({
|
|
171
171
|
projectRepoName: testGenConfig.options?.metadata.projectRepoName,
|
|
172
172
|
testSessionId: testGenConfig.options?.metadata.testSessionId,
|
|
@@ -5,5 +5,5 @@ export interface CliOptions {
|
|
|
5
5
|
prompt?: string;
|
|
6
6
|
suites?: string;
|
|
7
7
|
}
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function validateAndCompleteCliOptions(options: CliOptions): Promise<CliOptions>;
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AASD,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,UAAU,CAAC,CAiErB"}
|
package/dist/bin/utils/index.js
CHANGED
|
@@ -1,12 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
6
|
+
exports.validateAndCompleteCliOptions = void 0;
|
|
7
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
+
async function validateAndCompleteCliOptions(options) {
|
|
5
9
|
const hasToken = !!options.token;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
console.error("Invalid arguments. Provide either --token OR all of --name, --file, and --prompt");
|
|
9
|
-
process.exit(1);
|
|
10
|
+
if (hasToken) {
|
|
11
|
+
return options;
|
|
10
12
|
}
|
|
13
|
+
const questions = [];
|
|
14
|
+
if (!options.name) {
|
|
15
|
+
questions.push({
|
|
16
|
+
type: "input",
|
|
17
|
+
name: "name",
|
|
18
|
+
message: "Enter the test name:",
|
|
19
|
+
validate: (input) => input.trim().length > 0 || "Test name is required",
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (!options.file) {
|
|
23
|
+
questions.push({
|
|
24
|
+
type: "input",
|
|
25
|
+
name: "file",
|
|
26
|
+
message: "Enter the test file path (inside tests dir):",
|
|
27
|
+
validate: (input) => input.trim().length > 0 || "Test file path is required",
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (!options.prompt) {
|
|
31
|
+
questions.push({
|
|
32
|
+
type: "editor",
|
|
33
|
+
name: "prompt",
|
|
34
|
+
message: "Enter the test prompt (opens in your editor):",
|
|
35
|
+
validate: (input) => input.trim().length > 0 || "Test prompt is required",
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (!options.suites) {
|
|
39
|
+
questions.push({
|
|
40
|
+
type: "input",
|
|
41
|
+
name: "suites",
|
|
42
|
+
message: "Enter comma-separated test suites (optional):",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (questions.length > 0) {
|
|
46
|
+
// Ask each question individually to avoid type issues
|
|
47
|
+
const answers = {};
|
|
48
|
+
for (const question of questions) {
|
|
49
|
+
const answer = await inquirer_1.default.prompt({
|
|
50
|
+
type: question.type,
|
|
51
|
+
name: "value",
|
|
52
|
+
message: question.message,
|
|
53
|
+
validate: question.validate,
|
|
54
|
+
});
|
|
55
|
+
answers[question.name] = answer.value;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
...options,
|
|
59
|
+
...answers,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return options;
|
|
11
63
|
}
|
|
12
|
-
exports.
|
|
64
|
+
exports.validateAndCompleteCliOptions = validateAndCompleteCliOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
"ts-morph": "^23.0.0",
|
|
74
74
|
"tsx": "^4.16.2",
|
|
75
75
|
"typescript": "^5.3.3",
|
|
76
|
-
"@empiricalrun/
|
|
76
|
+
"@empiricalrun/llm": "^0.9.35",
|
|
77
77
|
"@empiricalrun/reporter": "^0.23.1",
|
|
78
|
-
"@empiricalrun/
|
|
78
|
+
"@empiricalrun/r2-uploader": "^0.3.8"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@playwright/test": "1.47.1",
|