@empiricalrun/test-gen 0.28.3 → 0.29.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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.29.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ad735ca: feat: send branch_name var as ci output
8
+
9
+ ## 0.28.5
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [da0362c]
14
+ - @empiricalrun/reporter@0.18.3
15
+
16
+ ## 0.28.4
17
+
18
+ ### Patch Changes
19
+
20
+ - 2d27074: fix: add test for nested test update
21
+
3
22
  ## 0.28.3
4
23
 
5
24
  ### Patch Changes
@@ -77,7 +77,7 @@ async function generateTest(testCase, file, options) {
77
77
  logger.success("Test generated successfully!");
78
78
  const readWriteFileSpan = trace.span({ name: "write-to-file" });
79
79
  let contents = fs_extra_1.default.readFileSync(file, "utf-8");
80
- const [prependContent, strippedContent] = await (0, web_1.stripAndPrependImports)(response, testCase?.name, testCase?.suites);
80
+ const [prependContent, strippedContent] = await (0, web_1.stripAndPrependImports)(response, testCase?.name, []);
81
81
  let updatedContent = prependContent + contents + `\n\n${strippedContent}`;
82
82
  await fs_extra_1.default.writeFile(file, updatedContent, "utf-8");
83
83
  readWriteFileSpan.end({ output: { updatedContent } });
@@ -23,14 +23,14 @@ async function applyFileChanges({ validateTypes = true, trace, testCase, fileCha
23
23
  const { testBlock: testBlockUpdate } = (0, web_1.getTypescriptTestBlock)({
24
24
  scenarioName: testCase?.name || "",
25
25
  content: fileChange.newCode || "",
26
- suites: testCase?.suites,
26
+ suites: [], // suites should be empty here since we ask LLM to send immediate parent AST node for the code update. so there won't be any nesting here, just the test block
27
27
  });
28
28
  if (testBlockUpdate) {
29
29
  // assuming the test case getting updated
30
30
  // maintaining the previous accuracy of the test case update
31
31
  const readWriteFileSpan = trace.span({ name: "write-to-file" });
32
32
  let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
33
- const [prependContent, strippedContent] = await (0, web_1.stripAndPrependImports)(fileChange.newCode, testCase?.name, testCase?.suites);
33
+ const [prependContent, strippedContent] = await (0, web_1.stripAndPrependImports)(fileChange.newCode, testCase?.name, []);
34
34
  let updatedContent = prependContent + contents + `\n\n${strippedContent}`;
35
35
  const { testBlock } = (0, web_1.getTypescriptTestBlock)({
36
36
  scenarioName: testCase?.name,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bin/utils/scenarios/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,aAAa,EAAwB,MAAM,gBAAgB,CAAC;AAW5E,iBAAe,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAe3E;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bin/utils/scenarios/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,aAAa,EAAwB,MAAM,gBAAgB,CAAC;AAY5E,iBAAe,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAgB3E;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -8,6 +8,7 @@ async function loadTestConfigs(testGenToken) {
8
8
  return {
9
9
  specPath,
10
10
  testCase: {
11
+ id: config.id,
11
12
  name: config.name,
12
13
  steps: config.steps.filter((s) => !!s),
13
14
  group: config.group,
@@ -1 +1 @@
1
- {"version":3,"file":"ci.d.ts","sourceRoot":"","sources":["../../src/reporter/ci.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,wBAAsB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAOtE"}
1
+ {"version":3,"file":"ci.d.ts","sourceRoot":"","sources":["../../src/reporter/ci.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,wBAAsB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWtE"}
@@ -25,11 +25,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.reportOnCI = void 0;
27
27
  const core = __importStar(require("@actions/core"));
28
+ const slug_1 = require("../utils/slug");
28
29
  async function reportOnCI(testCase) {
29
30
  if (process.env.CI) {
31
+ const slug = await (0, slug_1.asyncGenerateRandomSlug)(10);
32
+ const branchName = `test-${testCase.id}-${slug}`;
30
33
  const scenariosOutput = `**Scenario:** ${testCase.name} \n\n**Steps:**\n - ${testCase.steps.join("\n - ")}`;
31
34
  core.setOutput("summary", scenariosOutput);
32
35
  core.setOutput("test_names", testCase.name);
36
+ core.setOutput("branch_name", branchName);
33
37
  }
34
38
  return testCase;
35
39
  }
@@ -29,6 +29,7 @@ export type TestGenConfig = {
29
29
  options?: TestGenConfigOptions;
30
30
  };
31
31
  export type TestCase = {
32
+ id: number;
32
33
  name: string;
33
34
  steps: string[];
34
35
  group: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC3E,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,QAAQ,CAAC;IACzB,KAAK,EAAE,QAAQ,CAAC;IAChB,aAAa,EAAE,WAAW,C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AAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE;IACR,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACrC,KACE,MAAM,CAAC;AAEZ,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC;AAEtE,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IAC5E,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAC;CAC/E,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const asyncGenerateRandomSlug: (size: number) => Promise<string>;
2
+ //# sourceMappingURL=slug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slug.d.ts","sourceRoot":"","sources":["../../src/utils/slug.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,uBAAuB,SAAgB,MAAM,oBAOzD,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asyncGenerateRandomSlug = void 0;
4
+ // @ts-expect-error
5
+ let customAlphabet;
6
+ const loadNanoid = async () => {
7
+ const { customAlphabet: importedCustomAlphabet } = await import("nanoid");
8
+ customAlphabet = importedCustomAlphabet;
9
+ };
10
+ const asyncGenerateRandomSlug = async (size) => {
11
+ if (!customAlphabet) {
12
+ await loadNanoid();
13
+ }
14
+ const chars = "abcdefghijklmnopqrstuvwxyz";
15
+ const nanoid = customAlphabet(chars, size);
16
+ return nanoid();
17
+ };
18
+ exports.asyncGenerateRandomSlug = asyncGenerateRandomSlug;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.28.3",
3
+ "version": "0.29.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -33,6 +33,7 @@
33
33
  "md5": "^2.3.0",
34
34
  "mime": "^4.0.4",
35
35
  "minimatch": "^10.0.1",
36
+ "nanoid": "^5.0.7",
36
37
  "openai": "^4.47.2",
37
38
  "picocolors": "^1.0.1",
38
39
  "playwright": "^1.44.1",
@@ -43,9 +44,9 @@
43
44
  "ts-morph": "^23.0.0",
44
45
  "tsx": "^4.16.2",
45
46
  "typescript": "^5.3.3",
47
+ "@empiricalrun/llm": "^0.9.2",
46
48
  "@empiricalrun/r2-uploader": "^0.3.0",
47
- "@empiricalrun/reporter": "^0.18.2",
48
- "@empiricalrun/llm": "^0.9.2"
49
+ "@empiricalrun/reporter": "^0.18.3"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@types/detect-port": "^1.3.5",
@@ -0,0 +1,10 @@
1
+ import { config as dotenvConfig } from "dotenv";
2
+ import { defineConfig } from "vitest/config";
3
+
4
+ dotenvConfig({ path: [".env.local", ".env"] });
5
+
6
+ export default defineConfig({
7
+ test: {
8
+ setupFiles: ["dotenv/config"],
9
+ },
10
+ });