@empiricalrun/test-run 0.9.3 → 0.9.4

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-run
2
2
 
3
+ ## 0.9.4
4
+
5
+ ### Patch Changes
6
+
7
+ - f926e40: feat: consume repoPath in test run tool
8
+
3
9
  ## 0.9.3
4
10
 
5
11
  ### Patch Changes
package/dist/bin/index.js CHANGED
@@ -16,6 +16,7 @@ const config_parser_1 = require("../utils/config-parser");
16
16
  dotenv_1.default.config({
17
17
  path: [".env.local", ".env"],
18
18
  });
19
+ const repoDir = process.cwd();
19
20
  (async function main() {
20
21
  commander_1.program
21
22
  .option("-n, --name <test-name>", "Name of the test to run")
@@ -95,10 +96,10 @@ dotenv_1.default.config({
95
96
  const projectFilters = await (0, utils_1.generateProjectFilters)({
96
97
  platform,
97
98
  filteringSets: [...options.project, ...environmentSpecificProjects],
98
- repoDir: process.cwd(),
99
+ repoDir,
99
100
  });
100
101
  if (options.skipTeardown) {
101
- await (0, utils_1.handleTeardownSkipFlag)(directory);
102
+ await (0, utils_1.handleTeardownSkipFlag)(directory, repoDir);
102
103
  }
103
104
  const hasTestsFilter = tests && tests.length > 0;
104
105
  let commandToRun;
@@ -108,7 +109,7 @@ dotenv_1.default.config({
108
109
  projects: projectFilters,
109
110
  passthroughArgs: pwOptions.join(" "),
110
111
  platform,
111
- repoDir: process.cwd(),
112
+ repoDir,
112
113
  });
113
114
  }
114
115
  else {
@@ -118,7 +119,7 @@ dotenv_1.default.config({
118
119
  platform,
119
120
  });
120
121
  }
121
- const { hasTestPassed } = await (0, cmd_1.runTestsForCmd)(commandToRun);
122
+ const { hasTestPassed } = await (0, cmd_1.runTestsForCmd)(commandToRun, repoDir);
122
123
  if (!hasTestPassed) {
123
124
  process.exit(1);
124
125
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","s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jB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;;;GAiBA;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IACvE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;CACjD,CAAC,CAaD"}
package/dist/index.js CHANGED
@@ -20,15 +20,14 @@ const utils_1 = require("./utils");
20
20
  const supportedPlatform = types_1.Platform.WEB;
21
21
  async function runSingleTest({ testName, suites, fileName, projects, envOverrides, repoDir, }) {
22
22
  const testDir = "tests";
23
- const filePath = path_1.default.relative(repoDir, fileName);
24
23
  const commandToRun = await (0, run_specific_test_1.runSpecificTestsCmd)({
25
- tests: [{ name: testName, dir: testDir, filePath, suites }],
24
+ tests: [{ name: testName, dir: testDir, filePath: fileName, suites }],
26
25
  projects,
27
26
  envOverrides,
28
27
  platform: supportedPlatform,
29
28
  repoDir,
30
29
  });
31
- const { hasTestPassed } = await (0, cmd_1.runTestsForCmd)(commandToRun);
30
+ const { hasTestPassed } = await (0, cmd_1.runTestsForCmd)(commandToRun, repoDir);
32
31
  const jsonFilePath = path_1.default.join(repoDir, "playwright-report", `summary.json`);
33
32
  const jsonFileContents = await promises_1.default.readFile(jsonFilePath, "utf8");
34
33
  const summaryJson = JSON.parse(jsonFileContents);
package/dist/lib/cmd.d.ts CHANGED
@@ -3,7 +3,7 @@ export declare function getCommandFromString(command: string): {
3
3
  command: string;
4
4
  args: string[];
5
5
  };
6
- export declare function runTestsForCmd({ command, args, env }: CommandToRun): Promise<{
6
+ export declare function runTestsForCmd({ command, args, env }: CommandToRun, cwd: string): Promise<{
7
7
  hasTestPassed: boolean;
8
8
  }>;
9
9
  export declare function spawnCmd(command: string, args: string[], options: {
@@ -1 +1 @@
1
- {"version":3,"file":"cmd.d.ts","sourceRoot":"","sources":["../../src/lib/cmd.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAeA;AAED,wBAAsB,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,YAAY;;GAcxE;AAED,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;CACvB,GACA,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA6C5C"}
1
+ {"version":3,"file":"cmd.d.ts","sourceRoot":"","sources":["../../src/lib/cmd.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAeA;AAED,wBAAsB,cAAc,CAClC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,YAAY,EACpC,GAAG,EAAE,MAAM;;GAeZ;AAED,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;CACvB,GACA,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA6C5C"}
package/dist/lib/cmd.js CHANGED
@@ -18,12 +18,12 @@ function getCommandFromString(command) {
18
18
  }),
19
19
  };
20
20
  }
21
- async function runTestsForCmd({ command, args, env }) {
21
+ async function runTestsForCmd({ command, args, env }, cwd) {
22
22
  console.log(`Running cmd: ${command} with args: ${args}`);
23
23
  let hasTestPassed = true;
24
24
  try {
25
25
  await spawnCmd(command, args, {
26
- cwd: process.cwd(),
26
+ cwd,
27
27
  envOverrides: env,
28
28
  captureOutput: false,
29
29
  throwOnError: true,
@@ -1 +1 @@
1
- {"version":3,"file":"run-specific-test.d.ts","sourceRoot":"","sources":["../../src/lib/run-specific-test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAY5D,wBAAsB,mBAAmB,CAAC,EACxC,KAAU,EACV,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,OAAO,GACR,EAAE;IACD,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,YAAY,CAAC,CAuFxB"}
1
+ {"version":3,"file":"run-specific-test.d.ts","sourceRoot":"","sources":["../../src/lib/run-specific-test.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAY5D,wBAAsB,mBAAmB,CAAC,EACxC,KAAU,EACV,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,OAAO,GACR,EAAE;IACD,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,YAAY,CAAC,CA0FxB"}
@@ -1,6 +1,10 @@
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
6
  exports.runSpecificTestsCmd = runSpecificTestsCmd;
7
+ const path_1 = __importDefault(require("path"));
4
8
  const utils_1 = require("../utils");
5
9
  const run_all_tests_1 = require("./run-all-tests");
6
10
  async function runSpecificTestsCmd({ tests = [], projects, passthroughArgs, platform, envOverrides, repoDir, }) {
@@ -12,7 +16,7 @@ async function runSpecificTestsCmd({ tests = [], projects, passthroughArgs, plat
12
16
  for (const testCase of tests) {
13
17
  // TODO: Why do we have this getAllFilePaths call?
14
18
  // TODO: Can we remove `dir` from the test case entity?
15
- const files = await (0, utils_1.getAllFilePaths)(testCase.dir, {
19
+ const files = await (0, utils_1.getAllFilePaths)(testCase.dir, repoDir, {
16
20
  filePath: testCase.filePath,
17
21
  });
18
22
  let matchingFilePath = "";
@@ -21,6 +25,7 @@ async function runSpecificTestsCmd({ tests = [], projects, passthroughArgs, plat
21
25
  filePath: file,
22
26
  scenarioName: testCase.name,
23
27
  suites: testCase.suites,
28
+ repoDir,
24
29
  });
25
30
  if (match) {
26
31
  matchingFilePath = file;
@@ -42,8 +47,9 @@ async function runSpecificTestsCmd({ tests = [], projects, passthroughArgs, plat
42
47
  filePath: matchingFilePath,
43
48
  scenarioName: testCase.name,
44
49
  suites: testCase.suites,
50
+ repoDir,
45
51
  });
46
- const isFileMarkedSerial = await (0, utils_1.hasTopLevelDescribeConfigureWithSerialMode)(matchingFilePath);
52
+ const isFileMarkedSerial = await (0, utils_1.hasTopLevelDescribeConfigureWithSerialMode)(path_1.default.join(repoDir, matchingFilePath));
47
53
  if (!isFileMarkedSerial && testCaseNode) {
48
54
  const parentDescribe = (0, utils_1.findFirstSerialDescribeBlock)(testCaseNode);
49
55
  if (!parentDescribe) {
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;IACzC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC;AAEF,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA8B9B"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;IACzC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC;AAEF,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA+B9B"}
@@ -12,7 +12,7 @@ async function getProjectsFromPlaywrightConfig(platform, repoDir) {
12
12
  const configName = platform === types_1.Platform.WEB ? "playwright.config.ts" : "appwright.config.ts";
13
13
  try {
14
14
  const configPath = path_1.default.join(repoDir, configName);
15
- const tmpScriptPath = path_1.default.resolve(__dirname, "temp-extract-projects.js");
15
+ const tmpScriptPath = path_1.default.join(repoDir, "temp-extract-projects.js");
16
16
  fs_1.default.writeFileSync(tmpScriptPath, `
17
17
  // Import the config directly with the full path
18
18
  const configModule = require('${configPath.replace(/\\/g, "\\\\")}');
@@ -26,6 +26,7 @@ async function getProjectsFromPlaywrightConfig(platform, repoDir) {
26
26
  TS_NODE_PROJECT: path_1.default.join(repoDir, "tsconfig.json"),
27
27
  NODE_PATH: path_1.default.join(repoDir, "node_modules"),
28
28
  },
29
+ cwd: repoDir,
29
30
  });
30
31
  fs_1.default.unlinkSync(tmpScriptPath);
31
32
  const projects = JSON.parse(result);
@@ -1,21 +1,23 @@
1
1
  import { Node, SourceFile } from "ts-morph";
2
2
  import { Platform, TestFramework } from "../types";
3
- export declare function getAllFilePaths(directoryPath?: string, filters?: {
3
+ export declare function getAllFilePaths(directoryPath: string | undefined, repoDir: string, filters?: {
4
4
  filePath?: string;
5
5
  }): Promise<string[]>;
6
6
  export declare const getTestModuleAliasFromSourceFile: (sourceFile: SourceFile) => string;
7
- export declare function getTestCaseNode({ filePath, scenarioName, suites, }: {
7
+ export declare function getTestCaseNode({ filePath, scenarioName, suites, repoDir, }: {
8
8
  filePath: string;
9
9
  scenarioName: string;
10
10
  suites?: string[];
11
+ repoDir: string;
11
12
  }): Promise<{
12
13
  testCaseNode: Node | undefined;
13
14
  sourceFile: SourceFile;
14
15
  }>;
15
- export declare function hasTestBlock({ filePath, scenarioName, suites, }: {
16
+ export declare function hasTestBlock({ filePath, scenarioName, suites, repoDir, }: {
16
17
  filePath: string;
17
18
  scenarioName: string;
18
19
  suites?: string[];
20
+ repoDir: string;
19
21
  }): Promise<boolean>;
20
22
  export declare function getDescribeBlockName(node: Node): string | undefined;
21
23
  export declare function findFirstSerialDescribeBlock(node: Node | undefined): Node | undefined;
@@ -40,7 +42,7 @@ export declare function buildRepoName(projectName: string): string;
40
42
  export declare const pickNameFromPackageJson: () => Promise<string | undefined>;
41
43
  export declare const downloadBuild: (buildUrl: string) => Promise<void>;
42
44
  export declare const getTestRunner: (platform: Platform) => TestFramework;
43
- export declare const handleTeardownSkipFlag: (directory: string) => Promise<void>;
45
+ export declare const handleTeardownSkipFlag: (directory: string, repoDir: string) => Promise<void>;
44
46
  /**
45
47
  * function to get the test block and test node for the scenario
46
48
  * @export
@@ -48,10 +50,11 @@ export declare const handleTeardownSkipFlag: (directory: string) => Promise<void
48
50
  * @param {string} content
49
51
  * @return { testBlock: string; parentDescribe: string; } testBlock - the test block content, testNode - the test function node
50
52
  */
51
- export declare function getTypescriptTestBlock({ scenarioName, suites, content, }: {
53
+ export declare function getTypescriptTestBlock({ scenarioName, suites, content, repoDir, }: {
52
54
  scenarioName: string;
53
55
  suites?: string[];
54
56
  content: string;
57
+ repoDir: string;
55
58
  }): {
56
59
  testBlock: string | undefined;
57
60
  testNode: Node | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAW,UAAU,EAAc,MAAM,UAAU,CAAC;AAIjE,OAAO,EAAsB,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGvE,wBAAsB,eAAe,CACnC,aAAa,GAAE,MAAgB,EA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AE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG;IACF,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,UAAU,CAAC;CACxB,CAiDA"}
@@ -23,17 +23,17 @@ const util_1 = require("util");
23
23
  const cmd_1 = require("../lib/cmd");
24
24
  const types_1 = require("../types");
25
25
  const config_1 = require("./config");
26
- async function getAllFilePaths(directoryPath = "tests", filters = {}) {
26
+ async function getAllFilePaths(directoryPath = "tests", repoDir, filters = {}) {
27
27
  let filePaths = [];
28
28
  try {
29
- const files = await promises_1.default.readdir(directoryPath);
29
+ const files = await promises_1.default.readdir(path_1.default.join(repoDir, directoryPath));
30
30
  let allFilePaths = [];
31
31
  for (const file of files) {
32
32
  const filePath = path_1.default.join(directoryPath, file);
33
- const stat = await promises_1.default.lstat(filePath);
33
+ const stat = await promises_1.default.lstat(path_1.default.join(repoDir, filePath));
34
34
  if (stat.isDirectory()) {
35
35
  // If it's a directory, recursively get file paths from the directory
36
- const nestedFiles = await getAllFilePaths(filePath, filters);
36
+ const nestedFiles = await getAllFilePaths(filePath, repoDir, filters);
37
37
  allFilePaths = allFilePaths.concat(nestedFiles);
38
38
  }
39
39
  else {
@@ -67,20 +67,22 @@ const getTestModuleAliasFromSourceFile = (sourceFile) => {
67
67
  ?.getText() || "test");
68
68
  };
69
69
  exports.getTestModuleAliasFromSourceFile = getTestModuleAliasFromSourceFile;
70
- async function getTestCaseNode({ filePath, scenarioName, suites, }) {
71
- const content = await promises_1.default.readFile(filePath, "utf-8");
70
+ async function getTestCaseNode({ filePath, scenarioName, suites, repoDir, }) {
71
+ const content = await promises_1.default.readFile(path_1.default.join(repoDir, filePath), "utf-8");
72
72
  const { testNode, sourceFile } = getTypescriptTestBlock({
73
73
  scenarioName,
74
74
  content,
75
75
  suites, // since this method is called on the generated content, not the whole file
76
+ repoDir,
76
77
  });
77
78
  return { testCaseNode: testNode, sourceFile };
78
79
  }
79
- async function hasTestBlock({ filePath, scenarioName, suites, }) {
80
+ async function hasTestBlock({ filePath, scenarioName, suites, repoDir, }) {
80
81
  const { testCaseNode } = await getTestCaseNode({
81
82
  filePath,
82
83
  scenarioName,
83
84
  suites,
85
+ repoDir,
84
86
  });
85
87
  return !!testCaseNode;
86
88
  }
@@ -240,9 +242,9 @@ const getTestRunner = (platform) => {
240
242
  : types_1.TestFramework.APPWRIGHT;
241
243
  };
242
244
  exports.getTestRunner = getTestRunner;
243
- const getAllTeardownFiles = async (directory) => {
245
+ const getAllTeardownFiles = async (directory, repoDir) => {
244
246
  const teardownFileRegex = /.*\.teardown\.ts/;
245
- const files = await getAllFilePaths(directory);
247
+ const files = await getAllFilePaths(directory, repoDir);
246
248
  return files.filter((file) => teardownFileRegex.test(file));
247
249
  };
248
250
  const skipTeardownFile = async (filePath) => {
@@ -266,13 +268,15 @@ const skipTeardownFile = async (filePath) => {
266
268
  };
267
269
  class TeardownManager {
268
270
  directory;
269
- constructor(directory) {
271
+ repoDir;
272
+ constructor(directory, repoDir) {
270
273
  this.directory = directory;
274
+ this.repoDir = repoDir;
271
275
  }
272
276
  teardownFiles = [];
273
277
  teardownFileContents = [];
274
278
  async skip() {
275
- this.teardownFiles = await getAllTeardownFiles(this.directory);
279
+ this.teardownFiles = await getAllTeardownFiles(this.directory, this.repoDir);
276
280
  this.teardownFileContents = await Promise.all(this.teardownFiles.map(async (filePath) => {
277
281
  const content = await promises_1.default.readFile(filePath, "utf-8");
278
282
  return { filePath, content };
@@ -285,9 +289,9 @@ class TeardownManager {
285
289
  });
286
290
  }
287
291
  }
288
- const handleTeardownSkipFlag = async (directory) => {
292
+ const handleTeardownSkipFlag = async (directory, repoDir) => {
289
293
  console.log("Skipping teardown tests ...");
290
- const teardowns = new TeardownManager(directory);
294
+ const teardowns = new TeardownManager(directory, repoDir);
291
295
  await teardowns.skip();
292
296
  // revert teardown changes on exit
293
297
  process.on("beforeExit", () => {
@@ -332,9 +336,9 @@ const getParentDescribeNames = (node) => {
332
336
  * @param {string} content
333
337
  * @return { testBlock: string; parentDescribe: string; } testBlock - the test block content, testNode - the test function node
334
338
  */
335
- function getTypescriptTestBlock({ scenarioName, suites, content, }) {
339
+ function getTypescriptTestBlock({ scenarioName, suites, content, repoDir, }) {
336
340
  const project = new ts_morph_1.Project();
337
- const sourceFile = project.createSourceFile("test.ts", content);
341
+ const sourceFile = project.createSourceFile(path_1.default.join(repoDir, "test.ts"), content);
338
342
  const testAlias = (0, exports.getTestModuleAliasFromSourceFile)(sourceFile);
339
343
  // Get all test function nodes that match the scenario name
340
344
  const matchingTestFunctionNodes = sourceFile
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-run",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"