@datadog/datadog-ci 2.40.3 → 2.42.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.
Files changed (294) hide show
  1. package/README.md +1 -0
  2. package/dist/commands/deployment/cli.js +2 -1
  3. package/dist/commands/deployment/cli.js.map +1 -1
  4. package/dist/commands/deployment/correlate.d.ts +18 -0
  5. package/dist/commands/deployment/correlate.js +154 -0
  6. package/dist/commands/deployment/correlate.js.map +1 -0
  7. package/dist/commands/dsyms/utils.js +2 -4
  8. package/dist/commands/dsyms/utils.js.map +1 -1
  9. package/dist/commands/elf-symbols/elf.d.ts +5 -3
  10. package/dist/commands/elf-symbols/elf.js +18 -16
  11. package/dist/commands/elf-symbols/elf.js.map +1 -1
  12. package/dist/commands/elf-symbols/helpers.js +1 -1
  13. package/dist/commands/elf-symbols/interfaces.d.ts +6 -2
  14. package/dist/commands/elf-symbols/upload.d.ts +3 -0
  15. package/dist/commands/elf-symbols/upload.js +46 -22
  16. package/dist/commands/elf-symbols/upload.js.map +1 -1
  17. package/dist/commands/sarif/renderer.d.ts +1 -1
  18. package/dist/commands/sarif/renderer.js +5 -2
  19. package/dist/commands/sarif/renderer.js.map +1 -1
  20. package/dist/commands/sarif/upload.d.ts +1 -0
  21. package/dist/commands/sarif/upload.js +12 -35
  22. package/dist/commands/sarif/upload.js.map +1 -1
  23. package/dist/commands/sarif/validation.d.ts +15 -0
  24. package/dist/commands/sarif/validation.js +78 -0
  25. package/dist/commands/sarif/validation.js.map +1 -0
  26. package/dist/commands/sbom/upload.d.ts +1 -0
  27. package/dist/commands/sbom/upload.js +6 -14
  28. package/dist/commands/sbom/upload.js.map +1 -1
  29. package/dist/commands/synthetics/batch.js +3 -2
  30. package/dist/commands/synthetics/batch.js.map +1 -1
  31. package/dist/commands/synthetics/compatibility.d.ts +2 -2
  32. package/dist/commands/synthetics/compatibility.js +26 -26
  33. package/dist/commands/synthetics/compatibility.js.map +1 -1
  34. package/dist/commands/synthetics/interfaces.d.ts +3 -2
  35. package/dist/commands/synthetics/interfaces.js.map +1 -1
  36. package/dist/commands/synthetics/reporters/junit.d.ts +1 -0
  37. package/dist/commands/synthetics/reporters/junit.js +1 -0
  38. package/dist/commands/synthetics/reporters/junit.js.map +1 -1
  39. package/dist/commands/synthetics/run-tests-command.d.ts +1 -0
  40. package/dist/commands/synthetics/run-tests-command.js +25 -17
  41. package/dist/commands/synthetics/run-tests-command.js.map +1 -1
  42. package/dist/commands/synthetics/utils/internal.d.ts +4 -0
  43. package/dist/commands/synthetics/utils/internal.js +37 -2
  44. package/dist/commands/synthetics/utils/internal.js.map +1 -1
  45. package/dist/commands/synthetics/utils/public.d.ts +3 -0
  46. package/dist/commands/synthetics/utils/public.js +3 -0
  47. package/dist/commands/synthetics/utils/public.js.map +1 -1
  48. package/dist/helpers/git/get-git-data.d.ts +2 -0
  49. package/dist/helpers/git/get-git-data.js +11 -1
  50. package/dist/helpers/git/get-git-data.js.map +1 -1
  51. package/dist/helpers/tags.d.ts +2 -1
  52. package/dist/helpers/tags.js +3 -2
  53. package/dist/helpers/tags.js.map +1 -1
  54. package/package.json +14 -12
  55. package/dist/__tests__/cli.test.d.ts +0 -1
  56. package/dist/__tests__/cli.test.js +0 -41
  57. package/dist/__tests__/cli.test.js.map +0 -1
  58. package/dist/commands/cloud-run/__tests__/fixtures.d.ts +0 -2
  59. package/dist/commands/cloud-run/__tests__/fixtures.js +0 -12
  60. package/dist/commands/cloud-run/__tests__/fixtures.js.map +0 -1
  61. package/dist/commands/cloud-run/__tests__/flare.test.d.ts +0 -1
  62. package/dist/commands/cloud-run/__tests__/flare.test.js +0 -557
  63. package/dist/commands/cloud-run/__tests__/flare.test.js.map +0 -1
  64. package/dist/commands/deployment/__tests__/mark.test.d.ts +0 -1
  65. package/dist/commands/deployment/__tests__/mark.test.js +0 -47
  66. package/dist/commands/deployment/__tests__/mark.test.js.map +0 -1
  67. package/dist/commands/dora/__tests__/deployment.test.d.ts +0 -1
  68. package/dist/commands/dora/__tests__/deployment.test.js +0 -201
  69. package/dist/commands/dora/__tests__/deployment.test.js.map +0 -1
  70. package/dist/commands/dsyms/__tests__/upload.test.d.ts +0 -1
  71. package/dist/commands/dsyms/__tests__/upload.test.js +0 -346
  72. package/dist/commands/dsyms/__tests__/upload.test.js.map +0 -1
  73. package/dist/commands/dsyms/__tests__/utils.test.d.ts +0 -1
  74. package/dist/commands/dsyms/__tests__/utils.test.js +0 -103
  75. package/dist/commands/dsyms/__tests__/utils.test.js.map +0 -1
  76. package/dist/commands/elf-symbols/__tests__/elf.test.d.ts +0 -1
  77. package/dist/commands/elf-symbols/__tests__/elf.test.js +0 -813
  78. package/dist/commands/elf-symbols/__tests__/elf.test.js.map +0 -1
  79. package/dist/commands/elf-symbols/__tests__/upload.test.d.ts +0 -1
  80. package/dist/commands/elf-symbols/__tests__/upload.test.js +0 -249
  81. package/dist/commands/elf-symbols/__tests__/upload.test.js.map +0 -1
  82. package/dist/commands/flutter-symbols/__tests__/upload.test.d.ts +0 -1
  83. package/dist/commands/flutter-symbols/__tests__/upload.test.js +0 -617
  84. package/dist/commands/flutter-symbols/__tests__/upload.test.js.map +0 -1
  85. package/dist/commands/gate/__tests__/evaluate.test.d.ts +0 -1
  86. package/dist/commands/gate/__tests__/evaluate.test.js +0 -398
  87. package/dist/commands/gate/__tests__/evaluate.test.js.map +0 -1
  88. package/dist/commands/gate/__tests__/scope.test.d.ts +0 -1
  89. package/dist/commands/gate/__tests__/scope.test.js +0 -29
  90. package/dist/commands/gate/__tests__/scope.test.js.map +0 -1
  91. package/dist/commands/git-metadata/__tests__/git.test.d.ts +0 -1
  92. package/dist/commands/git-metadata/__tests__/git.test.js +0 -132
  93. package/dist/commands/git-metadata/__tests__/git.test.js.map +0 -1
  94. package/dist/commands/git-metadata/__tests__/gitdb.test.d.ts +0 -1
  95. package/dist/commands/git-metadata/__tests__/gitdb.test.js +0 -1386
  96. package/dist/commands/git-metadata/__tests__/gitdb.test.js.map +0 -1
  97. package/dist/commands/git-metadata/__tests__/library.test.d.ts +0 -1
  98. package/dist/commands/git-metadata/__tests__/library.test.js +0 -118
  99. package/dist/commands/git-metadata/__tests__/library.test.js.map +0 -1
  100. package/dist/commands/git-metadata/__tests__/upload.test.d.ts +0 -1
  101. package/dist/commands/git-metadata/__tests__/upload.test.js +0 -52
  102. package/dist/commands/git-metadata/__tests__/upload.test.js.map +0 -1
  103. package/dist/commands/junit/__tests__/id.test.d.ts +0 -1
  104. package/dist/commands/junit/__tests__/id.test.js +0 -24
  105. package/dist/commands/junit/__tests__/id.test.js.map +0 -1
  106. package/dist/commands/junit/__tests__/upload.test.d.ts +0 -1
  107. package/dist/commands/junit/__tests__/upload.test.js +0 -495
  108. package/dist/commands/junit/__tests__/upload.test.js.map +0 -1
  109. package/dist/commands/lambda/__tests__/fixtures.d.ts +0 -51
  110. package/dist/commands/lambda/__tests__/fixtures.js +0 -146
  111. package/dist/commands/lambda/__tests__/fixtures.js.map +0 -1
  112. package/dist/commands/lambda/__tests__/flare.test.d.ts +0 -1
  113. package/dist/commands/lambda/__tests__/flare.test.js +0 -730
  114. package/dist/commands/lambda/__tests__/flare.test.js.map +0 -1
  115. package/dist/commands/lambda/__tests__/functions/commons.test.d.ts +0 -1
  116. package/dist/commands/lambda/__tests__/functions/commons.test.js +0 -791
  117. package/dist/commands/lambda/__tests__/functions/commons.test.js.map +0 -1
  118. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.d.ts +0 -1
  119. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js +0 -386
  120. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js.map +0 -1
  121. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.d.ts +0 -1
  122. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js +0 -721
  123. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js.map +0 -1
  124. package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +0 -1
  125. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +0 -513
  126. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js.map +0 -1
  127. package/dist/commands/lambda/__tests__/functions/versionChecker.test.d.ts +0 -1
  128. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js +0 -33
  129. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js.map +0 -1
  130. package/dist/commands/lambda/__tests__/instrument.test.d.ts +0 -1
  131. package/dist/commands/lambda/__tests__/instrument.test.js +0 -1511
  132. package/dist/commands/lambda/__tests__/instrument.test.js.map +0 -1
  133. package/dist/commands/lambda/__tests__/loggroup.test.d.ts +0 -1
  134. package/dist/commands/lambda/__tests__/loggroup.test.js +0 -340
  135. package/dist/commands/lambda/__tests__/loggroup.test.js.map +0 -1
  136. package/dist/commands/lambda/__tests__/prompt.test.d.ts +0 -1
  137. package/dist/commands/lambda/__tests__/prompt.test.js +0 -206
  138. package/dist/commands/lambda/__tests__/prompt.test.js.map +0 -1
  139. package/dist/commands/lambda/__tests__/tags.test.d.ts +0 -1
  140. package/dist/commands/lambda/__tests__/tags.test.js +0 -305
  141. package/dist/commands/lambda/__tests__/tags.test.js.map +0 -1
  142. package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +0 -1
  143. package/dist/commands/lambda/__tests__/uninstrument.test.js +0 -722
  144. package/dist/commands/lambda/__tests__/uninstrument.test.js.map +0 -1
  145. package/dist/commands/measure/__tests__/measure.test.d.ts +0 -1
  146. package/dist/commands/measure/__tests__/measure.test.js +0 -110
  147. package/dist/commands/measure/__tests__/measure.test.js.map +0 -1
  148. package/dist/commands/react-native/__tests__/codepush.test.d.ts +0 -1
  149. package/dist/commands/react-native/__tests__/codepush.test.js +0 -161
  150. package/dist/commands/react-native/__tests__/codepush.test.js.map +0 -1
  151. package/dist/commands/react-native/__tests__/interfaces.test.d.ts +0 -1
  152. package/dist/commands/react-native/__tests__/interfaces.test.js +0 -33
  153. package/dist/commands/react-native/__tests__/interfaces.test.js.map +0 -1
  154. package/dist/commands/react-native/__tests__/upload.test.d.ts +0 -1
  155. package/dist/commands/react-native/__tests__/upload.test.js +0 -238
  156. package/dist/commands/react-native/__tests__/upload.test.js.map +0 -1
  157. package/dist/commands/react-native/__tests__/utils.test.d.ts +0 -1
  158. package/dist/commands/react-native/__tests__/utils.test.js +0 -27
  159. package/dist/commands/react-native/__tests__/utils.test.js.map +0 -1
  160. package/dist/commands/react-native/__tests__/xcode.test.d.ts +0 -1
  161. package/dist/commands/react-native/__tests__/xcode.test.js +0 -465
  162. package/dist/commands/react-native/__tests__/xcode.test.js.map +0 -1
  163. package/dist/commands/sarif/__tests__/upload.test.d.ts +0 -1
  164. package/dist/commands/sarif/__tests__/upload.test.js +0 -228
  165. package/dist/commands/sarif/__tests__/upload.test.js.map +0 -1
  166. package/dist/commands/sbom/__tests__/payload.test.d.ts +0 -1
  167. package/dist/commands/sbom/__tests__/payload.test.js +0 -262
  168. package/dist/commands/sbom/__tests__/payload.test.js.map +0 -1
  169. package/dist/commands/sbom/__tests__/validation.test.d.ts +0 -1
  170. package/dist/commands/sbom/__tests__/validation.test.js +0 -41
  171. package/dist/commands/sbom/__tests__/validation.test.js.map +0 -1
  172. package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +0 -1
  173. package/dist/commands/sourcemaps/__tests__/upload.test.js +0 -270
  174. package/dist/commands/sourcemaps/__tests__/upload.test.js.map +0 -1
  175. package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +0 -1
  176. package/dist/commands/sourcemaps/__tests__/utils.test.js +0 -31
  177. package/dist/commands/sourcemaps/__tests__/utils.test.js.map +0 -1
  178. package/dist/commands/stepfunctions/__tests__/awsCommands.test.d.ts +0 -1
  179. package/dist/commands/stepfunctions/__tests__/awsCommands.test.js +0 -192
  180. package/dist/commands/stepfunctions/__tests__/awsCommands.test.js.map +0 -1
  181. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.d.ts +0 -6
  182. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js +0 -45
  183. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js.map +0 -1
  184. package/dist/commands/stepfunctions/__tests__/fixtures/cli.d.ts +0 -5
  185. package/dist/commands/stepfunctions/__tests__/fixtures/cli.js +0 -19
  186. package/dist/commands/stepfunctions/__tests__/fixtures/cli.js.map +0 -1
  187. package/dist/commands/stepfunctions/__tests__/helpers.test.d.ts +0 -1
  188. package/dist/commands/stepfunctions/__tests__/helpers.test.js +0 -205
  189. package/dist/commands/stepfunctions/__tests__/helpers.test.js.map +0 -1
  190. package/dist/commands/stepfunctions/__tests__/instrument.test.d.ts +0 -1
  191. package/dist/commands/stepfunctions/__tests__/instrument.test.js +0 -431
  192. package/dist/commands/stepfunctions/__tests__/instrument.test.js.map +0 -1
  193. package/dist/commands/stepfunctions/__tests__/uninstrument.test.d.ts +0 -1
  194. package/dist/commands/stepfunctions/__tests__/uninstrument.test.js +0 -166
  195. package/dist/commands/stepfunctions/__tests__/uninstrument.test.js.map +0 -1
  196. package/dist/commands/synthetics/__tests__/api.test.d.ts +0 -1
  197. package/dist/commands/synthetics/__tests__/api.test.js +0 -422
  198. package/dist/commands/synthetics/__tests__/api.test.js.map +0 -1
  199. package/dist/commands/synthetics/__tests__/cli.test.d.ts +0 -1
  200. package/dist/commands/synthetics/__tests__/cli.test.js +0 -1325
  201. package/dist/commands/synthetics/__tests__/cli.test.js.map +0 -1
  202. package/dist/commands/synthetics/__tests__/fixtures.d.ts +0 -149
  203. package/dist/commands/synthetics/__tests__/fixtures.js +0 -507
  204. package/dist/commands/synthetics/__tests__/fixtures.js.map +0 -1
  205. package/dist/commands/synthetics/__tests__/mobile.test.d.ts +0 -1
  206. package/dist/commands/synthetics/__tests__/mobile.test.js +0 -376
  207. package/dist/commands/synthetics/__tests__/mobile.test.js.map +0 -1
  208. package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +0 -1
  209. package/dist/commands/synthetics/__tests__/reporters/default.test.js +0 -354
  210. package/dist/commands/synthetics/__tests__/reporters/default.test.js.map +0 -1
  211. package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +0 -1
  212. package/dist/commands/synthetics/__tests__/reporters/junit.test.js +0 -353
  213. package/dist/commands/synthetics/__tests__/reporters/junit.test.js.map +0 -1
  214. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.d.ts +0 -1
  215. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js +0 -232
  216. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js.map +0 -1
  217. package/dist/commands/synthetics/__tests__/run-tests-lib.test.d.ts +0 -1
  218. package/dist/commands/synthetics/__tests__/run-tests-lib.test.js +0 -735
  219. package/dist/commands/synthetics/__tests__/run-tests-lib.test.js.map +0 -1
  220. package/dist/commands/synthetics/__tests__/test.test.d.ts +0 -1
  221. package/dist/commands/synthetics/__tests__/test.test.js +0 -33
  222. package/dist/commands/synthetics/__tests__/test.test.js.map +0 -1
  223. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.d.ts +0 -1
  224. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js +0 -21
  225. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js.map +0 -1
  226. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.d.ts +0 -1
  227. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js +0 -80
  228. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js.map +0 -1
  229. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.d.ts +0 -1
  230. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js +0 -109
  231. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js.map +0 -1
  232. package/dist/commands/synthetics/__tests__/utils/internal.test.d.ts +0 -1
  233. package/dist/commands/synthetics/__tests__/utils/internal.test.js +0 -186
  234. package/dist/commands/synthetics/__tests__/utils/internal.test.js.map +0 -1
  235. package/dist/commands/synthetics/__tests__/utils/public.test.d.ts +0 -1
  236. package/dist/commands/synthetics/__tests__/utils/public.test.js +0 -1526
  237. package/dist/commands/synthetics/__tests__/utils/public.test.js.map +0 -1
  238. package/dist/commands/tag/__tests__/tag.test.d.ts +0 -1
  239. package/dist/commands/tag/__tests__/tag.test.js +0 -75
  240. package/dist/commands/tag/__tests__/tag.test.js.map +0 -1
  241. package/dist/commands/trace/__tests__/trace.test.d.ts +0 -1
  242. package/dist/commands/trace/__tests__/trace.test.js +0 -145
  243. package/dist/commands/trace/__tests__/trace.test.js.map +0 -1
  244. package/dist/commands/unity-symbols/__tests__/upload.test.d.ts +0 -1
  245. package/dist/commands/unity-symbols/__tests__/upload.test.js +0 -369
  246. package/dist/commands/unity-symbols/__tests__/upload.test.js.map +0 -1
  247. package/dist/helpers/__tests__/app.test.d.ts +0 -1
  248. package/dist/helpers/__tests__/app.test.js +0 -31
  249. package/dist/helpers/__tests__/app.test.js.map +0 -1
  250. package/dist/helpers/__tests__/ci.test.d.ts +0 -1
  251. package/dist/helpers/__tests__/ci.test.js +0 -252
  252. package/dist/helpers/__tests__/ci.test.js.map +0 -1
  253. package/dist/helpers/__tests__/fixtures.d.ts +0 -33
  254. package/dist/helpers/__tests__/fixtures.js +0 -71
  255. package/dist/helpers/__tests__/fixtures.js.map +0 -1
  256. package/dist/helpers/__tests__/flare.test.d.ts +0 -1
  257. package/dist/helpers/__tests__/flare.test.js +0 -226
  258. package/dist/helpers/__tests__/flare.test.js.map +0 -1
  259. package/dist/helpers/__tests__/fs.test.d.ts +0 -1
  260. package/dist/helpers/__tests__/fs.test.js +0 -189
  261. package/dist/helpers/__tests__/fs.test.js.map +0 -1
  262. package/dist/helpers/__tests__/plist.test.d.ts +0 -1
  263. package/dist/helpers/__tests__/plist.test.js +0 -43
  264. package/dist/helpers/__tests__/plist.test.js.map +0 -1
  265. package/dist/helpers/__tests__/prompt.test.d.ts +0 -1
  266. package/dist/helpers/__tests__/prompt.test.js +0 -71
  267. package/dist/helpers/__tests__/prompt.test.js.map +0 -1
  268. package/dist/helpers/__tests__/retry.test.d.ts +0 -1
  269. package/dist/helpers/__tests__/retry.test.js +0 -99
  270. package/dist/helpers/__tests__/retry.test.js.map +0 -1
  271. package/dist/helpers/__tests__/tags.test.d.ts +0 -1
  272. package/dist/helpers/__tests__/tags.test.js +0 -71
  273. package/dist/helpers/__tests__/tags.test.js.map +0 -1
  274. package/dist/helpers/__tests__/upload.test.d.ts +0 -1
  275. package/dist/helpers/__tests__/upload.test.js +0 -231
  276. package/dist/helpers/__tests__/upload.test.js.map +0 -1
  277. package/dist/helpers/__tests__/user-provided-git.test.d.ts +0 -1
  278. package/dist/helpers/__tests__/user-provided-git.test.js +0 -119
  279. package/dist/helpers/__tests__/user-provided-git.test.js.map +0 -1
  280. package/dist/helpers/__tests__/utils.test.d.ts +0 -1
  281. package/dist/helpers/__tests__/utils.test.js +0 -429
  282. package/dist/helpers/__tests__/utils.test.js.map +0 -1
  283. package/dist/helpers/__tests__/validation.test.d.ts +0 -1
  284. package/dist/helpers/__tests__/validation.test.js +0 -25
  285. package/dist/helpers/__tests__/validation.test.js.map +0 -1
  286. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.d.ts +0 -1
  287. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js +0 -103
  288. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js.map +0 -1
  289. package/dist/helpers/git/__tests__/format-git-span-data.test.d.ts +0 -1
  290. package/dist/helpers/git/__tests__/format-git-span-data.test.js +0 -121
  291. package/dist/helpers/git/__tests__/format-git-span-data.test.js.map +0 -1
  292. package/dist/helpers/git/__tests__/get-git-data.test.d.ts +0 -1
  293. package/dist/helpers/git/__tests__/get-git-data.test.js +0 -72
  294. package/dist/helpers/git/__tests__/get-git-data.test.js.map +0 -1
@@ -1,735 +0,0 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- const fs_1 = __importDefault(require("fs"));
39
- const ciUtils = __importStar(require("../../../helpers/utils"));
40
- const api = __importStar(require("../api"));
41
- const errors_1 = require("../errors");
42
- const interfaces_1 = require("../interfaces");
43
- const default_1 = require("../reporters/default");
44
- const junit_1 = require("../reporters/junit");
45
- const appUploadReporterModule = __importStar(require("../reporters/mobile/app-upload"));
46
- const runTests = __importStar(require("../run-tests-lib"));
47
- const tunnel_1 = require("../tunnel");
48
- const utils = __importStar(require("../utils/public"));
49
- const fixtures_1 = require("./fixtures");
50
- /**
51
- * Parameterize a test to run in both a backwards compatible way, and the new way.
52
- */
53
- // TODO SYNTH-12989: Clean up this parameterization when getting rid of `global` and `config`
54
- const compat = [
55
- {
56
- compat: 'current',
57
- defaultTestOverrides: 'defaultTestOverrides',
58
- testOverrides: 'testOverrides',
59
- },
60
- {
61
- compat: 'deprecated',
62
- defaultTestOverrides: 'global',
63
- testOverrides: 'config',
64
- },
65
- ];
66
- describe('run-test', () => {
67
- beforeEach(() => {
68
- jest.restoreAllMocks();
69
- jest.spyOn(ciUtils, 'getConfig').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return ({}); }));
70
- process.env = {};
71
- });
72
- describe('executeTests', () => {
73
- test('deprecated usage', () => __awaiter(void 0, void 0, void 0, function* () {
74
- jest.spyOn(utils, 'runTests').mockImplementation();
75
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => ({}));
76
- yield expect(runTests.executeTests(fixtures_1.mockReporter, {
77
- apiKey: '',
78
- appKey: '',
79
- configPath: 'datadog-ci.json',
80
- datadogSite: 'datadoghq.com',
81
- failOnCriticalErrors: false,
82
- failOnMissingTests: false,
83
- failOnTimeout: true,
84
- files: ['{,!(node_modules)/**/}*.synthetics.json'],
85
- global: {},
86
- locations: [],
87
- pollingTimeout: 2 * 60 * 1000,
88
- proxy: { protocol: 'http' },
89
- publicIds: [],
90
- selectiveRerun: false,
91
- subdomain: 'app',
92
- tunnel: false,
93
- variableStrings: [], // deprecated
94
- })).rejects.toThrow(new errors_1.CiError('NO_TESTS_TO_RUN'));
95
- }));
96
- test('current usage', () => __awaiter(void 0, void 0, void 0, function* () {
97
- jest.spyOn(utils, 'runTests').mockImplementation();
98
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => ({}));
99
- yield expect(runTests.executeTests(fixtures_1.mockReporter, {
100
- apiKey: '',
101
- appKey: '',
102
- configPath: 'datadog-ci.json',
103
- datadogSite: 'datadoghq.com',
104
- failOnCriticalErrors: false,
105
- failOnMissingTests: false,
106
- failOnTimeout: true,
107
- files: ['{,!(node_modules)/**/}*.synthetics.json'],
108
- defaultTestOverrides: {},
109
- // TODO SYNTH-12989: Clean up deprecated `global` and `locations`
110
- global: {},
111
- locations: [],
112
- pollingTimeout: 2 * 60 * 1000,
113
- proxy: { protocol: 'http' },
114
- publicIds: [],
115
- selectiveRerun: false,
116
- subdomain: 'app',
117
- tunnel: false,
118
- // TODO SYNTH-12989: Clean up deprecated `variableStrings`
119
- variableStrings: [],
120
- })).rejects.toThrow(new errors_1.CiError('NO_TESTS_TO_RUN'));
121
- }));
122
- test.each(compat)('should apply config override for tests triggered by public id ($compat)', ({ defaultTestOverrides }) => __awaiter(void 0, void 0, void 0, function* () {
123
- const getTestsToTriggersMock = jest.spyOn(utils, 'getTestsToTrigger').mockReturnValue(Promise.resolve({
124
- initialSummary: utils.createInitialSummary(),
125
- overriddenTestsToTrigger: [],
126
- tests: [],
127
- }));
128
- jest.spyOn(utils, 'runTests').mockImplementation();
129
- const startUrl = '{{PROTOCOL}}//myhost{{PATHNAME}}{{PARAMS}}';
130
- const locations = ['location1', 'location2'];
131
- const userConfigOverride = { locations, startUrl };
132
- const apiHelper = {};
133
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => ({}));
134
- yield expect(runTests.executeTests(fixtures_1.mockReporter, Object.assign(Object.assign({}, fixtures_1.ciConfig), { [defaultTestOverrides]: userConfigOverride, publicIds: ['aaa-aaa-aaa', 'bbb-bbb-bbb'] }))).rejects.toThrow();
135
- expect(getTestsToTriggersMock).toHaveBeenCalledWith(apiHelper, expect.arrayContaining([
136
- expect.objectContaining({ id: 'aaa-aaa-aaa', testOverrides: userConfigOverride }),
137
- expect.objectContaining({ id: 'bbb-bbb-bbb', testOverrides: userConfigOverride }),
138
- ]), expect.anything(), false, false, false);
139
- }));
140
- test.each([
141
- // TODO SYNTH-12989: Clean up deprecated `global` and `locations`
142
- [
143
- 'locations in global object only (deprecated)',
144
- { global: { locations: ['global-location-1'] } },
145
- { locations: ['global-location-1'] },
146
- ],
147
- [
148
- 'locations at root level only (deprecated)',
149
- { locations: ['envvar-location-1', 'envvar-location-2'] },
150
- { locations: ['envvar-location-1', 'envvar-location-2'] },
151
- ],
152
- [
153
- 'locations in global (deprecated), defaultTestOverrides and at the root level',
154
- {
155
- global: { locations: ['global-location-1'] },
156
- defaultTestOverrides: { locations: ['defaultTestOverrides-location-1'] },
157
- locations: ['envvar-location-1', 'envvar-location-2'],
158
- },
159
- { locations: ['defaultTestOverrides-location-1'] },
160
- ],
161
- [
162
- 'locations in defaultTestOverrides only',
163
- { defaultTestOverrides: { locations: ['defaultTestOverrides-location-1'] } },
164
- { locations: ['defaultTestOverrides-location-1'] },
165
- ],
166
- [
167
- 'locations in both defaultTestOverrides and at the root level',
168
- {
169
- defaultTestOverrides: { locations: ['defaultTestOverrides-location-1'] },
170
- locations: ['envvar-location-1', 'envvar-location-2'],
171
- },
172
- { locations: ['defaultTestOverrides-location-1'] },
173
- ],
174
- ])('Use appropriate list of locations for tests triggered by public id: %s', (text, partialCIConfig, expectedOverriddenConfig) => __awaiter(void 0, void 0, void 0, function* () {
175
- const getTestsToTriggersMock = jest.spyOn(utils, 'getTestsToTrigger').mockReturnValue(Promise.resolve({
176
- initialSummary: utils.createInitialSummary(),
177
- overriddenTestsToTrigger: [],
178
- tests: [],
179
- }));
180
- const apiHelper = {};
181
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => ({}));
182
- yield expect(runTests.executeTests(fixtures_1.mockReporter, Object.assign(Object.assign(Object.assign({}, fixtures_1.ciConfig), partialCIConfig), { publicIds: ['aaa-aaa-aaa', 'bbb-bbb-bbb'] }))).rejects.toThrow(new errors_1.CiError('NO_TESTS_TO_RUN'));
183
- expect(getTestsToTriggersMock).toHaveBeenCalledWith(apiHelper, expect.arrayContaining([
184
- expect.objectContaining({ id: 'aaa-aaa-aaa', testOverrides: expectedOverriddenConfig }),
185
- expect.objectContaining({ id: 'bbb-bbb-bbb', testOverrides: expectedOverriddenConfig }),
186
- ]), expect.anything(), false, false, false);
187
- }));
188
- test.each(compat)('should not wait for `skipped` only tests batch results ($compat)', ({ defaultTestOverrides }) => __awaiter(void 0, void 0, void 0, function* () {
189
- const getTestsToTriggersMock = jest.spyOn(utils, 'getTestsToTrigger').mockReturnValue(Promise.resolve({
190
- initialSummary: utils.createInitialSummary(),
191
- overriddenTestsToTrigger: [],
192
- tests: [],
193
- }));
194
- const apiHelper = {};
195
- const configOverride = { executionRule: interfaces_1.ExecutionRule.SKIPPED };
196
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => ({}));
197
- yield expect(runTests.executeTests(fixtures_1.mockReporter, Object.assign(Object.assign({}, fixtures_1.ciConfig), { [defaultTestOverrides]: configOverride, publicIds: ['aaa-aaa-aaa', 'bbb-bbb-bbb'] }))).rejects.toThrow(new errors_1.CiError('NO_TESTS_TO_RUN'));
198
- expect(getTestsToTriggersMock).toHaveBeenCalledWith(apiHelper, expect.arrayContaining([
199
- expect.objectContaining({ id: 'aaa-aaa-aaa', testOverrides: configOverride }),
200
- expect.objectContaining({ id: 'bbb-bbb-bbb', testOverrides: configOverride }),
201
- ]), expect.anything(), false, false, false);
202
- }));
203
- test.each(compat)('should not open tunnel if no test to run ($compat)', ({ defaultTestOverrides }) => __awaiter(void 0, void 0, void 0, function* () {
204
- const getTestsToTriggersMock = jest.spyOn(utils, 'getTestsToTrigger').mockReturnValue(Promise.resolve({
205
- initialSummary: utils.createInitialSummary(),
206
- overriddenTestsToTrigger: [],
207
- tests: [],
208
- }));
209
- const apiHelper = {
210
- getTunnelPresignedURL: jest.fn(),
211
- };
212
- const configOverride = { executionRule: interfaces_1.ExecutionRule.SKIPPED };
213
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => apiHelper);
214
- yield expect(runTests.executeTests(fixtures_1.mockReporter, Object.assign(Object.assign({}, fixtures_1.ciConfig), { [defaultTestOverrides]: configOverride, publicIds: ['aaa-aaa-aaa', 'bbb-bbb-bbb'], tunnel: true }))).rejects.toThrow(new errors_1.CiError('NO_TESTS_TO_RUN'));
215
- expect(getTestsToTriggersMock).toHaveBeenCalledWith(apiHelper, expect.arrayContaining([
216
- expect.objectContaining({ id: 'aaa-aaa-aaa', testOverrides: configOverride }),
217
- expect.objectContaining({ id: 'bbb-bbb-bbb', testOverrides: configOverride }),
218
- ]), expect.anything(), false, false, true);
219
- expect(apiHelper.getTunnelPresignedURL).not.toHaveBeenCalled();
220
- }));
221
- test('open and close tunnel for successful runs', () => __awaiter(void 0, void 0, void 0, function* () {
222
- jest.spyOn(utils, 'wait').mockImplementation(() => new Promise((res) => setTimeout(res, 10)));
223
- const startTunnelSpy = jest
224
- .spyOn(tunnel_1.Tunnel.prototype, 'start')
225
- .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return ({ host: 'host', id: 'id', privateKey: 'key' }); }));
226
- const stopTunnelSpy = jest.spyOn(tunnel_1.Tunnel.prototype, 'stop');
227
- jest.spyOn(utils, 'getTestsToTrigger').mockReturnValue(Promise.resolve({
228
- initialSummary: utils.createInitialSummary(),
229
- overriddenTestsToTrigger: [],
230
- tests: [{ options: { ci: { executionRule: interfaces_1.ExecutionRule.BLOCKING } }, public_id: '123-456-789' }],
231
- }));
232
- jest.spyOn(utils, 'runTests').mockResolvedValue(fixtures_1.mockTestTriggerResponse);
233
- const apiHelper = {
234
- getBatch: () => ({ results: [] }),
235
- getTunnelPresignedURL: () => ({ url: 'url' }),
236
- pollResults: () => [(0, fixtures_1.getApiResult)('1', (0, fixtures_1.getApiTest)())],
237
- triggerTests: () => fixtures_1.mockTestTriggerResponse,
238
- };
239
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => apiHelper);
240
- yield runTests.executeTests(fixtures_1.mockReporter, Object.assign(Object.assign({}, fixtures_1.ciConfig), { failOnCriticalErrors: true, publicIds: ['123-456-789'], tunnel: true }));
241
- expect(startTunnelSpy).toHaveBeenCalledTimes(1);
242
- expect(stopTunnelSpy).toHaveBeenCalledTimes(1);
243
- }));
244
- const cases = [
245
- [403, 'AUTHORIZATION_ERROR'],
246
- [502, 'UNAVAILABLE_TEST_CONFIG'],
247
- ];
248
- describe.each(cases)('%s triggers %s', (status, error) => {
249
- test(`getTestsList throws - ${status}`, () => __awaiter(void 0, void 0, void 0, function* () {
250
- const apiHelper = {
251
- searchTests: jest.fn(() => {
252
- throw (0, fixtures_1.getAxiosHttpError)(status, { message: 'Server Error' });
253
- }),
254
- };
255
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => apiHelper);
256
- yield expect(runTests.executeTests(fixtures_1.mockReporter, Object.assign(Object.assign({}, fixtures_1.ciConfig), { testSearchQuery: 'a-search-query', tunnel: true }))).rejects.toThrow(new errors_1.CriticalError(error, 'Server Error'));
257
- }));
258
- test(`getTestsToTrigger throws - ${status}`, () => __awaiter(void 0, void 0, void 0, function* () {
259
- const apiHelper = {
260
- getTest: jest.fn(() => {
261
- throw (0, fixtures_1.getAxiosHttpError)(status, { errors: ['Bad Gateway'] });
262
- }),
263
- };
264
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => apiHelper);
265
- yield expect(runTests.executeTests(fixtures_1.mockReporter, Object.assign(Object.assign({}, fixtures_1.ciConfig), { publicIds: ['aaa-aaa-aaa'], tunnel: true }))).rejects.toThrow(new errors_1.CriticalError(error, 'Failed to get test: query on https://app.datadoghq.com/example returned: "Bad Gateway"\n'));
266
- }));
267
- });
268
- test('getTunnelPresignedURL throws', () => __awaiter(void 0, void 0, void 0, function* () {
269
- jest.spyOn(utils, 'getTestsToTrigger').mockReturnValue(Promise.resolve({
270
- initialSummary: utils.createInitialSummary(),
271
- overriddenTestsToTrigger: [],
272
- tests: [{ options: { ci: { executionRule: interfaces_1.ExecutionRule.BLOCKING } }, public_id: 'publicId' }],
273
- }));
274
- const apiHelper = {
275
- getTunnelPresignedURL: jest.fn(() => {
276
- throw (0, fixtures_1.getAxiosHttpError)(502, { message: 'Server Error' });
277
- }),
278
- };
279
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => apiHelper);
280
- yield expect(runTests.executeTests(fixtures_1.mockReporter, Object.assign(Object.assign({}, fixtures_1.ciConfig), { publicIds: ['aaa-aaa-aaa', 'bbb-bbb-bbb'], tunnel: true }))).rejects.toThrow(new errors_1.CriticalError('UNAVAILABLE_TUNNEL_CONFIG', 'Server Error'));
281
- }));
282
- test.each(compat)('getMobileApplicationPresignedURLs throws ($compat)', ({ defaultTestOverrides }) => __awaiter(void 0, void 0, void 0, function* () {
283
- const mobileTest = (0, fixtures_1.getMobileTest)();
284
- jest.spyOn(utils, 'getTestAndOverrideConfig').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
285
- return Promise.resolve({
286
- overriddenConfig: { executionRule: interfaces_1.ExecutionRule.NON_BLOCKING, public_id: mobileTest.public_id },
287
- test: mobileTest,
288
- });
289
- }));
290
- // use /dev/null to create a valid empty fs.ReadStream
291
- const testStream = fs_1.default.createReadStream('/dev/null');
292
- jest.spyOn(fs_1.default, 'createReadStream').mockReturnValue(testStream);
293
- const { AppUploadReporter } = jest.requireActual('../reporters/mobile/app-upload');
294
- jest
295
- .spyOn(appUploadReporterModule, 'AppUploadReporter')
296
- .mockImplementation(() => new AppUploadReporter({ stdout: { write: jest.fn() } }));
297
- const apiHelper = {
298
- getMobileApplicationPresignedURLs: jest.fn(() => {
299
- throw (0, fixtures_1.getAxiosHttpError)(502, { message: 'Server Error' });
300
- }),
301
- };
302
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => apiHelper);
303
- yield expect(runTests.executeTests(fixtures_1.mockReporter, Object.assign(Object.assign({}, fixtures_1.ciConfig), { [defaultTestOverrides]: { mobileApplicationVersionFilePath: 'filePath' }, publicIds: [mobileTest.public_id] }))).rejects.toThrow('Failed to get presigned URL: could not query https://app.datadoghq.com/example');
304
- }));
305
- test.each(compat)('uploadMobileApplicationPart throws ($compat)', ({ defaultTestOverrides }) => __awaiter(void 0, void 0, void 0, function* () {
306
- const mobileTest = (0, fixtures_1.getMobileTest)();
307
- jest.spyOn(utils, 'getTestAndOverrideConfig').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
308
- return Promise.resolve({
309
- overriddenConfig: { executionRule: interfaces_1.ExecutionRule.NON_BLOCKING, public_id: mobileTest.public_id },
310
- test: mobileTest,
311
- });
312
- }));
313
- // use /dev/null to create a valid empty fs.ReadStream
314
- const testStream = fs_1.default.createReadStream('/dev/null');
315
- jest.spyOn(fs_1.default, 'createReadStream').mockReturnValue(testStream);
316
- const { AppUploadReporter } = jest.requireActual('../reporters/mobile/app-upload');
317
- jest
318
- .spyOn(appUploadReporterModule, 'AppUploadReporter')
319
- .mockImplementation(() => new AppUploadReporter({ stdout: { write: jest.fn() } }));
320
- jest.spyOn(fs_1.default.promises, 'readFile').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return Buffer.from('aa'); }));
321
- const apiHelper = {
322
- getMobileApplicationPresignedURLs: jest.fn(() => fixtures_1.MOBILE_PRESIGNED_URLS_PAYLOAD),
323
- uploadMobileApplicationPart: jest.fn(() => {
324
- throw (0, fixtures_1.getAxiosHttpError)(502, { message: 'Server Error' });
325
- }),
326
- };
327
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => apiHelper);
328
- yield expect(runTests.executeTests(fixtures_1.mockReporter, Object.assign(Object.assign({}, fixtures_1.ciConfig), { [defaultTestOverrides]: { mobileApplicationVersionFilePath: 'filePath' }, publicIds: [mobileTest.public_id] }))).rejects.toThrow('Failed to upload mobile application: could not query https://app.datadoghq.com/example');
329
- }));
330
- test('runTests throws', () => __awaiter(void 0, void 0, void 0, function* () {
331
- jest
332
- .spyOn(tunnel_1.Tunnel.prototype, 'start')
333
- .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return ({ host: 'host', id: 'id', privateKey: 'key' }); }));
334
- const stopTunnelSpy = jest.spyOn(tunnel_1.Tunnel.prototype, 'stop');
335
- jest.spyOn(utils, 'getTestsToTrigger').mockReturnValue(Promise.resolve({
336
- initialSummary: utils.createInitialSummary(),
337
- overriddenTestsToTrigger: [],
338
- tests: [{ options: { ci: { executionRule: interfaces_1.ExecutionRule.BLOCKING } }, public_id: 'publicId' }],
339
- }));
340
- const apiHelper = {
341
- getTunnelPresignedURL: () => ({ url: 'url' }),
342
- triggerTests: jest.fn(() => {
343
- throw (0, fixtures_1.getAxiosHttpError)(502, { errors: ['Bad Gateway'] });
344
- }),
345
- };
346
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => apiHelper);
347
- yield expect(runTests.executeTests(fixtures_1.mockReporter, Object.assign(Object.assign({}, fixtures_1.ciConfig), { publicIds: ['aaa-aaa-aaa', 'bbb-bbb-bbb'], tunnel: true }))).rejects.toThrow(new errors_1.CriticalError('TRIGGER_TESTS_FAILED', '[] Failed to trigger tests: query on https://app.datadoghq.com/example returned: "Bad Gateway"\n'));
348
- expect(stopTunnelSpy).toHaveBeenCalledTimes(1);
349
- }));
350
- test('waitForResults throws', () => __awaiter(void 0, void 0, void 0, function* () {
351
- const location = {
352
- display_name: 'us1',
353
- id: 1,
354
- is_active: true,
355
- name: 'us1',
356
- region: 'us1',
357
- };
358
- jest
359
- .spyOn(tunnel_1.Tunnel.prototype, 'start')
360
- .mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () { return ({ host: 'host', id: 'id', privateKey: 'key' }); }));
361
- const stopTunnelSpy = jest.spyOn(tunnel_1.Tunnel.prototype, 'stop');
362
- jest.spyOn(utils, 'getTestsToTrigger').mockReturnValue(Promise.resolve({
363
- initialSummary: utils.createInitialSummary(),
364
- overriddenTestsToTrigger: [],
365
- tests: [{ options: { ci: { executionRule: interfaces_1.ExecutionRule.BLOCKING } }, public_id: 'publicId' }],
366
- }));
367
- jest.spyOn(utils, 'runTests').mockReturnValue(Promise.resolve({
368
- batch_id: 'bid',
369
- locations: [location],
370
- }));
371
- const apiHelper = {
372
- getBatch: () => ({ results: [] }),
373
- getTunnelPresignedURL: () => ({ url: 'url' }),
374
- pollResults: jest.fn(() => {
375
- throw (0, fixtures_1.getAxiosHttpError)(502, { errors: ['Bad Gateway'] });
376
- }),
377
- };
378
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => apiHelper);
379
- yield expect(runTests.executeTests(fixtures_1.mockReporter, Object.assign(Object.assign({}, fixtures_1.ciConfig), { failOnCriticalErrors: true, publicIds: ['aaa-aaa-aaa', 'bbb-bbb-bbb'], tunnel: true }))).rejects.toThrow(new errors_1.CriticalError('POLL_RESULTS_FAILED', 'Failed to poll results: query on https://app.datadoghq.com/example returned: "Bad Gateway"\n'));
380
- expect(stopTunnelSpy).toHaveBeenCalledTimes(1);
381
- }));
382
- test('log when selective re-run is rate-limited', () => __awaiter(void 0, void 0, void 0, function* () {
383
- jest.spyOn(utils, 'getTestsToTrigger').mockReturnValue(Promise.resolve({
384
- initialSummary: utils.createInitialSummary(),
385
- overriddenTestsToTrigger: [],
386
- tests: [{ options: { ci: { executionRule: interfaces_1.ExecutionRule.BLOCKING } }, public_id: 'aaa-aaa-aaa' }],
387
- }));
388
- jest.spyOn(utils, 'runTests').mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
389
- return ({
390
- batch_id: 'bid',
391
- locations: [],
392
- selective_rerun_rate_limited: true,
393
- });
394
- }));
395
- const apiHelper = {
396
- getBatch: () => ({ results: [] }),
397
- getTunnelPresignedURL: () => ({ url: 'url' }),
398
- pollResults: () => [(0, fixtures_1.getApiResult)('1', (0, fixtures_1.getApiTest)())],
399
- triggerTests: () => fixtures_1.mockTestTriggerResponse,
400
- };
401
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => apiHelper);
402
- yield runTests.executeTests(fixtures_1.mockReporter, Object.assign(Object.assign({}, fixtures_1.ciConfig), { publicIds: ['aaa-aaa-aaa'] }));
403
- expect(fixtures_1.mockReporter.error).toHaveBeenCalledWith('The selective re-run feature was rate-limited. All tests will be re-run.\n\n');
404
- }));
405
- });
406
- describe('executeWithDetails', () => {
407
- beforeEach(() => {
408
- jest.restoreAllMocks();
409
- jest.spyOn(api, 'getApiHelper').mockImplementation(() => ({
410
- getSyntheticsOrgSettings: () => ({
411
- onDemandConcurrencyCap: 1,
412
- }),
413
- }));
414
- jest.spyOn(runTests, 'executeTests').mockReturnValue(Promise.resolve({ results: [], summary: {} }));
415
- jest.spyOn(utils, 'renderResults').mockImplementation(jest.fn());
416
- });
417
- test('should call executeTests and renderResults', () => __awaiter(void 0, void 0, void 0, function* () {
418
- yield runTests.executeWithDetails({}, {});
419
- expect(runTests.executeTests).toHaveBeenCalled();
420
- expect(utils.renderResults).toHaveBeenCalled();
421
- }));
422
- test('should extend config', () => __awaiter(void 0, void 0, void 0, function* () {
423
- const runConfig = { apiKey: 'apiKey', appKey: 'appKey' };
424
- yield runTests.executeWithDetails(runConfig, {});
425
- expect(runTests.executeTests).toHaveBeenCalledWith(expect.anything(), expect.objectContaining(runConfig), undefined);
426
- }));
427
- test('should bypass files if suite is passed', () => __awaiter(void 0, void 0, void 0, function* () {
428
- const suites = [{ content: { tests: [] } }];
429
- yield runTests.executeWithDetails({}, { suites });
430
- expect(runTests.executeTests).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ files: [] }), suites);
431
- }));
432
- test('should return values returned by executeTests, and an exitCode', () => __awaiter(void 0, void 0, void 0, function* () {
433
- const returnValue = yield runTests.executeWithDetails({}, {});
434
- expect(returnValue.results).toBeDefined();
435
- expect(returnValue.summary).toBeDefined();
436
- expect(returnValue.exitCode).toBeDefined();
437
- }));
438
- describe('reporters', () => {
439
- beforeEach(() => {
440
- jest.spyOn(utils, 'getReporter').mockImplementation(jest.fn());
441
- });
442
- test('should use default reporter with empty config', () => __awaiter(void 0, void 0, void 0, function* () {
443
- yield runTests.executeWithDetails({}, {});
444
- expect(utils.getReporter).toHaveBeenCalledWith(expect.arrayContaining([expect.any(default_1.DefaultReporter)]));
445
- }));
446
- test('should use custom reporters', () => __awaiter(void 0, void 0, void 0, function* () {
447
- const CustomReporter = {};
448
- yield runTests.executeWithDetails({}, { reporters: ['junit', CustomReporter] });
449
- expect(utils.getReporter).toHaveBeenCalledWith(expect.arrayContaining([expect.any(junit_1.JUnitReporter), CustomReporter]));
450
- }));
451
- });
452
- });
453
- describe('execute', () => {
454
- beforeEach(() => {
455
- jest.restoreAllMocks();
456
- jest
457
- .spyOn(runTests, 'executeWithDetails')
458
- .mockReturnValue(Promise.resolve({ results: [], summary: {}, exitCode: 0 }));
459
- });
460
- test('should call executeWithDetails', () => __awaiter(void 0, void 0, void 0, function* () {
461
- yield runTests.execute({}, {});
462
- expect(runTests.executeWithDetails).toHaveBeenCalled();
463
- }));
464
- test('should return the exitCode returned by executeWithDetails', () => __awaiter(void 0, void 0, void 0, function* () {
465
- const returnValue = yield runTests.execute({}, {});
466
- expect(returnValue).toBe(0);
467
- }));
468
- });
469
- describe('getTriggerConfigs', () => {
470
- beforeEach(() => {
471
- jest.restoreAllMocks();
472
- });
473
- const startUrl = 'fakeUrl';
474
- const locations = ['aws:ap-northeast-1'];
475
- const conf1 = {
476
- tests: [{ testOverrides: { deviceIds: ['chrome.laptop_large'] }, id: 'abc-def-ghi' }],
477
- };
478
- const conf2 = {
479
- tests: [{ testOverrides: { startUrl: 'someOtherFakeUrl' }, id: 'jkl-mno-pqr' }],
480
- };
481
- // TODO SYNTH-12989: Clean up deprecated `config` in favor of `testOverrides`
482
- // The following two cases are testing the behavior while we're migrating from config to testOverrides
483
- const conf3 = {
484
- tests: [{ config: { startUrl: 'someOtherFakeUrl' }, id: 'jkl-mno-pq1' }],
485
- };
486
- const conf4 = {
487
- tests: [{ config: { startUrl: 'someOtherFakeUrl' }, testOverrides: { startUrl: 'theFakestUrl' }, id: 'jkl-mno-pq2' }],
488
- };
489
- const fakeSuites = [
490
- {
491
- content: conf1,
492
- name: 'Suite 1',
493
- },
494
- {
495
- content: conf2,
496
- name: 'Suite 2',
497
- },
498
- {
499
- content: conf3,
500
- name: 'Suite 3',
501
- },
502
- {
503
- content: conf4,
504
- name: 'Suite 4',
505
- },
506
- ];
507
- const fakeApi = {
508
- searchTests: () => ({
509
- tests: [
510
- {
511
- public_id: 'stu-vwx-yza',
512
- },
513
- ],
514
- }),
515
- };
516
- test('should extend global config and execute all tests from test config files when no clue what to run', () => __awaiter(void 0, void 0, void 0, function* () {
517
- const getSuitesMock = jest.spyOn(utils, 'getSuites').mockImplementation((() => fakeSuites));
518
- const defaultTestOverrides = { locations, startUrl };
519
- yield expect(runTests.getTriggerConfigs(fakeApi, Object.assign(Object.assign({}, fixtures_1.ciConfig), { defaultTestOverrides }), fixtures_1.mockReporter)).resolves.toEqual([
520
- {
521
- testOverrides: { deviceIds: ['chrome.laptop_large'], startUrl, locations },
522
- id: 'abc-def-ghi',
523
- suite: 'Suite 1',
524
- },
525
- {
526
- testOverrides: { startUrl: 'someOtherFakeUrl', locations },
527
- id: 'jkl-mno-pqr',
528
- suite: 'Suite 2',
529
- },
530
- {
531
- testOverrides: { startUrl: 'someOtherFakeUrl', locations },
532
- id: 'jkl-mno-pq1',
533
- suite: 'Suite 3',
534
- },
535
- {
536
- testOverrides: { startUrl: 'theFakestUrl', locations },
537
- id: 'jkl-mno-pq2',
538
- suite: 'Suite 4',
539
- },
540
- ]);
541
- expect(getSuitesMock).toHaveBeenCalledTimes(1);
542
- expect(getSuitesMock).toHaveBeenCalledWith('{,!(node_modules)/**/}*.synthetics.json', fixtures_1.mockReporter);
543
- }));
544
- test('should override and execute only publicIds that were defined in the global config', () => __awaiter(void 0, void 0, void 0, function* () {
545
- const getSuitesMock = jest.spyOn(utils, 'getSuites');
546
- const defaultTestOverrides = { locations, startUrl };
547
- yield expect(runTests.getTriggerConfigs(fakeApi, Object.assign(Object.assign({}, fixtures_1.ciConfig), { defaultTestOverrides, publicIds: ['abc-def-ghi', '123-456-789'] }), fixtures_1.mockReporter)).resolves.toEqual([
548
- {
549
- testOverrides: { startUrl, locations },
550
- id: 'abc-def-ghi',
551
- },
552
- {
553
- testOverrides: { startUrl, locations },
554
- id: '123-456-789',
555
- },
556
- ]);
557
- expect(getSuitesMock).toHaveBeenCalledTimes(0);
558
- }));
559
- test('should override and execute only publicIds that were defined in the global config and use given globs', () => __awaiter(void 0, void 0, void 0, function* () {
560
- const getSuitesMock = jest.spyOn(utils, 'getSuites').mockImplementation((() => fakeSuites));
561
- const defaultTestOverrides = { locations, startUrl };
562
- const files = ['glob'];
563
- yield expect(runTests.getTriggerConfigs(fakeApi, Object.assign(Object.assign({}, fixtures_1.ciConfig), { defaultTestOverrides,
564
- files, publicIds: ['abc-def-ghi'] }), fixtures_1.mockReporter)).resolves.toEqual([
565
- {
566
- testOverrides: { startUrl, locations, deviceIds: ['chrome.laptop_large'] },
567
- id: 'abc-def-ghi',
568
- suite: 'Suite 1',
569
- },
570
- ]);
571
- expect(getSuitesMock).toHaveBeenCalledTimes(1);
572
- expect(getSuitesMock).toHaveBeenCalledWith('glob', fixtures_1.mockReporter);
573
- }));
574
- test('should search tests and extend global config', () => __awaiter(void 0, void 0, void 0, function* () {
575
- const getSuitesMock = jest.spyOn(utils, 'getSuites');
576
- const defaultTestOverrides = { locations, startUrl };
577
- const searchQuery = 'fake search';
578
- yield expect(runTests.getTriggerConfigs(fakeApi, Object.assign(Object.assign({}, fixtures_1.ciConfig), { defaultTestOverrides, testSearchQuery: searchQuery }), fixtures_1.mockReporter)).resolves.toEqual([
579
- {
580
- testOverrides: { locations, startUrl },
581
- id: 'stu-vwx-yza',
582
- suite: 'Query: fake search',
583
- },
584
- ]);
585
- expect(getSuitesMock).toHaveBeenCalledTimes(0);
586
- }));
587
- test('should not use testSearchQuery if global config has defined publicIds', () => __awaiter(void 0, void 0, void 0, function* () {
588
- const defaultTestOverrides = { startUrl };
589
- const searchQuery = 'fake search';
590
- yield expect(runTests.getTriggerConfigs(fakeApi, Object.assign(Object.assign({}, fixtures_1.ciConfig), { defaultTestOverrides, publicIds: ['abc-def-ghi'], testSearchQuery: searchQuery }), fixtures_1.mockReporter)).resolves.toEqual([
591
- {
592
- testOverrides: { startUrl },
593
- id: 'abc-def-ghi',
594
- },
595
- ]);
596
- }));
597
- test('should search tests with testSearchQuery and use given globs', () => __awaiter(void 0, void 0, void 0, function* () {
598
- const getSuitesMock = jest.spyOn(utils, 'getSuites').mockImplementation((() => fakeSuites));
599
- const defaultTestOverrides = { startUrl };
600
- const searchQuery = 'fake search';
601
- const files = ['glob'];
602
- yield expect(runTests.getTriggerConfigs(fakeApi, Object.assign(Object.assign({}, fixtures_1.ciConfig), { defaultTestOverrides,
603
- files, testSearchQuery: searchQuery }), fixtures_1.mockReporter)).resolves.toEqual([
604
- {
605
- testOverrides: { startUrl },
606
- id: 'stu-vwx-yza',
607
- suite: 'Query: fake search',
608
- },
609
- ]);
610
- expect(getSuitesMock).toHaveBeenCalledTimes(1);
611
- expect(getSuitesMock).toHaveBeenCalledWith('glob', fixtures_1.mockReporter);
612
- }));
613
- test('should use given globs to get tests list', () => __awaiter(void 0, void 0, void 0, function* () {
614
- const getSuitesMock = jest.spyOn(utils, 'getSuites').mockImplementation((() => fakeSuites));
615
- const defaultTestOverrides = { startUrl };
616
- const files = ['new glob', 'another one'];
617
- yield runTests.getTriggerConfigs(fakeApi, Object.assign(Object.assign({}, fixtures_1.ciConfig), { defaultTestOverrides, files }), fixtures_1.mockReporter);
618
- expect(getSuitesMock).toHaveBeenCalledTimes(2);
619
- expect(getSuitesMock).toHaveBeenCalledWith('new glob', fixtures_1.mockReporter);
620
- expect(getSuitesMock).toHaveBeenCalledWith('another one', fixtures_1.mockReporter);
621
- }));
622
- test('should return tests from provided suites with overrides', () => __awaiter(void 0, void 0, void 0, function* () {
623
- const getSuitesMock = jest.spyOn(utils, 'getSuites');
624
- const defaultTestOverrides = { startUrl };
625
- const files = [];
626
- const tests = yield runTests.getTriggerConfigs(fakeApi, Object.assign(Object.assign({}, fixtures_1.ciConfig), { defaultTestOverrides, files }), fixtures_1.mockReporter, fakeSuites);
627
- expect(tests).toEqual([
628
- {
629
- testOverrides: { deviceIds: ['chrome.laptop_large'], startUrl },
630
- id: conf1.tests[0].id,
631
- suite: fakeSuites[0].name,
632
- },
633
- { testOverrides: { startUrl: 'someOtherFakeUrl' }, id: conf2.tests[0].id, suite: fakeSuites[1].name },
634
- { testOverrides: { startUrl: 'someOtherFakeUrl' }, id: conf3.tests[0].id, suite: fakeSuites[2].name },
635
- { testOverrides: { startUrl: 'theFakestUrl' }, id: conf4.tests[0].id, suite: fakeSuites[3].name },
636
- ]);
637
- expect(getSuitesMock).toHaveBeenCalledTimes(0);
638
- }));
639
- test('should merge getSuites and user provided suites', () => __awaiter(void 0, void 0, void 0, function* () {
640
- const userSuites = [fakeSuites[0]];
641
- const globSuites = [fakeSuites[1]];
642
- const getSuitesMock = jest.spyOn(utils, 'getSuites').mockImplementation((() => globSuites));
643
- const defaultTestOverrides = { startUrl };
644
- const files = ['glob'];
645
- const tests = yield runTests.getTriggerConfigs(fakeApi, Object.assign(Object.assign({}, fixtures_1.ciConfig), { defaultTestOverrides, files }), fixtures_1.mockReporter, userSuites);
646
- expect(tests).toEqual([
647
- {
648
- testOverrides: { deviceIds: ['chrome.laptop_large'], startUrl },
649
- id: conf1.tests[0].id,
650
- suite: fakeSuites[0].name,
651
- },
652
- { testOverrides: { startUrl: 'someOtherFakeUrl' }, id: conf2.tests[0].id, suite: fakeSuites[1].name },
653
- ]);
654
- expect(getSuitesMock).toHaveBeenCalledTimes(1);
655
- expect(getSuitesMock).toHaveBeenCalledWith('glob', fixtures_1.mockReporter);
656
- }));
657
- test('should handle test configurations with the same test ID correctly', () => __awaiter(void 0, void 0, void 0, function* () {
658
- const conf5 = {
659
- tests: [
660
- {
661
- id: 'abc-abc-abc',
662
- testOverrides: {
663
- allowInsecureCertificates: true,
664
- basicAuth: { username: 'test', password: 'test' },
665
- body: '{"fakeContent":true}',
666
- bodyType: 'application/json',
667
- cookies: 'name1=value1;name2=value2;',
668
- defaultStepTimeout: 15,
669
- deviceIds: ['chrome.laptop_large'],
670
- executionRule: 'non-blocking',
671
- followRedirects: true,
672
- headers: { NEW_HEADER: 'NEW VALUE' },
673
- locations: ['aws:us-east-1'],
674
- mobileApplicationVersion: '01234567-8888-9999-abcd-efffffffffff',
675
- mobileApplicationVersionFilePath: 'path/to/application.apk',
676
- pollingTimeout: 30000,
677
- retry: { count: 2, interval: 300 },
678
- testTimeout: 300,
679
- variables: { MY_VARIABLE: 'new title' },
680
- },
681
- },
682
- {
683
- id: 'abc-abc-abc',
684
- testOverrides: {
685
- executionRule: 'skipped',
686
- },
687
- },
688
- ],
689
- };
690
- jest.spyOn(utils, 'getSuites').mockImplementation((() => [
691
- {
692
- content: conf5,
693
- name: 'Suite with duplicate IDs',
694
- },
695
- ]));
696
- const defaultTestOverrides = { locations: ['aws:us-east-1'], startUrl: 'fakeUrl' };
697
- yield expect(runTests.getTriggerConfigs(fakeApi, Object.assign(Object.assign({}, fixtures_1.ciConfig), { defaultTestOverrides }), fixtures_1.mockReporter)).resolves.toEqual([
698
- {
699
- testOverrides: {
700
- allowInsecureCertificates: true,
701
- basicAuth: { username: 'test', password: 'test' },
702
- body: '{"fakeContent":true}',
703
- bodyType: 'application/json',
704
- cookies: 'name1=value1;name2=value2;',
705
- defaultStepTimeout: 15,
706
- deviceIds: ['chrome.laptop_large'],
707
- executionRule: 'non-blocking',
708
- followRedirects: true,
709
- headers: { NEW_HEADER: 'NEW VALUE' },
710
- locations: ['aws:us-east-1'],
711
- mobileApplicationVersion: '01234567-8888-9999-abcd-efffffffffff',
712
- mobileApplicationVersionFilePath: 'path/to/application.apk',
713
- pollingTimeout: 30000,
714
- retry: { count: 2, interval: 300 },
715
- testTimeout: 300,
716
- variables: { MY_VARIABLE: 'new title' },
717
- startUrl: 'fakeUrl',
718
- },
719
- id: 'abc-abc-abc',
720
- suite: 'Suite with duplicate IDs',
721
- },
722
- {
723
- testOverrides: {
724
- executionRule: 'skipped',
725
- startUrl: 'fakeUrl',
726
- locations: ['aws:us-east-1'],
727
- },
728
- id: 'abc-abc-abc',
729
- suite: 'Suite with duplicate IDs',
730
- },
731
- ]);
732
- }));
733
- });
734
- });
735
- //# sourceMappingURL=run-tests-lib.test.js.map