@empiricalrun/test-gen 0.21.11 → 0.22.2
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 +26 -0
- package/dist/agent/browsing/utils.d.ts.map +1 -1
- package/dist/agent/browsing/utils.js +2 -1
- package/dist/bin/utils/platform/web/index.d.ts +1 -0
- package/dist/bin/utils/platform/web/index.d.ts.map +1 -1
- package/dist/bin/utils/platform/web/index.js +22 -5
- package/dist/bin/utils/platform/web/test-files/ts-path-import-validate.d.ts +2 -0
- package/dist/bin/utils/platform/web/test-files/ts-path-import-validate.d.ts.map +1 -0
- package/dist/bin/utils/platform/web/test-files/ts-path-import-validate.js +7 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +1 -1
- package/dist/file/server.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.22.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d35239e: fix: update imports for test and expect to fixtures
|
|
8
|
+
- Updated dependencies [2de783d]
|
|
9
|
+
- @empiricalrun/llm@0.7.0
|
|
10
|
+
|
|
11
|
+
## 0.22.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- b96491f: fix: typescript errors for valid CommonJS module imports
|
|
16
|
+
|
|
17
|
+
## 0.22.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- 4676ab7: feat: use gpt-4o-2024-08-06 as default
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [1770926]
|
|
26
|
+
- Updated dependencies [4676ab7]
|
|
27
|
+
- @empiricalrun/llm@0.6.0
|
|
28
|
+
|
|
3
29
|
## 0.21.11
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAUvD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AAED,wBAAsB,2BAA2B,CAAC,SAAS,EAAE,aAAa,iBAuCzE;AAiBD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBASxD;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,QA4BnD;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAM1E;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,oBAAoB,GACrC,OAAO,CAAC,MAAM,CAAC,CAkDjB;AAED,wBAAsB,sBAAsB,CAAC,EAC3C,YAAiB,EACjB,IAAS,EACT,eAAoB,EACpB,gBAAqB,EACrB,UAAyC,GAC1C,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,8EASA"}
|
|
@@ -28,7 +28,8 @@ async function prepareFileForBrowsingAgent(genConfig) {
|
|
|
28
28
|
const logger = new logger_1.CustomLogger();
|
|
29
29
|
if (!fs_extra_1.default.existsSync(specPath)) {
|
|
30
30
|
await fs_extra_1.default.createFile(specPath);
|
|
31
|
-
|
|
31
|
+
const fileContentWithImports = (0, web_1.addNewImport)("", ["test", "expect"], (0, web_1.getFixtureImportPath)(specPath));
|
|
32
|
+
await fs_extra_1.default.writeFile(specPath, fileContentWithImports, "utf-8");
|
|
32
33
|
}
|
|
33
34
|
if (name && steps && steps.length) {
|
|
34
35
|
const existingContents = await fs_extra_1.default.readFile(specPath, "utf-8");
|
|
@@ -6,4 +6,5 @@ export declare function lintErrors(filePath: string): Promise<void>;
|
|
|
6
6
|
export declare function formatCode(filePath: string): Promise<void>;
|
|
7
7
|
export declare function addNewImport(contents: string, modules: string[], pkg: string): string;
|
|
8
8
|
export declare function removeTestOnly(filePath: string): Promise<void>;
|
|
9
|
+
export declare function getFixtureImportPath(filePath: string): string;
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/bin/utils/platform/web/index.ts"],"names":[],"mappings":"AAMA,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAYpB;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAG5E;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/bin/utils/platform/web/index.ts"],"names":[],"mappings":"AAMA,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAYpB;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAG5E;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAwD7D;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,mCAOjB;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,iBAShD;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,iBAQhD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,UAE5E;AAED,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,iBAIpD;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,UAcpD"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.removeTestOnly = exports.addNewImport = exports.formatCode = exports.lintErrors = exports.stripAndPrependImports = exports.validateTypescript = exports.appendToTestBlock = exports.getTypescriptTestBlock = void 0;
|
|
6
|
+
exports.getFixtureImportPath = exports.removeTestOnly = exports.addNewImport = exports.formatCode = exports.lintErrors = exports.stripAndPrependImports = exports.validateTypescript = exports.appendToTestBlock = exports.getTypescriptTestBlock = void 0;
|
|
7
7
|
const eslint_1 = require("eslint");
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const prettier_1 = __importDefault(require("prettier"));
|
|
@@ -25,12 +25,13 @@ function appendToTestBlock(testBlock, content) {
|
|
|
25
25
|
exports.appendToTestBlock = appendToTestBlock;
|
|
26
26
|
function validateTypescript(filePath) {
|
|
27
27
|
// Create a compiler host to read files
|
|
28
|
-
const compilerHost = typescript_1.default.createCompilerHost({
|
|
29
|
-
esModuleInterop: true,
|
|
30
|
-
});
|
|
28
|
+
const compilerHost = typescript_1.default.createCompilerHost({});
|
|
31
29
|
compilerHost.readFile = (file) => fs_extra_1.default.readFileSync(file, "utf8");
|
|
32
30
|
// Create a program with a single source file
|
|
33
|
-
const program = typescript_1.default.createProgram([filePath], {
|
|
31
|
+
const program = typescript_1.default.createProgram([filePath], {
|
|
32
|
+
esModuleInterop: true,
|
|
33
|
+
allowSyntheticDefaultImports: true,
|
|
34
|
+
}, compilerHost);
|
|
34
35
|
// Get the source file
|
|
35
36
|
const sourceFile = program.getSourceFile(filePath);
|
|
36
37
|
// Get and report any syntactic errors
|
|
@@ -112,3 +113,19 @@ async function removeTestOnly(filePath) {
|
|
|
112
113
|
return fs_extra_1.default.writeFile(filePath, updatedContent);
|
|
113
114
|
}
|
|
114
115
|
exports.removeTestOnly = removeTestOnly;
|
|
116
|
+
function getFixtureImportPath(filePath) {
|
|
117
|
+
// get the depth from the tests folder
|
|
118
|
+
// assumption fixtures are always int the folder tests/fixtures
|
|
119
|
+
const subFolder = filePath.split("/tests/")[1];
|
|
120
|
+
const subFolderDepth = subFolder?.split("/").length
|
|
121
|
+
? subFolder?.split("/").length - 1
|
|
122
|
+
: 0;
|
|
123
|
+
// create an array of path segments to the fixtures file
|
|
124
|
+
const fixturesPath = [
|
|
125
|
+
"./",
|
|
126
|
+
subFolderDepth ? new Array(subFolderDepth).fill("../").join("") : "",
|
|
127
|
+
"fixtures",
|
|
128
|
+
].join("");
|
|
129
|
+
return fixturesPath;
|
|
130
|
+
}
|
|
131
|
+
exports.getFixtureImportPath = getFixtureImportPath;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-path-import-validate.d.ts","sourceRoot":"","sources":["../../../../../../src/bin/utils/platform/web/test-files/ts-path-import-validate.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
console.log(path_1.default);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE3E,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAItD,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,WAAsB,CAAC;AAE5D,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE3E,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAItD,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,WAAsB,CAAC;AAE5D,eAAO,MAAM,aAAa,EAAE,QAA8B,CAAC;AAE3D,eAAO,MAAM,wBAAwB,EAAE,eAEtC,CAAC"}
|
package/dist/constants/index.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.MODEL_API_KEYS = {
|
|
|
7
7
|
openai: process.env.OPENAI_API_KEY || "",
|
|
8
8
|
};
|
|
9
9
|
exports.DEFAULT_MODEL_PROVIDER = "openai";
|
|
10
|
-
exports.DEFAULT_MODEL = "gpt-4o";
|
|
10
|
+
exports.DEFAULT_MODEL = "gpt-4o-2024-08-06";
|
|
11
11
|
exports.DEFAULT_MODEL_PARAMETERS = {
|
|
12
12
|
temperature: 0.5,
|
|
13
13
|
};
|
package/dist/file/server.js
CHANGED
|
@@ -27,7 +27,7 @@ class FileService {
|
|
|
27
27
|
if (testFilePath) {
|
|
28
28
|
const testFile = fs_1.default.readFileSync(testFilePath, "utf-8");
|
|
29
29
|
const updatedTestFile = testFile.replace(/await createTest\([\s\S]*?\);\n/, "\n" + generatedCode);
|
|
30
|
-
const importStatement = `import { test, expect } from "
|
|
30
|
+
const importStatement = `import { test, expect } from "${(0, web_1.getFixtureImportPath)(testFilePath)}";`;
|
|
31
31
|
fs_1.default.writeFileSync(testFilePath, importStatement + "\n" + updatedTestFile, "utf-8");
|
|
32
32
|
await (0, web_1.lintErrors)(testFilePath);
|
|
33
33
|
return res.send({ success: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"ts-morph": "^23.0.0",
|
|
42
42
|
"tsx": "^4.16.2",
|
|
43
43
|
"typescript": "^5.3.3",
|
|
44
|
-
"@empiricalrun/llm": "^0.
|
|
44
|
+
"@empiricalrun/llm": "^0.7.0",
|
|
45
45
|
"@empiricalrun/reporter": "^0.16.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|