@ai-dev-tools/test-copilot-core 1.0.19

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.
Files changed (328) hide show
  1. package/README.md +6 -0
  2. package/azure-pipelines.yml +51 -0
  3. package/out/cli/commands/appInsightTelemetry.d.ts +7 -0
  4. package/out/cli/commands/appInsightTelemetry.d.ts.map +1 -0
  5. package/out/cli/commands/appInsightTelemetry.js +76 -0
  6. package/out/cli/commands/appInsightTelemetry.js.map +1 -0
  7. package/out/cli/commands/cliConfig.d.ts +4 -0
  8. package/out/cli/commands/cliConfig.d.ts.map +1 -0
  9. package/out/cli/commands/cliConfig.js +68 -0
  10. package/out/cli/commands/cliConfig.js.map +1 -0
  11. package/out/cli/commands/prompt.d.ts +6 -0
  12. package/out/cli/commands/prompt.d.ts.map +1 -0
  13. package/out/cli/commands/prompt.js +29 -0
  14. package/out/cli/commands/prompt.js.map +1 -0
  15. package/out/cli/commands/ut.d.ts +14 -0
  16. package/out/cli/commands/ut.d.ts.map +1 -0
  17. package/out/cli/commands/ut.js +72 -0
  18. package/out/cli/commands/ut.js.map +1 -0
  19. package/out/cli/commands/utPipeCmdWrapper.d.ts +18 -0
  20. package/out/cli/commands/utPipeCmdWrapper.d.ts.map +1 -0
  21. package/out/cli/commands/utPipeCmdWrapper.js +37 -0
  22. package/out/cli/commands/utPipeCmdWrapper.js.map +1 -0
  23. package/out/cli/config/index.d.ts +15 -0
  24. package/out/cli/config/index.d.ts.map +1 -0
  25. package/out/cli/config/index.js +10 -0
  26. package/out/cli/config/index.js.map +1 -0
  27. package/out/cli/index.d.ts +3 -0
  28. package/out/cli/index.d.ts.map +1 -0
  29. package/out/cli/index.js +169 -0
  30. package/out/cli/index.js.map +1 -0
  31. package/out/cli/type.d.ts +11 -0
  32. package/out/cli/type.d.ts.map +1 -0
  33. package/out/cli/type.js +3 -0
  34. package/out/cli/type.js.map +1 -0
  35. package/out/cli/utils/ds.d.ts +3 -0
  36. package/out/cli/utils/ds.d.ts.map +1 -0
  37. package/out/cli/utils/ds.js +50 -0
  38. package/out/cli/utils/ds.js.map +1 -0
  39. package/out/cli/utils/gpt.d.ts +3 -0
  40. package/out/cli/utils/gpt.d.ts.map +1 -0
  41. package/out/cli/utils/gpt.js +63 -0
  42. package/out/cli/utils/gpt.js.map +1 -0
  43. package/out/core/analyze/cjs.d.ts +61 -0
  44. package/out/core/analyze/cjs.d.ts.map +1 -0
  45. package/out/core/analyze/cjs.js +358 -0
  46. package/out/core/analyze/cjs.js.map +1 -0
  47. package/out/core/analyze/class.d.ts +4 -0
  48. package/out/core/analyze/class.d.ts.map +1 -0
  49. package/out/core/analyze/class.js +32 -0
  50. package/out/core/analyze/class.js.map +1 -0
  51. package/out/core/analyze/declares.d.ts +7 -0
  52. package/out/core/analyze/declares.d.ts.map +1 -0
  53. package/out/core/analyze/declares.js +316 -0
  54. package/out/core/analyze/declares.js.map +1 -0
  55. package/out/core/analyze/deps.d.ts +8 -0
  56. package/out/core/analyze/deps.d.ts.map +1 -0
  57. package/out/core/analyze/deps.js +210 -0
  58. package/out/core/analyze/deps.js.map +1 -0
  59. package/out/core/analyze/functionComponent.d.ts +4 -0
  60. package/out/core/analyze/functionComponent.d.ts.map +1 -0
  61. package/out/core/analyze/functionComponent.js +77 -0
  62. package/out/core/analyze/functionComponent.js.map +1 -0
  63. package/out/core/analyze/functions.d.ts +4 -0
  64. package/out/core/analyze/functions.d.ts.map +1 -0
  65. package/out/core/analyze/functions.js +46 -0
  66. package/out/core/analyze/functions.js.map +1 -0
  67. package/out/core/analyze/index.d.ts +16 -0
  68. package/out/core/analyze/index.d.ts.map +1 -0
  69. package/out/core/analyze/index.js +149 -0
  70. package/out/core/analyze/index.js.map +1 -0
  71. package/out/core/analyze/index.type.d.ts +69 -0
  72. package/out/core/analyze/index.type.d.ts.map +1 -0
  73. package/out/core/analyze/index.type.js +14 -0
  74. package/out/core/analyze/index.type.js.map +1 -0
  75. package/out/core/analyze/utils/global.d.ts +2 -0
  76. package/out/core/analyze/utils/global.d.ts.map +1 -0
  77. package/out/core/analyze/utils/global.js +84 -0
  78. package/out/core/analyze/utils/global.js.map +1 -0
  79. package/out/core/analyzev2/declare/class.d.ts +4 -0
  80. package/out/core/analyzev2/declare/class.d.ts.map +1 -0
  81. package/out/core/analyzev2/declare/class.js +24 -0
  82. package/out/core/analyzev2/declare/class.js.map +1 -0
  83. package/out/core/analyzev2/declare/funcLike.d.ts +8 -0
  84. package/out/core/analyzev2/declare/funcLike.d.ts.map +1 -0
  85. package/out/core/analyzev2/declare/funcLike.js +71 -0
  86. package/out/core/analyzev2/declare/funcLike.js.map +1 -0
  87. package/out/core/analyzev2/declare/variable.d.ts +3 -0
  88. package/out/core/analyzev2/declare/variable.d.ts.map +1 -0
  89. package/out/core/analyzev2/declare/variable.js +15 -0
  90. package/out/core/analyzev2/declare/variable.js.map +1 -0
  91. package/out/core/analyzev2/file.d.ts +19 -0
  92. package/out/core/analyzev2/file.d.ts.map +1 -0
  93. package/out/core/analyzev2/file.js +449 -0
  94. package/out/core/analyzev2/file.js.map +1 -0
  95. package/out/core/analyzev2/index.d.ts +5 -0
  96. package/out/core/analyzev2/index.d.ts.map +1 -0
  97. package/out/core/analyzev2/index.js +30 -0
  98. package/out/core/analyzev2/index.js.map +1 -0
  99. package/out/core/analyzev2/type.d.ts +35 -0
  100. package/out/core/analyzev2/type.d.ts.map +1 -0
  101. package/out/core/analyzev2/type.js +3 -0
  102. package/out/core/analyzev2/type.js.map +1 -0
  103. package/out/core/config/index.d.ts +25 -0
  104. package/out/core/config/index.d.ts.map +1 -0
  105. package/out/core/config/index.js +14 -0
  106. package/out/core/config/index.js.map +1 -0
  107. package/out/core/constants.d.ts +9 -0
  108. package/out/core/constants.d.ts.map +1 -0
  109. package/out/core/constants.js +12 -0
  110. package/out/core/constants.js.map +1 -0
  111. package/out/core/features/common/base.d.ts +20 -0
  112. package/out/core/features/common/base.d.ts.map +1 -0
  113. package/out/core/features/common/base.js +77 -0
  114. package/out/core/features/common/base.js.map +1 -0
  115. package/out/core/features/common/types.d.ts +16 -0
  116. package/out/core/features/common/types.d.ts.map +1 -0
  117. package/out/core/features/common/types.js +12 -0
  118. package/out/core/features/common/types.js.map +1 -0
  119. package/out/core/features/generateFile.d.ts +31 -0
  120. package/out/core/features/generateFile.d.ts.map +1 -0
  121. package/out/core/features/generateFile.js +148 -0
  122. package/out/core/features/generateFile.js.map +1 -0
  123. package/out/core/features/generateSingle.d.ts +28 -0
  124. package/out/core/features/generateSingle.d.ts.map +1 -0
  125. package/out/core/features/generateSingle.js +149 -0
  126. package/out/core/features/generateSingle.js.map +1 -0
  127. package/out/core/features/index.d.ts +9 -0
  128. package/out/core/features/index.d.ts.map +1 -0
  129. package/out/core/features/index.js +16 -0
  130. package/out/core/features/index.js.map +1 -0
  131. package/out/core/features/lintFix.d.ts +2 -0
  132. package/out/core/features/lintFix.d.ts.map +1 -0
  133. package/out/core/features/lintFix.js +33 -0
  134. package/out/core/features/lintFix.js.map +1 -0
  135. package/out/core/features/mergeUTFile.d.ts +19 -0
  136. package/out/core/features/mergeUTFile.d.ts.map +1 -0
  137. package/out/core/features/mergeUTFile.js +63 -0
  138. package/out/core/features/mergeUTFile.js.map +1 -0
  139. package/out/core/features/removeFailedCases.d.ts +23 -0
  140. package/out/core/features/removeFailedCases.d.ts.map +1 -0
  141. package/out/core/features/removeFailedCases.js +81 -0
  142. package/out/core/features/removeFailedCases.js.map +1 -0
  143. package/out/core/features/updateSpec.d.ts +20 -0
  144. package/out/core/features/updateSpec.d.ts.map +1 -0
  145. package/out/core/features/updateSpec.js +98 -0
  146. package/out/core/features/updateSpec.js.map +1 -0
  147. package/out/core/features/validFix.d.ts +29 -0
  148. package/out/core/features/validFix.d.ts.map +1 -0
  149. package/out/core/features/validFix.js +219 -0
  150. package/out/core/features/validFix.js.map +1 -0
  151. package/out/core/generate/UTGen.d.ts +79 -0
  152. package/out/core/generate/UTGen.d.ts.map +1 -0
  153. package/out/core/generate/UTGen.js +795 -0
  154. package/out/core/generate/UTGen.js.map +1 -0
  155. package/out/core/llm/index.d.ts +9 -0
  156. package/out/core/llm/index.d.ts.map +1 -0
  157. package/out/core/llm/index.js +39 -0
  158. package/out/core/llm/index.js.map +1 -0
  159. package/out/core/llm/prompts/config.d.ts +6 -0
  160. package/out/core/llm/prompts/config.d.ts.map +1 -0
  161. package/out/core/llm/prompts/config.js +239 -0
  162. package/out/core/llm/prompts/config.js.map +1 -0
  163. package/out/core/llm/prompts/templates/common.d.ts +3 -0
  164. package/out/core/llm/prompts/templates/common.d.ts.map +1 -0
  165. package/out/core/llm/prompts/templates/common.js +27 -0
  166. package/out/core/llm/prompts/templates/common.js.map +1 -0
  167. package/out/core/llm/prompts/templates/fixCase.d.ts +4 -0
  168. package/out/core/llm/prompts/templates/fixCase.d.ts.map +1 -0
  169. package/out/core/llm/prompts/templates/fixCase.js +46 -0
  170. package/out/core/llm/prompts/templates/fixCase.js.map +1 -0
  171. package/out/core/llm/prompts/templates/fixLint.d.ts +3 -0
  172. package/out/core/llm/prompts/templates/fixLint.d.ts.map +1 -0
  173. package/out/core/llm/prompts/templates/fixLint.js +22 -0
  174. package/out/core/llm/prompts/templates/fixLint.js.map +1 -0
  175. package/out/core/llm/prompts/templates/genClassMemberUT.d.ts +5 -0
  176. package/out/core/llm/prompts/templates/genClassMemberUT.d.ts.map +1 -0
  177. package/out/core/llm/prompts/templates/genClassMemberUT.js +115 -0
  178. package/out/core/llm/prompts/templates/genClassMemberUT.js.map +1 -0
  179. package/out/core/llm/prompts/templates/genFuncUT.d.ts +4 -0
  180. package/out/core/llm/prompts/templates/genFuncUT.d.ts.map +1 -0
  181. package/out/core/llm/prompts/templates/genFuncUT.js +64 -0
  182. package/out/core/llm/prompts/templates/genFuncUT.js.map +1 -0
  183. package/out/core/llm/prompts/templates/mergeUT.d.ts +4 -0
  184. package/out/core/llm/prompts/templates/mergeUT.d.ts.map +1 -0
  185. package/out/core/llm/prompts/templates/mergeUT.js +106 -0
  186. package/out/core/llm/prompts/templates/mergeUT.js.map +1 -0
  187. package/out/core/llm/prompts/templates/msnStudio.d.ts +3 -0
  188. package/out/core/llm/prompts/templates/msnStudio.d.ts.map +1 -0
  189. package/out/core/llm/prompts/templates/msnStudio.js +36 -0
  190. package/out/core/llm/prompts/templates/msnStudio.js.map +1 -0
  191. package/out/core/llm/prompts/templates/snapshotUT.d.ts +4 -0
  192. package/out/core/llm/prompts/templates/snapshotUT.d.ts.map +1 -0
  193. package/out/core/llm/prompts/templates/snapshotUT.js +68 -0
  194. package/out/core/llm/prompts/templates/snapshotUT.js.map +1 -0
  195. package/out/core/llm/prompts/templates/updateSpecBlock.d.ts +3 -0
  196. package/out/core/llm/prompts/templates/updateSpecBlock.d.ts.map +1 -0
  197. package/out/core/llm/prompts/templates/updateSpecBlock.js +38 -0
  198. package/out/core/llm/prompts/templates/updateSpecBlock.js.map +1 -0
  199. package/out/core/llm/prompts/templates/updateSpecFile.d.ts +3 -0
  200. package/out/core/llm/prompts/templates/updateSpecFile.d.ts.map +1 -0
  201. package/out/core/llm/prompts/templates/updateSpecFile.js +30 -0
  202. package/out/core/llm/prompts/templates/updateSpecFile.js.map +1 -0
  203. package/out/core/llm/types.d.ts +80 -0
  204. package/out/core/llm/types.d.ts.map +1 -0
  205. package/out/core/llm/types.js +5 -0
  206. package/out/core/llm/types.js.map +1 -0
  207. package/out/core/quality/validateMockedTest.d.ts +3 -0
  208. package/out/core/quality/validateMockedTest.d.ts.map +1 -0
  209. package/out/core/quality/validateMockedTest.js +211 -0
  210. package/out/core/quality/validateMockedTest.js.map +1 -0
  211. package/out/core/utils/checkTestIgnore.d.ts +4 -0
  212. package/out/core/utils/checkTestIgnore.d.ts.map +1 -0
  213. package/out/core/utils/checkTestIgnore.js +52 -0
  214. package/out/core/utils/checkTestIgnore.js.map +1 -0
  215. package/out/core/utils/common.d.ts +4 -0
  216. package/out/core/utils/common.d.ts.map +1 -0
  217. package/out/core/utils/common.js +34 -0
  218. package/out/core/utils/common.js.map +1 -0
  219. package/out/core/utils/console.d.ts +8 -0
  220. package/out/core/utils/console.d.ts.map +1 -0
  221. package/out/core/utils/console.js +24 -0
  222. package/out/core/utils/console.js.map +1 -0
  223. package/out/core/utils/deps.d.ts +3 -0
  224. package/out/core/utils/deps.d.ts.map +1 -0
  225. package/out/core/utils/deps.js +58 -0
  226. package/out/core/utils/deps.js.map +1 -0
  227. package/out/core/utils/eslintRuleHandler.d.ts +3 -0
  228. package/out/core/utils/eslintRuleHandler.d.ts.map +1 -0
  229. package/out/core/utils/eslintRuleHandler.js +98 -0
  230. package/out/core/utils/eslintRuleHandler.js.map +1 -0
  231. package/out/core/utils/file.d.ts +18 -0
  232. package/out/core/utils/file.d.ts.map +1 -0
  233. package/out/core/utils/file.js +142 -0
  234. package/out/core/utils/file.js.map +1 -0
  235. package/out/core/utils/lint.d.ts +9 -0
  236. package/out/core/utils/lint.d.ts.map +1 -0
  237. package/out/core/utils/lint.js +95 -0
  238. package/out/core/utils/lint.js.map +1 -0
  239. package/out/core/utils/lru.d.ts +12 -0
  240. package/out/core/utils/lru.d.ts.map +1 -0
  241. package/out/core/utils/lru.js +47 -0
  242. package/out/core/utils/lru.js.map +1 -0
  243. package/out/core/utils/move.d.ts +12 -0
  244. package/out/core/utils/move.d.ts.map +1 -0
  245. package/out/core/utils/move.js +93 -0
  246. package/out/core/utils/move.js.map +1 -0
  247. package/out/core/utils/msnStudio.d.ts +13 -0
  248. package/out/core/utils/msnStudio.d.ts.map +1 -0
  249. package/out/core/utils/msnStudio.js +150 -0
  250. package/out/core/utils/msnStudio.js.map +1 -0
  251. package/out/core/utils/parseCustomizedCmd.d.ts +2 -0
  252. package/out/core/utils/parseCustomizedCmd.d.ts.map +1 -0
  253. package/out/core/utils/parseCustomizedCmd.js +32 -0
  254. package/out/core/utils/parseCustomizedCmd.js.map +1 -0
  255. package/out/core/utils/specBlock.d.ts +20 -0
  256. package/out/core/utils/specBlock.d.ts.map +1 -0
  257. package/out/core/utils/specBlock.js +231 -0
  258. package/out/core/utils/specBlock.js.map +1 -0
  259. package/out/core/utils/system.d.ts +13 -0
  260. package/out/core/utils/system.d.ts.map +1 -0
  261. package/out/core/utils/system.js +86 -0
  262. package/out/core/utils/system.js.map +1 -0
  263. package/out/core/utils/telemetry.d.ts +9 -0
  264. package/out/core/utils/telemetry.d.ts.map +1 -0
  265. package/out/core/utils/telemetry.js +32 -0
  266. package/out/core/utils/telemetry.js.map +1 -0
  267. package/out/core/utils/tsMorph.d.ts +13 -0
  268. package/out/core/utils/tsMorph.d.ts.map +1 -0
  269. package/out/core/utils/tsMorph.js +76 -0
  270. package/out/core/utils/tsMorph.js.map +1 -0
  271. package/out/core/valid/customizedLint.d.ts +2 -0
  272. package/out/core/valid/customizedLint.d.ts.map +1 -0
  273. package/out/core/valid/customizedLint.js +64 -0
  274. package/out/core/valid/customizedLint.js.map +1 -0
  275. package/out/core/valid/customizedTest.d.ts +3 -0
  276. package/out/core/valid/customizedTest.d.ts.map +1 -0
  277. package/out/core/valid/customizedTest.js +58 -0
  278. package/out/core/valid/customizedTest.js.map +1 -0
  279. package/out/core/valid/extractVitestConfig.d.ts +5 -0
  280. package/out/core/valid/extractVitestConfig.d.ts.map +1 -0
  281. package/out/core/valid/extractVitestConfig.js +97 -0
  282. package/out/core/valid/extractVitestConfig.js.map +1 -0
  283. package/out/core/valid/getViteConfig.d.ts +2 -0
  284. package/out/core/valid/getViteConfig.d.ts.map +1 -0
  285. package/out/core/valid/getViteConfig.js +65 -0
  286. package/out/core/valid/getViteConfig.js.map +1 -0
  287. package/out/core/valid/index.d.ts +15 -0
  288. package/out/core/valid/index.d.ts.map +1 -0
  289. package/out/core/valid/index.js +99 -0
  290. package/out/core/valid/index.js.map +1 -0
  291. package/out/core/valid/jest.d.ts +4 -0
  292. package/out/core/valid/jest.d.ts.map +1 -0
  293. package/out/core/valid/jest.js +121 -0
  294. package/out/core/valid/jest.js.map +1 -0
  295. package/out/core/valid/mock.d.ts +2 -0
  296. package/out/core/valid/mock.d.ts.map +1 -0
  297. package/out/core/valid/mock.js +149 -0
  298. package/out/core/valid/mock.js.map +1 -0
  299. package/out/core/valid/remove.d.ts +5 -0
  300. package/out/core/valid/remove.d.ts.map +1 -0
  301. package/out/core/valid/remove.js +109 -0
  302. package/out/core/valid/remove.js.map +1 -0
  303. package/out/core/valid/tag.d.ts +3 -0
  304. package/out/core/valid/tag.d.ts.map +1 -0
  305. package/out/core/valid/tag.js +91 -0
  306. package/out/core/valid/tag.js.map +1 -0
  307. package/out/core/valid/type.d.ts +83 -0
  308. package/out/core/valid/type.d.ts.map +1 -0
  309. package/out/core/valid/type.js +3 -0
  310. package/out/core/valid/type.js.map +1 -0
  311. package/out/core/valid/vitest.d.ts +3 -0
  312. package/out/core/valid/vitest.d.ts.map +1 -0
  313. package/out/core/valid/vitest.js +82 -0
  314. package/out/core/valid/vitest.js.map +1 -0
  315. package/out/index.d.ts +20 -0
  316. package/out/index.d.ts.map +1 -0
  317. package/out/index.js +60 -0
  318. package/out/index.js.map +1 -0
  319. package/out/setup.d.ts +11 -0
  320. package/out/setup.d.ts.map +1 -0
  321. package/out/setup.js +14 -0
  322. package/out/setup.js.map +1 -0
  323. package/out/types.d.ts +23 -0
  324. package/out/types.d.ts.map +1 -0
  325. package/out/types.js +3 -0
  326. package/out/types.js.map +1 -0
  327. package/package.json +39 -0
  328. package/package_devops.json +42 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customizedTest.d.ts","sourceRoot":"","sources":["../../../src/core/valid/customizedTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAUjD,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA6CpH"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runCustomizedTest = runCustomizedTest;
4
+ const constants_1 = require("../constants");
5
+ const system_1 = require("../utils/system");
6
+ const file_1 = require("../utils/file");
7
+ const config_1 = require("../config");
8
+ const console_1 = require("../utils/console");
9
+ const jest_1 = require("./jest");
10
+ const parseCustomizedCmd_1 = require("../utils/parseCustomizedCmd");
11
+ async function runCustomizedTest(testFilePath, options) {
12
+ // `cd {repoDir};.\\init.ps1;cd {packageDir};pnpm msads-tool-prepare-jest-pip;pnpm msads-tool-jest-pip --jsonOutput {testFilePath}`;
13
+ const customizedTestCmd = (0, config_1.getConfig)().common.customizedTestCmd;
14
+ const testCmds = (0, parseCustomizedCmd_1.parseCustomizedCmd)(customizedTestCmd, testFilePath);
15
+ (0, console_1.getConsole)().log(`Start to run customized test command: ${testCmds}`);
16
+ const cwd = (0, file_1.findProjectRoot)(testFilePath);
17
+ try {
18
+ (0, console_1.getConsole)().log(`Running customized test\ncwd: ${cwd}\ncmd: ${testCmds}`);
19
+ const env = {
20
+ ...process.env,
21
+ ...(0, config_1.getConfig)().common.testEnv
22
+ };
23
+ const res = await (0, system_1.execAsync)("powershell.exe", ["-ExecutionPolicy", "Bypass", "-Command", testCmds.join(';')], {
24
+ cwd,
25
+ abortSignal: options?.abortSignal,
26
+ env,
27
+ maxBuffer: 1024 * 1024 * 80 // 80MB
28
+ });
29
+ if (res.error) {
30
+ (0, console_1.getConsole)().error(`Jest error: ${res.error}`);
31
+ }
32
+ const parsedResult = (0, jest_1.getJestJson)(res.stderr?.toString(), res.stdout?.toString());
33
+ if (parsedResult) {
34
+ return parsedResult;
35
+ }
36
+ const error = new Error(`========Failed to parse jest output========
37
+ command: ${testCmds}
38
+ cwd: ${cwd}
39
+ ----------
40
+ stdout:
41
+ ${res?.stdout ?? 'undefined'}
42
+ ----------
43
+ stderr:
44
+ ${res?.stderr ?? 'undefined'}
45
+ ========`);
46
+ error.name = constants_1.JEST_PARSE_ERROR;
47
+ throw error;
48
+ }
49
+ catch (error) {
50
+ if (error?.name === constants_1.JEST_PARSE_ERROR) {
51
+ throw error;
52
+ }
53
+ (0, console_1.getConsole)().error(`Run jest error: ${error}`);
54
+ return (0, jest_1.getJestJson)(error.stderr?.toString());
55
+ }
56
+ }
57
+ // runCustomizedTest("D:\\code\\AdsAppsCampaignUI\\private\\ads-copilot\\packages\\copilot-layout-provider", {});
58
+ //# sourceMappingURL=customizedTest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customizedTest.js","sourceRoot":"","sources":["../../../src/core/valid/customizedTest.ts"],"names":[],"mappings":";;AAUA,8CA6CC;AArDD,4CAAgD;AAChD,4CAA4C;AAC5C,wCAAgD;AAChD,sCAAsC;AACtC,8CAA8C;AAC9C,iCAAqC;AACrC,oEAAiE;AAE1D,KAAK,UAAU,iBAAiB,CAAC,YAAoB,EAAE,OAAqB;IAC/E,oIAAoI;IACpI,MAAM,iBAAiB,GAAG,IAAA,kBAAS,GAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC;IAC/D,MAAM,QAAQ,GAAG,IAAA,uCAAkB,EAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;IACrE,IAAA,oBAAU,GAAE,CAAC,GAAG,CAAC,yCAAyC,QAAQ,EAAE,CAAC,CAAC;IACtE,MAAM,GAAG,GAAG,IAAA,sBAAe,EAAC,YAAY,CAAC,CAAC;IAC1C,IAAI,CAAC;QACD,IAAA,oBAAU,GAAE,CAAC,GAAG,CAAC,iCAAiC,GAAG,UAAU,QAAQ,EAAE,CAAC,CAAC;QAC3E,MAAM,GAAG,GAAG;YACR,GAAG,OAAO,CAAC,GAAG;YACd,GAAG,IAAA,kBAAS,GAAE,CAAC,MAAM,CAAC,OAAO;SAChC,CAAC;QACF,MAAM,GAAG,GAAG,MAAM,IAAA,kBAAS,EAAC,gBAAgB,EAAE,CAAC,kBAAkB,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;YAC1G,GAAG;YACH,WAAW,EAAE,OAAO,EAAE,WAAW;YACjC,GAAG;YACH,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,EAAE,CAAE,OAAO;SACvC,CAAC,CAAC;QACH,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;YACZ,IAAA,oBAAU,GAAE,CAAC,KAAK,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,YAAY,GAAG,IAAA,kBAAW,EAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;QACjF,IAAI,YAAY,EAAE,CAAC;YACf,OAAO,YAAY,CAAC;QACxB,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC;mBACb,QAAQ;eACZ,GAAG;;;UAGR,GAAG,EAAE,MAAM,IAAI,WAAW;;;UAG1B,GAAG,EAAE,MAAM,IAAI,WAAW;iBACnB,CAAC,CAAC;QACX,KAAK,CAAC,IAAI,GAAG,4BAAgB,CAAC;QAC9B,MAAM,KAAK,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,IAAI,KAAK,EAAE,IAAI,KAAK,4BAAgB,EAAE,CAAC;YACnC,MAAM,KAAK,CAAC;QAChB,CAAC;QACD,IAAA,oBAAU,GAAE,CAAC,KAAK,CAAC,mBAAmB,KAAK,EAAE,CAAC,CAAC;QAC/C,OAAO,IAAA,kBAAW,EAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;AACL,CAAC;AAED,iHAAiH"}
@@ -0,0 +1,5 @@
1
+ export declare function extractTestConfigWithAST(configPath: string): {
2
+ testDir: string;
3
+ testSpecifier: any;
4
+ };
5
+ //# sourceMappingURL=extractVitestConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractVitestConfig.d.ts","sourceRoot":"","sources":["../../../src/core/valid/extractVitestConfig.ts"],"names":[],"mappings":"AAQA,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM;;;EAwC1D"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.extractTestConfigWithAST = extractTestConfigWithAST;
37
+ const fs = __importStar(require("fs"));
38
+ const ts = __importStar(require("typescript"));
39
+ let vitestConfig = {
40
+ include: [],
41
+ exclude: [],
42
+ };
43
+ function extractTestConfigWithAST(configPath) {
44
+ const sourceCode = fs.readFileSync(configPath, "utf-8");
45
+ const sourceFile = ts.createSourceFile(configPath, sourceCode, ts.ScriptTarget.Latest, true);
46
+ visit(sourceFile);
47
+ const directories = new Set();
48
+ const extensions = new Set();
49
+ (vitestConfig.include || []).forEach(pattern => {
50
+ const dirMatch = pattern.match(/^([^*]+)/);
51
+ if (dirMatch) {
52
+ const dir = dirMatch[1].replace(/\/$/, "");
53
+ if (dir && dir !== "**") {
54
+ directories.add(dir);
55
+ }
56
+ }
57
+ const extMatch = pattern.match(/\*(\.[^/]+)$/);
58
+ if (extMatch) {
59
+ extensions.add(extMatch[1]);
60
+ }
61
+ });
62
+ const testDir = directories.size > 0 ? Array.from(directories)[0] : undefined;
63
+ const specifierMatch = extensions.size > 0 ? Array.from(extensions)[0].match(/\.([^.]+)\.\w+$/) : undefined;
64
+ let testSpecifier;
65
+ if (specifierMatch) {
66
+ testSpecifier = specifierMatch[1];
67
+ }
68
+ return {
69
+ testDir,
70
+ testSpecifier
71
+ };
72
+ }
73
+ function visit(node) {
74
+ // find test attribute
75
+ if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) && node.name.text === "test" && ts.isObjectLiteralExpression(node.initializer)) {
76
+ node.initializer.properties.forEach(prop => {
77
+ if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) {
78
+ const propName = prop.name.text;
79
+ if ((propName === "include" || propName === "exclude") &&
80
+ ts.isArrayLiteralExpression(prop.initializer)) {
81
+ const values = [];
82
+ prop.initializer.elements.forEach(element => {
83
+ if (ts.isStringLiteral(element)) {
84
+ values.push(element.text);
85
+ }
86
+ });
87
+ vitestConfig[propName] = values;
88
+ }
89
+ }
90
+ });
91
+ }
92
+ ts.forEachChild(node, visit);
93
+ }
94
+ // const configPath = "d:\\code\\studio\\vite.config.ts";
95
+ // const testConfig = extractTestConfigWithAST(configPath);
96
+ // console.log("Extracted Vitest Config:", testConfig);
97
+ //# sourceMappingURL=extractVitestConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractVitestConfig.js","sourceRoot":"","sources":["../../../src/core/valid/extractVitestConfig.ts"],"names":[],"mappings":";;;;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CAAC,OAAO,CAAC,EAAE,CAAC;4BAC9B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;wBAC9B,CAAC;oBACL,CAAC,CAAC,CAAC;oBAEH,YAAY,CAAC,QAAiC,CAAC,GAAG,MAAM,CAAC;gBAC7D,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,yDAAyD;AACzD,2DAA2D;AAC3D,uDAAuD"}
@@ -0,0 +1,2 @@
1
+ export declare function getViteConfigPath(startDir: string, configFileName?: string): string | null;
2
+ //# sourceMappingURL=getViteConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getViteConfig.d.ts","sourceRoot":"","sources":["../../../src/core/valid/getViteConfig.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAC7B,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,MAAyB,GAC1C,MAAM,GAAG,IAAI,CAsBf"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getViteConfigPath = getViteConfigPath;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ function getViteConfigPath(startDir, configFileName = "vite.config.ts") {
40
+ let currentDir = path.resolve(startDir);
41
+ // Get root directory (Windows: 'C:\')
42
+ const root = path.parse(currentDir).root;
43
+ while (true) {
44
+ const configPath = path.join(currentDir, configFileName);
45
+ // Check if the configuration file exists
46
+ if (fs.existsSync(configPath)) {
47
+ return configPath;
48
+ }
49
+ // If we've reached the root directory, stop searching
50
+ if (currentDir === root) {
51
+ return null;
52
+ }
53
+ // Move up one directory level
54
+ currentDir = path.dirname(currentDir);
55
+ }
56
+ }
57
+ // const sourceFile = "D:\\code\\studio\\src\\components\\answer-cards\\shopping-card\\product-card\\rich-product-card-carousel.tsx";
58
+ // const configPath = getViteConfigPath(path.dirname(sourceFile));
59
+ // D:\code\studio\vite.config.ts
60
+ // if (configPath) {
61
+ // console.log(`get vite config: ${configPath}`);
62
+ // } else {
63
+ // console.log("Not found vite.config.ts");
64
+ // }
65
+ //# sourceMappingURL=getViteConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getViteConfig.js","sourceRoot":"","sources":["../../../src/core/valid/getViteConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,8CAyBC;AA5BD,uCAAyB;AACzB,2CAA6B;AAE7B,SAAgB,iBAAiB,CAC7B,QAAgB,EAChB,iBAAyB,gBAAgB;IAEzC,IAAI,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAExC,sCAAsC;IACtC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;IAEzC,OAAO,IAAI,EAAE,CAAC;QACV,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAEzD,yCAAyC;QACzC,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC5B,OAAO,UAAU,CAAC;QACtB,CAAC;QAED,sDAAsD;QACtD,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,8BAA8B;QAC9B,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC;AACL,CAAC;AAED,qIAAqI;AACrI,kEAAkE;AAElE,gCAAgC;AAChC,oBAAoB;AACpB,qDAAqD;AACrD,WAAW;AACX,+CAA+C;AAC/C,IAAI"}
@@ -0,0 +1,15 @@
1
+ import { FailedCaseDetails, TestOptions, TestOutput } from "./type";
2
+ export declare function runTest(type: 'jest' | 'vitest' | string, file: string, options?: TestOptions): Promise<TestOutput | undefined>;
3
+ export declare function getFailedCase(jestResult: TestOutput, specFileName?: string): {
4
+ cases: FailedCaseDetails[];
5
+ isDataErrorOnly: boolean;
6
+ };
7
+ export declare function getDataErrors(specCode: string, failedCases: FailedCaseDetails[]): {
8
+ casePath: string;
9
+ line: number;
10
+ code: string;
11
+ errorMessage: string;
12
+ expected: string;
13
+ actual: string;
14
+ }[];
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/valid/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAQpE,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAYpI;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG;IAC1E,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;CAC5B,CA+DA;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE;;;;;;;IAc/E"}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runTest = runTest;
4
+ exports.getFailedCase = getFailedCase;
5
+ exports.getDataErrors = getDataErrors;
6
+ const config_1 = require("../config");
7
+ const console_1 = require("../utils/console");
8
+ const customizedTest_1 = require("./customizedTest");
9
+ const jest_1 = require("./jest");
10
+ const vitest_1 = require("./vitest");
11
+ async function runTest(type, file, options) {
12
+ if (!!(0, config_1.getConfig)().common.customizedTestCmd) {
13
+ return await (0, customizedTest_1.runCustomizedTest)(file, options);
14
+ }
15
+ if (type === 'vitest') {
16
+ return await (0, vitest_1.runVitestAsync)(file, options);
17
+ }
18
+ if (type !== 'jest') {
19
+ (0, console_1.getConsole)().error(`Unsupported test type: ${type}, using jest as default`);
20
+ }
21
+ return await (0, jest_1.runJestAsync)(file, options);
22
+ }
23
+ function getFailedCase(jestResult, specFileName) {
24
+ const failedCases = [];
25
+ const results = jestResult?.testResults || [];
26
+ let dataErrorCount = 0;
27
+ for (const test of results) {
28
+ if (test.status !== 'failed') {
29
+ continue;
30
+ }
31
+ if (!test.assertionResults?.length && test.message) {
32
+ failedCases.push({
33
+ casePath: '*',
34
+ errorMessage: test.message
35
+ });
36
+ continue;
37
+ }
38
+ for (const assertion of test.assertionResults) {
39
+ if (assertion.status !== 'failed') {
40
+ continue;
41
+ }
42
+ const title = [...assertion.ancestorTitles, assertion.title].join('>');
43
+ const res = {
44
+ casePath: title,
45
+ errorMessage: ''
46
+ };
47
+ const failureMessage = assertion.failureMessages?.[0];
48
+ if (failureMessage) {
49
+ res.errorMessage = failureMessage;
50
+ // replace by real expected statement's location
51
+ const locMatch = failureMessage.match(specFileName
52
+ ? new RegExp(`${specFileName}:(\\d+):(\\d+)`)
53
+ : /\.(spec|test)\.(ts|js|tsx|jsx):(\d+):(\d+)/);
54
+ if (locMatch && locMatch.length > 2) {
55
+ res.codeLocation = {
56
+ line: parseInt(locMatch[1]),
57
+ column: parseInt(locMatch[2])
58
+ };
59
+ }
60
+ }
61
+ if (assertion.failureDetails?.[0]?.matcherResult) {
62
+ const matcherResult = assertion.failureDetails[0].matcherResult;
63
+ res.errorMessage = matcherResult.message;
64
+ res.expected = matcherResult.expected;
65
+ res.actual = matcherResult.actual;
66
+ if (/\.to(Be|Equal)\(/.test(matcherResult.message) && matcherResult.expected && matcherResult.actual) {
67
+ ++dataErrorCount;
68
+ }
69
+ }
70
+ if (!res.errorMessage) {
71
+ continue;
72
+ }
73
+ if (assertion.location && !res.codeLocation) {
74
+ res.codeLocation = assertion.location;
75
+ }
76
+ failedCases.push(res);
77
+ }
78
+ }
79
+ return {
80
+ cases: failedCases,
81
+ isDataErrorOnly: dataErrorCount > 0 && dataErrorCount === failedCases.length
82
+ };
83
+ }
84
+ function getDataErrors(specCode, failedCases) {
85
+ const lines = specCode.split('\n');
86
+ return failedCases.map((data) => {
87
+ const lineIndex = data.codeLocation?.line ?? 1;
88
+ const code = lines[lineIndex - 1];
89
+ return {
90
+ casePath: data.casePath,
91
+ line: lineIndex,
92
+ code,
93
+ errorMessage: data.errorMessage,
94
+ expected: data.expected,
95
+ actual: data.actual,
96
+ };
97
+ });
98
+ }
99
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+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
+ import { TestOptions, TestOutput } from './type';
2
+ export declare function runJestAsync(file: string, options?: TestOptions): Promise<TestOutput | undefined>;
3
+ export declare function getJestJson(stderr?: string, stdout?: string): TestOutput | undefined;
4
+ //# sourceMappingURL=jest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest.d.ts","sourceRoot":"","sources":["../../../src/core/valid/jest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAgDjD,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAqC3G;AAED,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAOpF"}
@@ -0,0 +1,121 @@
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
+ exports.runJestAsync = runJestAsync;
7
+ exports.getJestJson = getJestJson;
8
+ const file_1 = require("../utils/file");
9
+ const constants_1 = require("../constants");
10
+ const system_1 = require("../utils/system");
11
+ const fs_1 = __importDefault(require("fs"));
12
+ const config_1 = require("../config");
13
+ const console_1 = require("../utils/console");
14
+ const path_1 = __importDefault(require("path"));
15
+ function getJestCommand(file, options = {}) {
16
+ const { enableCoverage = false, noStackTrace = false, projectFolder } = options;
17
+ const filePath = (0, file_1.toUnixStyle)(file);
18
+ const projectFolderPath = projectFolder ? (0, file_1.toUnixStyle)(projectFolder) : (0, file_1.findProjectRoot)(filePath);
19
+ let config = '';
20
+ if (projectFolderPath) {
21
+ const jestConfigPath = (0, file_1.toUnixStyle)(path_1.default.resolve(projectFolderPath, 'jest.config.js'));
22
+ if (fs_1.default.existsSync(jestConfigPath)) {
23
+ config = `--config="${jestConfigPath}"`;
24
+ }
25
+ }
26
+ const params = [
27
+ 'jest',
28
+ '--bail=999',
29
+ '--verbose=false',
30
+ '--json',
31
+ '--testLocationInResults',
32
+ '--no-colors',
33
+ '--passWithNoTests',
34
+ '--updateSnapshot',
35
+ ];
36
+ if (noStackTrace) {
37
+ params.push('--noStackTrace');
38
+ }
39
+ if (enableCoverage) {
40
+ params.push('--coverage');
41
+ }
42
+ if (config) {
43
+ params.push(config);
44
+ }
45
+ params.push(filePath);
46
+ return {
47
+ params,
48
+ cwd: projectFolderPath || path_1.default.dirname(filePath),
49
+ };
50
+ }
51
+ async function runJestAsync(file, options = {}) {
52
+ (0, console_1.getConsole)().log(`Running jest for ${file}`);
53
+ try {
54
+ let parsedResult = undefined;
55
+ const { params, cwd } = getJestCommand(file, options);
56
+ (0, console_1.getConsole)().log(`Run jest command: ${params.join(' ')}`);
57
+ const res = await (0, system_1.execAsync)('npx', params, {
58
+ cwd,
59
+ abortSignal: options.abortSignal,
60
+ env: (0, config_1.getConfig)().common.testEnv
61
+ });
62
+ if (res.error) {
63
+ (0, console_1.getConsole)().error(`Jest error: ${res.error}`);
64
+ }
65
+ parsedResult = getJestJson(res.stderr?.toString(), res.stdout?.toString());
66
+ if (parsedResult) {
67
+ return parsedResult;
68
+ }
69
+ const error = new Error(`========Failed to parse jest output========
70
+ command: npx ${params.join(' ')}
71
+ cwd: ${cwd}
72
+ ----------
73
+ stdout:
74
+ ${res?.stdout ?? 'undefined'}
75
+ ----------
76
+ stderr:
77
+ ${res?.stderr ?? 'undefined'}
78
+ ========`);
79
+ error.name = constants_1.JEST_PARSE_ERROR;
80
+ throw error;
81
+ }
82
+ catch (error) {
83
+ if (error?.name === constants_1.JEST_PARSE_ERROR) {
84
+ throw error;
85
+ }
86
+ (0, console_1.getConsole)().error(`Run jest error: ${error}`);
87
+ return getJestJson(error.stdout?.toString());
88
+ }
89
+ }
90
+ function getJestJson(stderr, stdout) {
91
+ for (const text of [stdout, stderr]) {
92
+ const res = parseJestOuput(text);
93
+ if (res) {
94
+ return res;
95
+ }
96
+ }
97
+ }
98
+ function parseJestOuput(text) {
99
+ if (!text) {
100
+ return;
101
+ }
102
+ let jsonText = '';
103
+ const lines = text.split('\n');
104
+ for (const line of lines) {
105
+ jsonText = line.trim();
106
+ if (jsonText.startsWith('{')) {
107
+ break;
108
+ }
109
+ }
110
+ if (!jsonText) {
111
+ return;
112
+ }
113
+ try {
114
+ return JSON.parse(jsonText);
115
+ }
116
+ catch (error) {
117
+ console.log(`Parse jest json error: ${jsonText}`);
118
+ return;
119
+ }
120
+ }
121
+ //# sourceMappingURL=jest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest.js","sourceRoot":"","sources":["../../../src/core/valid/jest.ts"],"names":[],"mappings":";;;;;AAgDA,oCAqCC;AAED,kCAOC;AA7FD,wCAA6D;AAE7D,4CAAgD;AAChD,4CAA4C;AAC5C,4CAAoB;AACpB,sCAAsC;AACtC,8CAA8C;AAC9C,gDAAwB;AAExB,SAAS,cAAc,CAAC,IAAY,EAAE,UAAuB,EAAE;IAC3D,MAAM,EAAE,cAAc,GAAG,KAAK,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAChF,MAAM,QAAQ,GAAG,IAAA,kBAAW,EAAC,IAAI,CAAC,CAAC;IACnC,MAAM,iBAAiB,GAAG,aAAa,CAAC,CAAC,CAAC,IAAA,kBAAW,EAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAA,sBAAe,EAAC,QAAQ,CAAC,CAAC;IACjG,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,iBAAiB,EAAE,CAAC;QACpB,MAAM,cAAc,GAAG,IAAA,kBAAW,EAAC,cAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC,CAAC;QACtF,IAAI,YAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;YAChC,MAAM,GAAG,aAAa,cAAc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MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACvB,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM;QACV,CAAC;IACL,CAAC;IAED,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,OAAO;IACX,CAAC;IACD,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAe,CAAC;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;QAClD,OAAO;IACX,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function checkMock(code: string): string;
2
+ //# sourceMappingURL=mock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/core/valid/mock.ts"],"names":[],"mappings":"AAGA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,UAoCrC"}