@empiricalrun/test-gen 0.16.2 → 0.16.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.16.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 8243b11: fix: add logs for errors while running playwright
8
+
3
9
  ## 0.16.2
4
10
 
5
11
  ### Patch Changes
@@ -1,7 +1,10 @@
1
1
  import { Page } from "playwright";
2
- export declare function browsingAgent(task: string, page: Page, options?: {
2
+ import { TestGenConfigOptions } from "../../types";
3
+ type BrowsingAgentOptions = Partial<TestGenConfigOptions> & {
3
4
  htmlSanitize?: {
4
5
  disallowedStrings?: string[];
5
6
  };
6
- }): Promise<string>;
7
+ };
8
+ export declare function browsingAgent(task: string, page: Page, options: BrowsingAgentOptions): Promise<string>;
9
+ export {};
7
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAQlC,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,GAAE;IACP,YAAY,CAAC,EAAE;QACb,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC9B,CAAC;CACE,mBAyFP"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAWlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAInD,KAAK,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,GAAG;IAC1D,YAAY,CAAC,EAAE;QACb,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,oBAAoB,mBA4F9B"}
@@ -4,10 +4,11 @@ exports.browsingAgent = void 0;
4
4
  const llm_1 = require("@empiricalrun/llm");
5
5
  const actions_1 = require("../../actions");
6
6
  const logger_1 = require("../../bin/logger");
7
+ const constants_1 = require("../../constants");
7
8
  const session_1 = require("../../session");
8
9
  const html_1 = require("../../utils/html");
9
10
  const utils_1 = require("./utils");
10
- async function browsingAgent(task, page, options = {}) {
11
+ async function browsingAgent(task, page, options) {
11
12
  const logger = new logger_1.CustomLogger();
12
13
  const trace = new llm_1.LLMTracing({
13
14
  name: "browsing-agent",
@@ -43,10 +44,12 @@ async function browsingAgent(task, page, options = {}) {
43
44
  messages,
44
45
  tools,
45
46
  trace,
46
- model: "gpt-4o",
47
- provider: "openai",
47
+ model: options.model || constants_1.DEFAULT_MODEL,
48
+ provider: options.modelProvider || constants_1.DEFAULT_MODEL_PROVIDER,
49
+ providerApiKey: constants_1.MODEL_API_KEYS[options.modelProvider || constants_1.DEFAULT_MODEL_PROVIDER],
48
50
  modelParameters: {
49
- temperature: 0.5,
51
+ ...constants_1.DEFAULT_MODEL_PARAMETERS,
52
+ ...options.modelParameters,
50
53
  tool_choice: "required",
51
54
  },
52
55
  });
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAaA,wBAAsB,+BAA+B,CAAC,YAAY,EAAE,MAAM,iBA0BzE"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAaA,wBAAsB,+BAA+B,CAAC,YAAY,EAAE,MAAM,iBA4BzE"}
@@ -26,15 +26,18 @@ async function generateTestsUsingBrowsingAgent(testFilePath) {
26
26
  if (!process.env.CI) {
27
27
  command = command.concat(` --headed`);
28
28
  }
29
- const exitCode = await (0, exec_1.cmd)(command.split(" "), {
30
- env: {
31
- APP_PORT: port.toString(),
32
- PW_TEST_HTML_REPORT_OPEN: "never",
33
- TEST_GEN_TOKEN: (0, utils_1.getTestConfigCliArg)(),
34
- },
35
- });
36
- if (exitCode != 0) {
37
- process.exit(exitCode);
29
+ try {
30
+ await (0, exec_1.cmd)(command.split(" "), {
31
+ env: {
32
+ APP_PORT: port.toString(),
33
+ PW_TEST_HTML_REPORT_OPEN: "never",
34
+ TEST_GEN_TOKEN: (0, utils_1.getTestConfigCliArg)(),
35
+ },
36
+ });
37
+ }
38
+ catch (e) {
39
+ logger.error(e);
40
+ process.exit(1);
38
41
  }
39
42
  await (0, web_1.removeTestOnly)(testFilePath);
40
43
  }
@@ -1,3 +1,3 @@
1
- import { Scenario } from "../../types";
2
- export declare function generateTest(scenarios: Scenario[], file: string, isUpdate: boolean): Promise<Scenario[]>;
1
+ import { Scenario, TestGenConfigOptions } from "../../types";
2
+ export declare function generateTest(scenarios: Scenario[], file: string, isUpdate: boolean, options: TestGenConfigOptions): Promise<Scenario[]>;
3
3
  //# sourceMappingURL=run.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,wBAAsB,YAAY,CAChC,SAAS,EAAE,QAAQ,EAAE,EACrB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC,QAAQ,EAAE,CAAC,CA6IrB"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE7D,wBAAsB,YAAY,CAChC,SAAS,EAAE,QAAQ,EAAE,EACrB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,QAAQ,EAAE,CAAC,CAqJrB"}
@@ -9,8 +9,9 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const logger_1 = require("../../bin/logger");
10
10
  const context_1 = require("../../bin/utils/context");
11
11
  const web_1 = require("../../bin/utils/platform/web");
12
+ const constants_1 = require("../../constants");
12
13
  const session_1 = require("../../session");
13
- async function generateTest(scenarios, file, isUpdate) {
14
+ async function generateTest(scenarios, file, isUpdate, options) {
14
15
  const logger = new logger_1.CustomLogger();
15
16
  if (!fs_extra_1.default.existsSync(file)) {
16
17
  logger.log(`Creating a new spec file: ${file}`);
@@ -55,10 +56,12 @@ async function generateTest(scenarios, file, isUpdate) {
55
56
  const firstShotMessage = await (0, llm_1.getLLMResult)({
56
57
  messages: instruction,
57
58
  trace,
58
- model: "gpt-4o",
59
- provider: "openai",
59
+ model: options.model || constants_1.DEFAULT_MODEL,
60
+ provider: options.modelProvider || constants_1.DEFAULT_MODEL_PROVIDER,
61
+ providerApiKey: constants_1.MODEL_API_KEYS[options.modelProvider || constants_1.DEFAULT_MODEL_PROVIDER],
60
62
  modelParameters: {
61
- temperature: 0.5,
63
+ ...constants_1.DEFAULT_MODEL_PARAMETERS,
64
+ ...options.modelParameters,
62
65
  },
63
66
  });
64
67
  let response = firstShotMessage?.content || "";
@@ -115,9 +118,13 @@ async function generateTest(scenarios, file, isUpdate) {
115
118
  const message = await (0, llm_1.getLLMResult)({
116
119
  messages: instruction,
117
120
  trace,
118
- model: "gpt-4o",
119
- provider: "openai",
120
- modelParameters: { temperature: 0.5 },
121
+ model: options.model || constants_1.DEFAULT_MODEL,
122
+ provider: options.modelProvider || constants_1.DEFAULT_MODEL_PROVIDER,
123
+ providerApiKey: constants_1.MODEL_API_KEYS[options.modelProvider || constants_1.DEFAULT_MODEL_PROVIDER],
124
+ modelParameters: {
125
+ ...constants_1.DEFAULT_MODEL_PARAMETERS,
126
+ ...options.modelParameters,
127
+ },
121
128
  });
122
129
  response = message?.content || "";
123
130
  const readWriteFileSpan = trace.startSpan("write-to-file");
package/dist/bin/index.js CHANGED
@@ -34,7 +34,7 @@ async function runAgent(sourceFile, isUpdate, testGenConfigs) {
34
34
  }
35
35
  else {
36
36
  logger.success("Generating test using coding agent");
37
- const gen = await (0, run_2.generateTest)(scenarios, specPath, isUpdate);
37
+ const gen = await (0, run_2.generateTest)(scenarios, specPath, isUpdate, testGenConfig.options);
38
38
  generatedTestScenarios.push(...gen);
39
39
  }
40
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/bin/utils/platform/web/index.ts"],"names":[],"mappings":"AAKA,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAQpB;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAG5E;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAwC7D;AAED,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,qBAM3D;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,iBAOhD;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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/bin/utils/platform/web/index.ts"],"names":[],"mappings":"AAKA,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAQpB;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAG5E;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAiD7D;AAED,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,qBAM3D;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,iBAOhD;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"}
@@ -56,7 +56,17 @@ function validateTypescript(filePath) {
56
56
  const semanticDiagnostics = program.getSemanticDiagnostics(sourceFile);
57
57
  if (semanticDiagnostics.length > 0) {
58
58
  semanticDiagnostics.forEach((diagnostic) => {
59
- errors.push(diagnostic.messageText.toString());
59
+ if (typeof diagnostic.messageText === "string") {
60
+ errors.push(diagnostic.messageText);
61
+ }
62
+ else {
63
+ let messageChain = diagnostic.messageText;
64
+ errors.push(messageChain.messageText);
65
+ while (messageChain?.next) {
66
+ messageChain = messageChain.next[0];
67
+ errors.push(messageChain?.messageText);
68
+ }
69
+ }
60
70
  });
61
71
  }
62
72
  return errors;
@@ -0,0 +1,6 @@
1
+ import { LLMModel, LLMProvider, ModelParameters } from "@empiricalrun/llm";
2
+ export declare const MODEL_API_KEYS: Record<LLMProvider, string>;
3
+ export declare const DEFAULT_MODEL_PROVIDER: LLMProvider;
4
+ export declare const DEFAULT_MODEL: LLMModel;
5
+ export declare const DEFAULT_MODEL_PARAMETERS: ModelParameters;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,QAAmB,CAAC;AAEhD,eAAO,MAAM,wBAAwB,EAAE,eAEtC,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_MODEL_PARAMETERS = exports.DEFAULT_MODEL = exports.DEFAULT_MODEL_PROVIDER = exports.MODEL_API_KEYS = void 0;
4
+ exports.MODEL_API_KEYS = {
5
+ google: process.env.GOOGLE_API_KEY || "",
6
+ anthropic: process.env.ANTHROPIC_API_KEY || "",
7
+ openai: process.env.OPENAI_API_KEY || "",
8
+ };
9
+ exports.DEFAULT_MODEL_PROVIDER = "openai";
10
+ exports.DEFAULT_MODEL = "gpt-4o";
11
+ exports.DEFAULT_MODEL_PARAMETERS = {
12
+ temperature: 0.5,
13
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAWlC,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,iBAiBnE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAWlC,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,iBAkBnE"}
package/dist/index.js CHANGED
@@ -17,13 +17,14 @@ async function createTest(task, page, test) {
17
17
  const testConfigArg = process.env.TEST_GEN_TOKEN;
18
18
  const { testGenConfigs } = await (0, utils_1.parseCliArgs)(testConfigArg);
19
19
  const [testGenConfig] = testGenConfigs;
20
- (0, reporter_1.setReporterConfig)(testGenConfig?.options?.metadata);
20
+ (0, reporter_1.setReporterConfig)(testGenConfig.options?.metadata);
21
21
  const fileService = new client_1.default(Number(port));
22
22
  test.setTimeout(900000);
23
23
  const code = await (0, browsing_1.browsingAgent)(task, page, {
24
24
  htmlSanitize: {
25
25
  disallowedStrings: ["v-data-table__td v-data-table-column--align-start"],
26
26
  },
27
+ ...testGenConfig.options,
27
28
  });
28
29
  await fileService.updateTest({
29
30
  task,
@@ -1,3 +1,4 @@
1
+ import { LLMModel, LLMProvider, ModelParameters } from "@empiricalrun/llm";
1
2
  import OpenAI from "openai";
2
3
  import { Page } from "playwright";
3
4
  export type FileContent = {
@@ -6,9 +7,10 @@ export type FileContent = {
6
7
  };
7
8
  export type TestGenConfigOptions = {
8
9
  agent: "code" | "browser";
9
- model: string;
10
+ model: LLMModel;
11
+ modelProvider: LLMProvider;
12
+ modelParameters?: ModelParameters;
10
13
  metadata: {
11
- apiToken: string;
12
14
  testSessionId: number;
13
15
  testCaseName: string;
14
16
  projectRepoName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;QACrB,eAAe,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AAGA,wBAAgB,GAAG,CACjB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACxC,OAAO,CAAC,MAAM,CAAC,CAejB"}
1
+ {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":"AAGA,wBAAgB,GAAG,CACjB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACxC,OAAO,CAAC,MAAM,CAAC,CAyBjB"}
@@ -7,18 +7,29 @@ exports.cmd = void 0;
7
7
  const child_process_1 = require("child_process");
8
8
  const process_1 = __importDefault(require("process"));
9
9
  function cmd(command, options) {
10
- return new Promise((resolveFunc) => {
10
+ let lastLog = "";
11
+ return new Promise((resolveFunc, rejectFunc) => {
11
12
  let p = (0, child_process_1.spawn)(command[0], command.slice(1), {
12
13
  env: { ...process_1.default.env, ...options.env },
13
14
  });
14
15
  p.stdout.on("data", (x) => {
15
- process_1.default.stdout.write(x.toString());
16
+ const log = x.toString();
17
+ process_1.default.stdout.write(log);
18
+ lastLog = log;
16
19
  });
17
20
  p.stderr.on("data", (x) => {
21
+ const log = x.toString();
18
22
  process_1.default.stderr.write(x.toString());
23
+ lastLog = log;
19
24
  });
20
25
  p.on("exit", (code) => {
21
- resolveFunc(code);
26
+ if (code != 0) {
27
+ // assuming last log is the error message before exiting
28
+ rejectFunc(lastLog);
29
+ }
30
+ else {
31
+ resolveFunc(code);
32
+ }
22
33
  });
23
34
  });
24
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"