@empiricalrun/test-run 0.4.5 → 0.4.6

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.4.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 4ab570f: fix: consider "setup" and "teardown" aliases as test block in test-run
8
+
3
9
  ## 0.4.5
4
10
 
5
11
  ### Patch Changes
@@ -10,6 +10,7 @@ export declare function cmd(command: string[], options: {
10
10
  * @return {*} {Promise<string[]>}
11
11
  */
12
12
  export declare function getAllFilePaths(directoryPath?: string): Promise<string[]>;
13
+ export declare const getTestModuleAliasFromSourceFile: (sourceFile: SourceFile) => string;
13
14
  export declare function getTestCaseNode({ filePath, scenarioName, }: {
14
15
  filePath: string;
15
16
  scenarioName: string;
@@ -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;AAGjE,OAAO,EAEL,QAAQ,EAER,aAAa,EACd,MAAM,UAAU,CAAC;AAElB,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,CA2BjB;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,aAAa,GAAE,MAAW,GACzB,OAAO,CAAC,MAAM,EAAE,CAAC,CAqBnB;AAED,wBAAsB,eAAe,CAAC,EACpC,QAAQ,EACR,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC;IAAE,YAAY,EAAE,IAAI,GAAG,SAAS,CAAC;IAA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AM,CAAC;CAClB,iBAgBA;AAED,wBAAsB,+BAA+B,CAAC,QAAQ,EAAE,QAAQ,gBAevE;AAED,eAAO,MAAM,4BAA4B,UAEhC,MAAM,EAAE,mBAGE,MAAM,EAAE,EAAE,KAC1B,MAAM,EAUR,CAAC;AAEF,eAAO,MAAM,sBAAsB;cAIvB,QAAQ;mBACH,MAAM,EAAE;MACrB,QAAQ,MAAM,EAAE,CAmBnB,CAAC;AAEF,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,eAAO,MAAM,uBAAuB,QAAa,QAC/C,MAAM,GAAG,SAAS,CAMnB,CAAC;AAEF,eAAO,MAAM,aAAa,aAAoB,MAAM,KAAG,QAAQ,IAAI,CAWlE,CAAC;AAEF,eAAO,MAAM,aAAa,aAAc,QAAQ,KAAG,aAIlD,CAAC;AA4DF,eAAO,MAAM,sBAAsB,cAAqB,MAAM,kBAkB7D,CAAC"}
@@ -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.handleTeardownSkipFlag = exports.getTestRunner = exports.downloadBuild = exports.pickNameFromPackageJson = exports.buildRepoName = exports.generateProjectFilters = exports.filterArrayByGlobMatchersSet = exports.getProjectsFromPlaywrightConfig = exports.markTestAsOnly = exports.hasTopLevelDescribeConfigureWithSerialMode = exports.findFirstSerialDescribeBlock = exports.hasTestBlock = exports.getTestCaseNode = exports.getAllFilePaths = exports.cmd = void 0;
6
+ exports.handleTeardownSkipFlag = exports.getTestRunner = exports.downloadBuild = exports.pickNameFromPackageJson = exports.buildRepoName = exports.generateProjectFilters = exports.filterArrayByGlobMatchersSet = exports.getProjectsFromPlaywrightConfig = exports.markTestAsOnly = exports.hasTopLevelDescribeConfigureWithSerialMode = exports.findFirstSerialDescribeBlock = exports.hasTestBlock = exports.getTestCaseNode = exports.getTestModuleAliasFromSourceFile = exports.getAllFilePaths = exports.cmd = void 0;
7
7
  const child_process_1 = require("child_process");
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const minimatch_1 = require("minimatch");
@@ -71,12 +71,27 @@ async function getAllFilePaths(directoryPath = "") {
71
71
  return filePaths;
72
72
  }
73
73
  exports.getAllFilePaths = getAllFilePaths;
74
+ const getTestModuleAliasFromSourceFile = (sourceFile) => {
75
+ return (sourceFile
76
+ .getImportDeclarations()
77
+ // Look for any import that includes "test" as a named import, regardless of module path
78
+ // "test" can be imported from "@playwright/test" or "<some-fixture>"
79
+ .find((importDecl) => importDecl
80
+ .getNamedImports()
81
+ .some((namedImport) => namedImport.getName() === "test"))
82
+ ?.getNamedImports()
83
+ .find((namedImport) => namedImport.getName() === "test")
84
+ ?.getAliasNode()
85
+ ?.getText() || "test");
86
+ };
87
+ exports.getTestModuleAliasFromSourceFile = getTestModuleAliasFromSourceFile;
74
88
  async function getTestCaseNode({ filePath, scenarioName, }) {
75
89
  const project = new ts_morph_1.Project();
76
90
  const content = await fs_extra_1.default.readFile(filePath, "utf-8");
77
91
  const sourceFile = project.createSourceFile("test.ts", content);
92
+ const testAlias = (0, exports.getTestModuleAliasFromSourceFile)(sourceFile);
78
93
  const testCaseNode = sourceFile.getFirstDescendant((node) => !!(node.isKind(ts_morph_1.SyntaxKind.CallExpression) &&
79
- node.getExpression().getText() === "test" &&
94
+ node.getExpression().getText() === testAlias &&
80
95
  node.getArguments()[0]?.getText().includes(scenarioName)));
81
96
  return { testCaseNode, sourceFile };
82
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-run",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"