@datadog/datadog-ci 3.4.0 → 3.6.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 (397) hide show
  1. package/dist/cli.js.map +1 -1
  2. package/dist/commands/cloud-run/flare.js +14 -14
  3. package/dist/commands/cloud-run/flare.js.map +1 -1
  4. package/dist/commands/coverage/api.js +10 -0
  5. package/dist/commands/coverage/api.js.map +1 -1
  6. package/dist/commands/coverage/interfaces.d.ts +3 -0
  7. package/dist/commands/coverage/renderer.js +2 -2
  8. package/dist/commands/coverage/renderer.js.map +1 -1
  9. package/dist/commands/coverage/upload.d.ts +3 -0
  10. package/dist/commands/coverage/upload.js +59 -12
  11. package/dist/commands/coverage/upload.js.map +1 -1
  12. package/dist/commands/coverage/utils.js +2 -2
  13. package/dist/commands/coverage/utils.js.map +1 -1
  14. package/dist/commands/dsyms/renderer.js +3 -3
  15. package/dist/commands/dsyms/renderer.js.map +1 -1
  16. package/dist/commands/dsyms/upload.js +9 -9
  17. package/dist/commands/dsyms/upload.js.map +1 -1
  18. package/dist/commands/dsyms/utils.js +4 -4
  19. package/dist/commands/dsyms/utils.js.map +1 -1
  20. package/dist/commands/elf-symbols/upload.js +4 -4
  21. package/dist/commands/elf-symbols/upload.js.map +1 -1
  22. package/dist/commands/flutter-symbols/helpers.js +5 -25
  23. package/dist/commands/flutter-symbols/helpers.js.map +1 -1
  24. package/dist/commands/flutter-symbols/upload.js +2 -2
  25. package/dist/commands/flutter-symbols/upload.js.map +1 -1
  26. package/dist/commands/gate/renderer.js +1 -1
  27. package/dist/commands/gate/renderer.js.map +1 -1
  28. package/dist/commands/git-metadata/git.d.ts +6 -0
  29. package/dist/commands/git-metadata/git.js +74 -2
  30. package/dist/commands/git-metadata/git.js.map +1 -1
  31. package/dist/commands/git-metadata/gitdb.js +4 -4
  32. package/dist/commands/git-metadata/gitdb.js.map +1 -1
  33. package/dist/commands/junit/api.js +2 -2
  34. package/dist/commands/junit/api.js.map +1 -1
  35. package/dist/commands/junit/renderer.js +2 -2
  36. package/dist/commands/junit/renderer.js.map +1 -1
  37. package/dist/commands/junit/upload.js +7 -7
  38. package/dist/commands/junit/upload.js.map +1 -1
  39. package/dist/commands/lambda/flare.js +18 -18
  40. package/dist/commands/lambda/flare.js.map +1 -1
  41. package/dist/commands/pe-symbols/upload.js +2 -3
  42. package/dist/commands/pe-symbols/upload.js.map +1 -1
  43. package/dist/commands/react-native/xcode.js +1 -2
  44. package/dist/commands/react-native/xcode.js.map +1 -1
  45. package/dist/commands/sarif/renderer.js +3 -3
  46. package/dist/commands/sarif/renderer.js.map +1 -1
  47. package/dist/commands/sarif/upload.js +5 -6
  48. package/dist/commands/sarif/upload.js.map +1 -1
  49. package/dist/commands/sourcemaps/upload.js +4 -5
  50. package/dist/commands/sourcemaps/upload.js.map +1 -1
  51. package/dist/commands/sourcemaps/utils.js +2 -2
  52. package/dist/commands/sourcemaps/utils.js.map +1 -1
  53. package/dist/commands/synthetics/api.d.ts +1 -1
  54. package/dist/commands/synthetics/api.js +40 -12
  55. package/dist/commands/synthetics/api.js.map +1 -1
  56. package/dist/commands/synthetics/base-command.d.ts +1 -1
  57. package/dist/commands/synthetics/base-command.js +12 -7
  58. package/dist/commands/synthetics/base-command.js.map +1 -1
  59. package/dist/commands/synthetics/batch.js +12 -11
  60. package/dist/commands/synthetics/batch.js.map +1 -1
  61. package/dist/commands/synthetics/build-and-test.d.ts +1 -1
  62. package/dist/commands/synthetics/build-and-test.js +11 -31
  63. package/dist/commands/synthetics/build-and-test.js.map +1 -1
  64. package/dist/commands/synthetics/deploy-tests-command.d.ts +1 -1
  65. package/dist/commands/synthetics/deploy-tests-command.js +8 -11
  66. package/dist/commands/synthetics/deploy-tests-command.js.map +1 -1
  67. package/dist/commands/synthetics/import-tests-command.js +10 -9
  68. package/dist/commands/synthetics/import-tests-command.js.map +1 -1
  69. package/dist/commands/synthetics/interfaces.d.ts +71 -35
  70. package/dist/commands/synthetics/interfaces.js.map +1 -1
  71. package/dist/commands/synthetics/multilocator.js +2 -2
  72. package/dist/commands/synthetics/multilocator.js.map +1 -1
  73. package/dist/commands/synthetics/reporters/default.js +10 -9
  74. package/dist/commands/synthetics/reporters/default.js.map +1 -1
  75. package/dist/commands/synthetics/reporters/junit.js +74 -63
  76. package/dist/commands/synthetics/reporters/junit.js.map +1 -1
  77. package/dist/commands/synthetics/run-tests-command.js +26 -18
  78. package/dist/commands/synthetics/run-tests-command.js.map +1 -1
  79. package/dist/commands/synthetics/test.d.ts +2 -2
  80. package/dist/commands/synthetics/upload-application-command.d.ts +1 -1
  81. package/dist/commands/synthetics/upload-application-command.js +19 -5
  82. package/dist/commands/synthetics/upload-application-command.js.map +1 -1
  83. package/dist/commands/synthetics/utils/internal.d.ts +3 -3
  84. package/dist/commands/synthetics/utils/internal.js +1 -2
  85. package/dist/commands/synthetics/utils/internal.js.map +1 -1
  86. package/dist/commands/synthetics/utils/public.d.ts +4 -4
  87. package/dist/commands/synthetics/utils/public.js +22 -11
  88. package/dist/commands/synthetics/utils/public.js.map +1 -1
  89. package/dist/commands/trace/test-utils.d.ts +4 -1
  90. package/dist/commands/trace/test-utils.js.map +1 -1
  91. package/dist/commands/unity-symbols/renderer.js +1 -1
  92. package/dist/commands/unity-symbols/upload.js +7 -7
  93. package/dist/commands/unity-symbols/upload.js.map +1 -1
  94. package/dist/helpers/ci.d.ts +1 -0
  95. package/dist/helpers/ci.js +3 -2
  96. package/dist/helpers/ci.js.map +1 -1
  97. package/dist/helpers/file-finder.js +3 -3
  98. package/dist/helpers/file-finder.js.map +1 -1
  99. package/dist/helpers/flare.js +4 -4
  100. package/dist/helpers/flare.js.map +1 -1
  101. package/dist/helpers/fs.js +3 -3
  102. package/dist/helpers/fs.js.map +1 -1
  103. package/dist/helpers/glob.d.ts +12 -0
  104. package/dist/helpers/glob.js +70 -0
  105. package/dist/helpers/glob.js.map +1 -0
  106. package/dist/helpers/interfaces.d.ts +7 -8
  107. package/dist/helpers/renderer.js +3 -3
  108. package/dist/helpers/renderer.js.map +1 -1
  109. package/dist/helpers/tags.d.ts +1 -0
  110. package/dist/helpers/tags.js +6 -4
  111. package/dist/helpers/tags.js.map +1 -1
  112. package/dist/helpers/utils.d.ts +5 -1
  113. package/dist/helpers/utils.js +6 -12
  114. package/dist/helpers/utils.js.map +1 -1
  115. package/package.json +6 -5
  116. package/dist/__tests__/cli.test.d.ts +0 -1
  117. package/dist/__tests__/cli.test.js +0 -93
  118. package/dist/__tests__/cli.test.js.map +0 -1
  119. package/dist/commands/cloud-run/__tests__/fixtures.d.ts +0 -2
  120. package/dist/commands/cloud-run/__tests__/fixtures.js +0 -12
  121. package/dist/commands/cloud-run/__tests__/fixtures.js.map +0 -1
  122. package/dist/commands/cloud-run/__tests__/flare.test.d.ts +0 -1
  123. package/dist/commands/cloud-run/__tests__/flare.test.js +0 -557
  124. package/dist/commands/cloud-run/__tests__/flare.test.js.map +0 -1
  125. package/dist/commands/coverage/__tests__/upload.test.d.ts +0 -1
  126. package/dist/commands/coverage/__tests__/upload.test.js +0 -291
  127. package/dist/commands/coverage/__tests__/upload.test.js.map +0 -1
  128. package/dist/commands/coverage/__tests__/utils.test.d.ts +0 -1
  129. package/dist/commands/coverage/__tests__/utils.test.js +0 -47
  130. package/dist/commands/coverage/__tests__/utils.test.js.map +0 -1
  131. package/dist/commands/deployment/__tests__/correlate.test.d.ts +0 -1
  132. package/dist/commands/deployment/__tests__/correlate.test.js +0 -106
  133. package/dist/commands/deployment/__tests__/correlate.test.js.map +0 -1
  134. package/dist/commands/deployment/__tests__/mark.test.d.ts +0 -1
  135. package/dist/commands/deployment/__tests__/mark.test.js +0 -97
  136. package/dist/commands/deployment/__tests__/mark.test.js.map +0 -1
  137. package/dist/commands/dora/__tests__/deployment.test.d.ts +0 -1
  138. package/dist/commands/dora/__tests__/deployment.test.js +0 -203
  139. package/dist/commands/dora/__tests__/deployment.test.js.map +0 -1
  140. package/dist/commands/dsyms/__tests__/upload.test.d.ts +0 -1
  141. package/dist/commands/dsyms/__tests__/upload.test.js +0 -346
  142. package/dist/commands/dsyms/__tests__/upload.test.js.map +0 -1
  143. package/dist/commands/dsyms/__tests__/utils.test.d.ts +0 -1
  144. package/dist/commands/dsyms/__tests__/utils.test.js +0 -100
  145. package/dist/commands/dsyms/__tests__/utils.test.js.map +0 -1
  146. package/dist/commands/elf-symbols/__tests__/elf.test.d.ts +0 -1
  147. package/dist/commands/elf-symbols/__tests__/elf.test.js +0 -822
  148. package/dist/commands/elf-symbols/__tests__/elf.test.js.map +0 -1
  149. package/dist/commands/elf-symbols/__tests__/upload.test.d.ts +0 -1
  150. package/dist/commands/elf-symbols/__tests__/upload.test.js +0 -228
  151. package/dist/commands/elf-symbols/__tests__/upload.test.js.map +0 -1
  152. package/dist/commands/flutter-symbols/__tests__/upload.test.d.ts +0 -1
  153. package/dist/commands/flutter-symbols/__tests__/upload.test.js +0 -617
  154. package/dist/commands/flutter-symbols/__tests__/upload.test.js.map +0 -1
  155. package/dist/commands/gate/__tests__/evaluate.test.d.ts +0 -1
  156. package/dist/commands/gate/__tests__/evaluate.test.js +0 -398
  157. package/dist/commands/gate/__tests__/evaluate.test.js.map +0 -1
  158. package/dist/commands/gate/__tests__/scope.test.d.ts +0 -1
  159. package/dist/commands/gate/__tests__/scope.test.js +0 -29
  160. package/dist/commands/gate/__tests__/scope.test.js.map +0 -1
  161. package/dist/commands/git-metadata/__tests__/git.test.d.ts +0 -1
  162. package/dist/commands/git-metadata/__tests__/git.test.js +0 -132
  163. package/dist/commands/git-metadata/__tests__/git.test.js.map +0 -1
  164. package/dist/commands/git-metadata/__tests__/gitdb.test.d.ts +0 -1
  165. package/dist/commands/git-metadata/__tests__/gitdb.test.js +0 -1386
  166. package/dist/commands/git-metadata/__tests__/gitdb.test.js.map +0 -1
  167. package/dist/commands/git-metadata/__tests__/library.test.d.ts +0 -1
  168. package/dist/commands/git-metadata/__tests__/library.test.js +0 -118
  169. package/dist/commands/git-metadata/__tests__/library.test.js.map +0 -1
  170. package/dist/commands/git-metadata/__tests__/upload.test.d.ts +0 -1
  171. package/dist/commands/git-metadata/__tests__/upload.test.js +0 -52
  172. package/dist/commands/git-metadata/__tests__/upload.test.js.map +0 -1
  173. package/dist/commands/junit/__tests__/upload.test.d.ts +0 -1
  174. package/dist/commands/junit/__tests__/upload.test.js +0 -495
  175. package/dist/commands/junit/__tests__/upload.test.js.map +0 -1
  176. package/dist/commands/lambda/__tests__/fixtures.d.ts +0 -51
  177. package/dist/commands/lambda/__tests__/fixtures.js +0 -146
  178. package/dist/commands/lambda/__tests__/fixtures.js.map +0 -1
  179. package/dist/commands/lambda/__tests__/flare.test.d.ts +0 -1
  180. package/dist/commands/lambda/__tests__/flare.test.js +0 -730
  181. package/dist/commands/lambda/__tests__/flare.test.js.map +0 -1
  182. package/dist/commands/lambda/__tests__/functions/commons.test.d.ts +0 -1
  183. package/dist/commands/lambda/__tests__/functions/commons.test.js +0 -791
  184. package/dist/commands/lambda/__tests__/functions/commons.test.js.map +0 -1
  185. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.d.ts +0 -1
  186. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js +0 -388
  187. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js.map +0 -1
  188. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.d.ts +0 -1
  189. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js +0 -732
  190. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js.map +0 -1
  191. package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +0 -1
  192. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +0 -516
  193. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js.map +0 -1
  194. package/dist/commands/lambda/__tests__/functions/versionChecker.test.d.ts +0 -1
  195. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js +0 -33
  196. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js.map +0 -1
  197. package/dist/commands/lambda/__tests__/instrument.test.d.ts +0 -1
  198. package/dist/commands/lambda/__tests__/instrument.test.js +0 -1606
  199. package/dist/commands/lambda/__tests__/instrument.test.js.map +0 -1
  200. package/dist/commands/lambda/__tests__/loggroup.test.d.ts +0 -1
  201. package/dist/commands/lambda/__tests__/loggroup.test.js +0 -340
  202. package/dist/commands/lambda/__tests__/loggroup.test.js.map +0 -1
  203. package/dist/commands/lambda/__tests__/prompt.test.d.ts +0 -1
  204. package/dist/commands/lambda/__tests__/prompt.test.js +0 -206
  205. package/dist/commands/lambda/__tests__/prompt.test.js.map +0 -1
  206. package/dist/commands/lambda/__tests__/tags.test.d.ts +0 -1
  207. package/dist/commands/lambda/__tests__/tags.test.js +0 -305
  208. package/dist/commands/lambda/__tests__/tags.test.js.map +0 -1
  209. package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +0 -1
  210. package/dist/commands/lambda/__tests__/uninstrument.test.js +0 -725
  211. package/dist/commands/lambda/__tests__/uninstrument.test.js.map +0 -1
  212. package/dist/commands/measure/__tests__/measure.test.d.ts +0 -1
  213. package/dist/commands/measure/__tests__/measure.test.js +0 -102
  214. package/dist/commands/measure/__tests__/measure.test.js.map +0 -1
  215. package/dist/commands/pe-symbols/__tests__/pe.test.d.ts +0 -1
  216. package/dist/commands/pe-symbols/__tests__/pe.test.js +0 -81
  217. package/dist/commands/pe-symbols/__tests__/pe.test.js.map +0 -1
  218. package/dist/commands/react-native/__tests__/codepush.test.d.ts +0 -1
  219. package/dist/commands/react-native/__tests__/codepush.test.js +0 -196
  220. package/dist/commands/react-native/__tests__/codepush.test.js.map +0 -1
  221. package/dist/commands/react-native/__tests__/interfaces.test.d.ts +0 -1
  222. package/dist/commands/react-native/__tests__/interfaces.test.js +0 -33
  223. package/dist/commands/react-native/__tests__/interfaces.test.js.map +0 -1
  224. package/dist/commands/react-native/__tests__/upload.test.d.ts +0 -1
  225. package/dist/commands/react-native/__tests__/upload.test.js +0 -238
  226. package/dist/commands/react-native/__tests__/upload.test.js.map +0 -1
  227. package/dist/commands/react-native/__tests__/utils.test.d.ts +0 -1
  228. package/dist/commands/react-native/__tests__/utils.test.js +0 -69
  229. package/dist/commands/react-native/__tests__/utils.test.js.map +0 -1
  230. package/dist/commands/react-native/__tests__/xcode.test.d.ts +0 -1
  231. package/dist/commands/react-native/__tests__/xcode.test.js +0 -465
  232. package/dist/commands/react-native/__tests__/xcode.test.js.map +0 -1
  233. package/dist/commands/sarif/__tests__/upload.test.d.ts +0 -1
  234. package/dist/commands/sarif/__tests__/upload.test.js +0 -291
  235. package/dist/commands/sarif/__tests__/upload.test.js.map +0 -1
  236. package/dist/commands/sarif/__tests__/utils.test.d.ts +0 -1
  237. package/dist/commands/sarif/__tests__/utils.test.js +0 -26
  238. package/dist/commands/sarif/__tests__/utils.test.js.map +0 -1
  239. package/dist/commands/sarif/__tests__/validation.test.d.ts +0 -1
  240. package/dist/commands/sarif/__tests__/validation.test.js +0 -19
  241. package/dist/commands/sarif/__tests__/validation.test.js.map +0 -1
  242. package/dist/commands/sbom/__tests__/payload.test.d.ts +0 -1
  243. package/dist/commands/sbom/__tests__/payload.test.js +0 -467
  244. package/dist/commands/sbom/__tests__/payload.test.js.map +0 -1
  245. package/dist/commands/sbom/__tests__/validation.test.d.ts +0 -1
  246. package/dist/commands/sbom/__tests__/validation.test.js +0 -145
  247. package/dist/commands/sbom/__tests__/validation.test.js.map +0 -1
  248. package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +0 -1
  249. package/dist/commands/sourcemaps/__tests__/upload.test.js +0 -270
  250. package/dist/commands/sourcemaps/__tests__/upload.test.js.map +0 -1
  251. package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +0 -1
  252. package/dist/commands/sourcemaps/__tests__/utils.test.js +0 -31
  253. package/dist/commands/sourcemaps/__tests__/utils.test.js.map +0 -1
  254. package/dist/commands/span/__tests__/span.test.d.ts +0 -1
  255. package/dist/commands/span/__tests__/span.test.js +0 -108
  256. package/dist/commands/span/__tests__/span.test.js.map +0 -1
  257. package/dist/commands/stepfunctions/__tests__/awsCommands.test.d.ts +0 -1
  258. package/dist/commands/stepfunctions/__tests__/awsCommands.test.js +0 -210
  259. package/dist/commands/stepfunctions/__tests__/awsCommands.test.js.map +0 -1
  260. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.d.ts +0 -6
  261. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js +0 -45
  262. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js.map +0 -1
  263. package/dist/commands/stepfunctions/__tests__/fixtures/cli.d.ts +0 -5
  264. package/dist/commands/stepfunctions/__tests__/fixtures/cli.js +0 -19
  265. package/dist/commands/stepfunctions/__tests__/fixtures/cli.js.map +0 -1
  266. package/dist/commands/stepfunctions/__tests__/helpers.test.d.ts +0 -1
  267. package/dist/commands/stepfunctions/__tests__/helpers.test.js +0 -501
  268. package/dist/commands/stepfunctions/__tests__/helpers.test.js.map +0 -1
  269. package/dist/commands/stepfunctions/__tests__/instrument.test.d.ts +0 -1
  270. package/dist/commands/stepfunctions/__tests__/instrument.test.js +0 -431
  271. package/dist/commands/stepfunctions/__tests__/instrument.test.js.map +0 -1
  272. package/dist/commands/stepfunctions/__tests__/uninstrument.test.d.ts +0 -1
  273. package/dist/commands/stepfunctions/__tests__/uninstrument.test.js +0 -166
  274. package/dist/commands/stepfunctions/__tests__/uninstrument.test.js.map +0 -1
  275. package/dist/commands/synthetics/__tests__/api.test.d.ts +0 -1
  276. package/dist/commands/synthetics/__tests__/api.test.js +0 -416
  277. package/dist/commands/synthetics/__tests__/api.test.js.map +0 -1
  278. package/dist/commands/synthetics/__tests__/batch.test.d.ts +0 -1
  279. package/dist/commands/synthetics/__tests__/batch.test.js +0 -907
  280. package/dist/commands/synthetics/__tests__/batch.test.js.map +0 -1
  281. package/dist/commands/synthetics/__tests__/build-and-test.test.d.ts +0 -1
  282. package/dist/commands/synthetics/__tests__/build-and-test.test.js +0 -91
  283. package/dist/commands/synthetics/__tests__/build-and-test.test.js.map +0 -1
  284. package/dist/commands/synthetics/__tests__/cli.test.d.ts +0 -1
  285. package/dist/commands/synthetics/__tests__/cli.test.js +0 -1407
  286. package/dist/commands/synthetics/__tests__/cli.test.js.map +0 -1
  287. package/dist/commands/synthetics/__tests__/deploy-tests-lib.test.d.ts +0 -1
  288. package/dist/commands/synthetics/__tests__/deploy-tests-lib.test.js +0 -112
  289. package/dist/commands/synthetics/__tests__/deploy-tests-lib.test.js.map +0 -1
  290. package/dist/commands/synthetics/__tests__/fixtures.d.ts +0 -123
  291. package/dist/commands/synthetics/__tests__/fixtures.js +0 -493
  292. package/dist/commands/synthetics/__tests__/fixtures.js.map +0 -1
  293. package/dist/commands/synthetics/__tests__/import-tests-lib.test.d.ts +0 -1
  294. package/dist/commands/synthetics/__tests__/import-tests-lib.test.js +0 -186
  295. package/dist/commands/synthetics/__tests__/import-tests-lib.test.js.map +0 -1
  296. package/dist/commands/synthetics/__tests__/mobile.test.d.ts +0 -1
  297. package/dist/commands/synthetics/__tests__/mobile.test.js +0 -376
  298. package/dist/commands/synthetics/__tests__/mobile.test.js.map +0 -1
  299. package/dist/commands/synthetics/__tests__/multilocator.test.d.ts +0 -1
  300. package/dist/commands/synthetics/__tests__/multilocator.test.js +0 -142
  301. package/dist/commands/synthetics/__tests__/multilocator.test.js.map +0 -1
  302. package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +0 -1
  303. package/dist/commands/synthetics/__tests__/reporters/default.test.js +0 -410
  304. package/dist/commands/synthetics/__tests__/reporters/default.test.js.map +0 -1
  305. package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +0 -1
  306. package/dist/commands/synthetics/__tests__/reporters/junit.test.js +0 -354
  307. package/dist/commands/synthetics/__tests__/reporters/junit.test.js.map +0 -1
  308. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.d.ts +0 -1
  309. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js +0 -232
  310. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js.map +0 -1
  311. package/dist/commands/synthetics/__tests__/run-tests-lib.test.d.ts +0 -1
  312. package/dist/commands/synthetics/__tests__/run-tests-lib.test.js +0 -698
  313. package/dist/commands/synthetics/__tests__/run-tests-lib.test.js.map +0 -1
  314. package/dist/commands/synthetics/__tests__/test.test.d.ts +0 -1
  315. package/dist/commands/synthetics/__tests__/test.test.js +0 -268
  316. package/dist/commands/synthetics/__tests__/test.test.js.map +0 -1
  317. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.d.ts +0 -1
  318. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js +0 -21
  319. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js.map +0 -1
  320. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.d.ts +0 -1
  321. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js +0 -80
  322. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js.map +0 -1
  323. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.d.ts +0 -1
  324. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js +0 -109
  325. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js.map +0 -1
  326. package/dist/commands/synthetics/__tests__/utils/internal.test.d.ts +0 -1
  327. package/dist/commands/synthetics/__tests__/utils/internal.test.js +0 -161
  328. package/dist/commands/synthetics/__tests__/utils/internal.test.js.map +0 -1
  329. package/dist/commands/synthetics/__tests__/utils/public.test.d.ts +0 -1
  330. package/dist/commands/synthetics/__tests__/utils/public.test.js +0 -576
  331. package/dist/commands/synthetics/__tests__/utils/public.test.js.map +0 -1
  332. package/dist/commands/tag/__tests__/tag.test.d.ts +0 -1
  333. package/dist/commands/tag/__tests__/tag.test.js +0 -85
  334. package/dist/commands/tag/__tests__/tag.test.js.map +0 -1
  335. package/dist/commands/trace/__tests__/trace.test.d.ts +0 -1
  336. package/dist/commands/trace/__tests__/trace.test.js +0 -48
  337. package/dist/commands/trace/__tests__/trace.test.js.map +0 -1
  338. package/dist/commands/unity-symbols/__tests__/upload.test.d.ts +0 -1
  339. package/dist/commands/unity-symbols/__tests__/upload.test.js +0 -369
  340. package/dist/commands/unity-symbols/__tests__/upload.test.js.map +0 -1
  341. package/dist/helpers/__tests__/app.test.d.ts +0 -1
  342. package/dist/helpers/__tests__/app.test.js +0 -31
  343. package/dist/helpers/__tests__/app.test.js.map +0 -1
  344. package/dist/helpers/__tests__/ci.test.d.ts +0 -1
  345. package/dist/helpers/__tests__/ci.test.js +0 -344
  346. package/dist/helpers/__tests__/ci.test.js.map +0 -1
  347. package/dist/helpers/__tests__/env.test.d.ts +0 -1
  348. package/dist/helpers/__tests__/env.test.js +0 -74
  349. package/dist/helpers/__tests__/env.test.js.map +0 -1
  350. package/dist/helpers/__tests__/fips.test.d.ts +0 -1
  351. package/dist/helpers/__tests__/fips.test.js +0 -30
  352. package/dist/helpers/__tests__/fips.test.js.map +0 -1
  353. package/dist/helpers/__tests__/fixtures.d.ts +0 -41
  354. package/dist/helpers/__tests__/fixtures.js +0 -80
  355. package/dist/helpers/__tests__/fixtures.js.map +0 -1
  356. package/dist/helpers/__tests__/flare.test.d.ts +0 -1
  357. package/dist/helpers/__tests__/flare.test.js +0 -227
  358. package/dist/helpers/__tests__/flare.test.js.map +0 -1
  359. package/dist/helpers/__tests__/fs.test.d.ts +0 -1
  360. package/dist/helpers/__tests__/fs.test.js +0 -189
  361. package/dist/helpers/__tests__/fs.test.js.map +0 -1
  362. package/dist/helpers/__tests__/id.test.d.ts +0 -1
  363. package/dist/helpers/__tests__/id.test.js +0 -24
  364. package/dist/helpers/__tests__/id.test.js.map +0 -1
  365. package/dist/helpers/__tests__/plist.test.d.ts +0 -1
  366. package/dist/helpers/__tests__/plist.test.js +0 -43
  367. package/dist/helpers/__tests__/plist.test.js.map +0 -1
  368. package/dist/helpers/__tests__/prompt.test.d.ts +0 -1
  369. package/dist/helpers/__tests__/prompt.test.js +0 -71
  370. package/dist/helpers/__tests__/prompt.test.js.map +0 -1
  371. package/dist/helpers/__tests__/retry.test.d.ts +0 -1
  372. package/dist/helpers/__tests__/retry.test.js +0 -99
  373. package/dist/helpers/__tests__/retry.test.js.map +0 -1
  374. package/dist/helpers/__tests__/tags.test.d.ts +0 -1
  375. package/dist/helpers/__tests__/tags.test.js +0 -362
  376. package/dist/helpers/__tests__/tags.test.js.map +0 -1
  377. package/dist/helpers/__tests__/upload.test.d.ts +0 -1
  378. package/dist/helpers/__tests__/upload.test.js +0 -231
  379. package/dist/helpers/__tests__/upload.test.js.map +0 -1
  380. package/dist/helpers/__tests__/user-provided-git.test.d.ts +0 -1
  381. package/dist/helpers/__tests__/user-provided-git.test.js +0 -119
  382. package/dist/helpers/__tests__/user-provided-git.test.js.map +0 -1
  383. package/dist/helpers/__tests__/utils.test.d.ts +0 -1
  384. package/dist/helpers/__tests__/utils.test.js +0 -429
  385. package/dist/helpers/__tests__/utils.test.js.map +0 -1
  386. package/dist/helpers/__tests__/validation.test.d.ts +0 -1
  387. package/dist/helpers/__tests__/validation.test.js +0 -25
  388. package/dist/helpers/__tests__/validation.test.js.map +0 -1
  389. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.d.ts +0 -1
  390. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js +0 -103
  391. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js.map +0 -1
  392. package/dist/helpers/git/__tests__/format-git-span-data.test.d.ts +0 -1
  393. package/dist/helpers/git/__tests__/format-git-span-data.test.js +0 -121
  394. package/dist/helpers/git/__tests__/format-git-span-data.test.js.map +0 -1
  395. package/dist/helpers/git/__tests__/get-git-data.test.d.ts +0 -1
  396. package/dist/helpers/git/__tests__/get-git-data.test.js +0 -72
  397. package/dist/helpers/git/__tests__/get-git-data.test.js.map +0 -1
@@ -1,1407 +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 __rest = (this && this.__rest) || function (s, e) {
35
- var t = {};
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
37
- t[p] = s[p];
38
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
39
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
40
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
41
- t[p[i]] = s[p[i]];
42
- }
43
- return t;
44
- };
45
- Object.defineProperty(exports, "__esModule", { value: true });
46
- const advanced_1 = require("clipanion/lib/advanced");
47
- const fixtures_1 = require("../../../helpers/__tests__/fixtures");
48
- const env_1 = require("../../../helpers/env");
49
- const ciUtils = __importStar(require("../../../helpers/utils"));
50
- const api = __importStar(require("../api"));
51
- const deploy_tests_command_1 = require("../deploy-tests-command");
52
- const errors_1 = require("../errors");
53
- const import_tests_command_1 = require("../import-tests-command");
54
- const interfaces_1 = require("../interfaces");
55
- const mobile = __importStar(require("../mobile"));
56
- const run_tests_command_1 = require("../run-tests-command");
57
- const testUtils = __importStar(require("../test"));
58
- const upload_application_command_1 = require("../upload-application-command");
59
- const internal_1 = require("../utils/internal");
60
- const utils = __importStar(require("../utils/public"));
61
- const fixtures_2 = require("./fixtures");
62
- test('all option flags are supported', () => __awaiter(void 0, void 0, void 0, function* () {
63
- const options = [
64
- 'apiKey',
65
- 'appKey',
66
- 'config',
67
- 'datadogSite',
68
- 'failOnCriticalErrors',
69
- 'failOnMissingTests',
70
- 'failOnTimeout',
71
- 'files',
72
- 'jUnitReport',
73
- 'mobileApplicationVersion',
74
- 'mobileApplicationVersionFilePath',
75
- 'public-id',
76
- 'runName',
77
- 'search',
78
- 'subdomain',
79
- 'tunnel',
80
- ];
81
- const cli = new advanced_1.Cli();
82
- cli.register(run_tests_command_1.RunTestsCommand);
83
- const usage = cli.usage(run_tests_command_1.RunTestsCommand);
84
- options.forEach((option) => expect(usage).toContain(`--${option}`));
85
- }));
86
- describe('run-tests', () => {
87
- beforeEach(() => {
88
- process.env = {};
89
- jest.restoreAllMocks();
90
- });
91
- describe('resolveConfig', () => {
92
- beforeEach(() => {
93
- process.env = {};
94
- });
95
- test('override from ENV', () => __awaiter(void 0, void 0, void 0, function* () {
96
- var _a;
97
- const overrideEnv = {
98
- DATADOG_API_KEY: 'fake_api_key',
99
- DATADOG_APP_KEY: 'fake_app_key',
100
- DATADOG_SITE: 'datadoghq.eu',
101
- DATADOG_SUBDOMAIN: 'custom',
102
- DATADOG_SYNTHETICS_BATCH_TIMEOUT: '1',
103
- DATADOG_SYNTHETICS_BUILD_COMMAND: 'build-command',
104
- DATADOG_SYNTHETICS_CONFIG_PATH: 'path/to/config.json',
105
- DATADOG_SYNTHETICS_FAIL_ON_CRITICAL_ERRORS: 'false',
106
- DATADOG_SYNTHETICS_FAIL_ON_MISSING_TESTS: 'false',
107
- DATADOG_SYNTHETICS_FAIL_ON_TIMEOUT: 'false',
108
- DATADOG_SYNTHETICS_FILES: 'test-file1;test-file2;test-file3',
109
- DATADOG_SYNTHETICS_JUNIT_REPORT: 'junit-report.xml',
110
- DATADOG_SYNTHETICS_PUBLIC_IDS: 'a-public-id;another-public-id',
111
- DATADOG_SYNTHETICS_SELECTIVE_RERUN: 'true',
112
- DATADOG_SYNTHETICS_TEST_SEARCH_QUERY: 'a-search-query',
113
- DATADOG_SYNTHETICS_TUNNEL: 'false',
114
- DATADOG_SYNTHETICS_OVERRIDE_ALLOW_INSECURE_CERTIFICATES: 'true',
115
- DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_PASSWORD: 'password',
116
- DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_USERNAME: 'username',
117
- DATADOG_SYNTHETICS_OVERRIDE_BODY: 'body',
118
- DATADOG_SYNTHETICS_OVERRIDE_BODY_TYPE: 'bodyType',
119
- DATADOG_SYNTHETICS_OVERRIDE_COOKIES: 'cookie1;cookie2;cookie3',
120
- DATADOG_SYNTHETICS_OVERRIDE_COOKIES_APPEND: 'true',
121
- DATADOG_SYNTHETICS_OVERRIDE_SET_COOKIES: 'name1=value1 \n name2=value2; Domain=example.com \n name3=value3; Secure; HttpOnly',
122
- DATADOG_SYNTHETICS_OVERRIDE_SET_COOKIES_APPEND: 'true',
123
- DATADOG_SYNTHETICS_OVERRIDE_DEFAULT_STEP_TIMEOUT: '42',
124
- DATADOG_SYNTHETICS_OVERRIDE_DEVICE_IDS: 'chrome.laptop_large',
125
- DATADOG_SYNTHETICS_OVERRIDE_EXECUTION_RULE: 'BLOCKING',
126
- DATADOG_SYNTHETICS_OVERRIDE_FOLLOW_REDIRECTS: 'true',
127
- DATADOG_SYNTHETICS_OVERRIDE_HEADERS: "{'Content-Type': 'application/json', 'Authorization': 'Bearer token'}",
128
- DATADOG_SYNTHETICS_OVERRIDE_LOCATIONS: 'us-east-1;us-west-1',
129
- DATADOG_SYNTHETICS_OVERRIDE_MOBILE_APPLICATION_VERSION: '00000000-0000-0000-0000-000000000000',
130
- DATADOG_SYNTHETICS_OVERRIDE_RESOURCE_URL_SUBSTITUTION_REGEXES: 'regex1;regex2',
131
- DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT: '5',
132
- DATADOG_SYNTHETICS_OVERRIDE_RETRY_INTERVAL: '100',
133
- DATADOG_SYNTHETICS_OVERRIDE_START_URL: 'startUrl',
134
- DATADOG_SYNTHETICS_OVERRIDE_START_URL_SUBSTITUTION_REGEX: 'startUrlSubstitutionRegex',
135
- DATADOG_SYNTHETICS_OVERRIDE_TEST_TIMEOUT: '42',
136
- DATADOG_SYNTHETICS_OVERRIDE_VARIABLES: "{'var1': 'value1', 'var2': 'value2'}",
137
- };
138
- process.env = overrideEnv;
139
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
140
- yield command['resolveConfig']();
141
- expect(command['config']).toEqual(Object.assign(Object.assign({}, run_tests_command_1.RunTestsCommand.getDefaultConfig()), { apiKey: overrideEnv.DATADOG_API_KEY, appKey: overrideEnv.DATADOG_APP_KEY, batchTimeout: 1, buildCommand: overrideEnv.DATADOG_SYNTHETICS_BUILD_COMMAND, configPath: overrideEnv.DATADOG_SYNTHETICS_CONFIG_PATH, datadogSite: overrideEnv.DATADOG_SITE, defaultTestOverrides: {
142
- allowInsecureCertificates: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_ALLOW_INSECURE_CERTIFICATES),
143
- basicAuth: {
144
- password: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_PASSWORD,
145
- username: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_USERNAME,
146
- },
147
- body: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BODY,
148
- bodyType: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BODY_TYPE,
149
- cookies: {
150
- value: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_COOKIES,
151
- append: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_COOKIES_APPEND),
152
- },
153
- setCookies: {
154
- value: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_SET_COOKIES,
155
- append: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_SET_COOKIES_APPEND),
156
- },
157
- defaultStepTimeout: (0, env_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_DEFAULT_STEP_TIMEOUT),
158
- deviceIds: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_DEVICE_IDS.split(';'),
159
- executionRule: (0, internal_1.toExecutionRule)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_EXECUTION_RULE),
160
- followRedirects: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_FOLLOW_REDIRECTS),
161
- headers: (0, env_1.toStringMap)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_HEADERS),
162
- locations: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_LOCATIONS.split(';'),
163
- mobileApplicationVersion: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_MOBILE_APPLICATION_VERSION,
164
- resourceUrlSubstitutionRegexes: (_a = overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_RESOURCE_URL_SUBSTITUTION_REGEXES) === null || _a === void 0 ? void 0 : _a.split(';'),
165
- retry: {
166
- count: (0, env_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT),
167
- interval: (0, env_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_RETRY_INTERVAL),
168
- },
169
- startUrl: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_START_URL,
170
- startUrlSubstitutionRegex: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_START_URL_SUBSTITUTION_REGEX,
171
- testTimeout: (0, env_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_TEST_TIMEOUT),
172
- variables: (0, env_1.toStringMap)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_VARIABLES),
173
- }, failOnCriticalErrors: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_CRITICAL_ERRORS), failOnMissingTests: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_MISSING_TESTS), failOnTimeout: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_TIMEOUT), files: overrideEnv.DATADOG_SYNTHETICS_FILES.split(';'), jUnitReport: overrideEnv.DATADOG_SYNTHETICS_JUNIT_REPORT, publicIds: overrideEnv.DATADOG_SYNTHETICS_PUBLIC_IDS.split(';'), selectiveRerun: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_SELECTIVE_RERUN), subdomain: overrideEnv.DATADOG_SUBDOMAIN, testSearchQuery: overrideEnv.DATADOG_SYNTHETICS_TEST_SEARCH_QUERY, tunnel: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_TUNNEL) }));
174
- }));
175
- test('partial retryConfig override from ENV retains existing values', () => __awaiter(void 0, void 0, void 0, function* () {
176
- const overrideEnv = {
177
- DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT: '5',
178
- };
179
- process.env = overrideEnv;
180
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
181
- command['config'].defaultTestOverrides = Object.assign(Object.assign({}, command['config'].defaultTestOverrides), { retry: {
182
- count: 1,
183
- interval: 42,
184
- } });
185
- yield command['resolveConfig']();
186
- expect(command['config'].defaultTestOverrides.retry).toEqual({
187
- count: 5,
188
- interval: 42,
189
- });
190
- }));
191
- test('override from config file', () => __awaiter(void 0, void 0, void 0, function* () {
192
- const expectedConfig = {
193
- apiKey: 'fake_api_key',
194
- appKey: 'fake_app_key',
195
- batchTimeout: 1,
196
- buildCommand: 'build-command',
197
- configPath: 'src/commands/synthetics/__tests__/config-fixtures/config-with-all-keys.json',
198
- datadogSite: 'datadoghq.eu',
199
- defaultTestOverrides: {
200
- allowInsecureCertificates: true,
201
- basicAuth: { username: 'test', password: 'test' },
202
- body: '{"fakeContent":true}',
203
- bodyType: 'application/json',
204
- cookies: {
205
- value: 'name1=value1;name2=value2;',
206
- append: true,
207
- },
208
- setCookies: {
209
- value: 'name1=value1 \n name2=value2; Domain=example.com \n name3=value3; Secure; HttpOnly',
210
- append: true,
211
- },
212
- defaultStepTimeout: 10000,
213
- deviceIds: ['chrome.laptop_large'],
214
- executionRule: interfaces_1.ExecutionRule.BLOCKING,
215
- followRedirects: true,
216
- headers: { '<NEW_HEADER>': '<NEW_VALUE>' },
217
- locations: ['aws:us-west-1'],
218
- mobileApplicationVersion: '00000000-0000-0000-0000-000000000000',
219
- mobileApplicationVersionFilePath: './path/to/application.apk',
220
- resourceUrlSubstitutionRegexes: [
221
- 's/(https://www.)(.*)/$1extra-$2',
222
- 'https://example.com(.*)|http://subdomain.example.com$1',
223
- ],
224
- retry: { count: 2, interval: 300 },
225
- startUrl: '{{URL}}?static_hash={{STATIC_HASH}}',
226
- startUrlSubstitutionRegex: 's/(https://www.)(.*)/$1extra-$2/',
227
- testTimeout: 200000,
228
- variables: { titleVariable: 'new value' },
229
- },
230
- failOnCriticalErrors: true,
231
- failOnMissingTests: true,
232
- failOnTimeout: false,
233
- files: ['my-new-file'],
234
- jUnitReport: 'junit-report.xml',
235
- proxy: {
236
- protocol: 'https',
237
- },
238
- publicIds: ['ran-dom-id1'],
239
- selectiveRerun: true,
240
- subdomain: 'ppa',
241
- testSearchQuery: 'a-search-query',
242
- tunnel: true,
243
- };
244
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
245
- command['configPath'] = 'src/commands/synthetics/__tests__/config-fixtures/config-with-all-keys.json';
246
- yield command['resolveConfig']();
247
- expect(command['config']).toEqual(expectedConfig);
248
- }));
249
- test('override from CLI', () => __awaiter(void 0, void 0, void 0, function* () {
250
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
251
- const overrideCLI = {
252
- apiKey: 'fake_api_key',
253
- appKey: 'fake_app_key',
254
- batchTimeout: 1,
255
- configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file.json',
256
- datadogSite: 'datadoghq.eu',
257
- failOnCriticalErrors: true,
258
- failOnMissingTests: true,
259
- failOnTimeout: false,
260
- files: ['new-file'],
261
- jUnitReport: 'junit-report.xml',
262
- mobileApplicationVersionFilePath: './path/to/application.apk',
263
- publicIds: ['ran-dom-id2'],
264
- selectiveRerun: true,
265
- subdomain: 'new-sub-domain',
266
- testSearchQuery: 'a-search-query',
267
- tunnel: true,
268
- };
269
- /** Values passed to `--override`. */
270
- const defaultTestOverrides = {
271
- allowInsecureCertificates: true,
272
- basicAuth: {
273
- password: 'password',
274
- username: 'username',
275
- },
276
- body: 'a body',
277
- bodyType: 'bodyType',
278
- cookies: 'name1=value1;name2=value2;',
279
- setCookies: 'name1=value1 \n name2=value2; Domain=example.com \n name3=value3; Secure; HttpOnly',
280
- defaultStepTimeout: 42,
281
- deviceIds: ['chrome.laptop_large', 'chrome.laptop_small', 'firefox.laptop_large'],
282
- executionRule: interfaces_1.ExecutionRule.BLOCKING,
283
- followRedirects: true,
284
- headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' },
285
- locations: ['us-east-1', 'us-west-1'],
286
- mobileApplicationVersion: '00000000-0000-0000-0000-000000000000',
287
- resourceUrlSubstitutionRegexes: [
288
- 's/(https://www.)(.*)/$1extra-$2',
289
- 'https://example.com(.*)|http://subdomain.example.com$1',
290
- ],
291
- retry: {
292
- count: 5,
293
- interval: 42,
294
- },
295
- startUrl: 'startUrl',
296
- startUrlSubstitutionRegex: 'startUrlSubstitutionRegex',
297
- testTimeout: 42,
298
- variables: { var1: 'value1', var2: 'value2' },
299
- };
300
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
301
- command['apiKey'] = overrideCLI.apiKey;
302
- command['appKey'] = overrideCLI.appKey;
303
- command['batchTimeout'] = overrideCLI.batchTimeout;
304
- command['configPath'] = overrideCLI.configPath;
305
- command['datadogSite'] = overrideCLI.datadogSite;
306
- command['failOnCriticalErrors'] = overrideCLI.failOnCriticalErrors;
307
- command['failOnMissingTests'] = overrideCLI.failOnMissingTests;
308
- command['failOnTimeout'] = overrideCLI.failOnTimeout;
309
- command['files'] = overrideCLI.files;
310
- command['jUnitReport'] = overrideCLI.jUnitReport;
311
- command['mobileApplicationVersion'] = defaultTestOverrides.mobileApplicationVersion;
312
- command['mobileApplicationVersionFilePath'] = overrideCLI.mobileApplicationVersionFilePath;
313
- command['publicIds'] = overrideCLI.publicIds;
314
- command['selectiveRerun'] = overrideCLI.selectiveRerun;
315
- command['subdomain'] = overrideCLI.subdomain;
316
- command['tunnel'] = overrideCLI.tunnel;
317
- command['testSearchQuery'] = overrideCLI.testSearchQuery;
318
- command['overrides'] = [
319
- `allowInsecureCertificates=${defaultTestOverrides.allowInsecureCertificates}`,
320
- `basicAuth.password=${(_b = defaultTestOverrides.basicAuth) === null || _b === void 0 ? void 0 : _b.password}`,
321
- `basicAuth.username=${(_c = defaultTestOverrides.basicAuth) === null || _c === void 0 ? void 0 : _c.username}`,
322
- `body=${defaultTestOverrides.body}`,
323
- `bodyType=${defaultTestOverrides.bodyType}`,
324
- `cookies=${defaultTestOverrides.cookies}`,
325
- `cookies.append=true`,
326
- `setCookies=${defaultTestOverrides.setCookies}`,
327
- `setCookies.append=true`,
328
- `defaultStepTimeout=${defaultTestOverrides.defaultStepTimeout}`,
329
- `deviceIds=${(_d = defaultTestOverrides.deviceIds) === null || _d === void 0 ? void 0 : _d.join(';')}`,
330
- `executionRule=${defaultTestOverrides.executionRule}`,
331
- `followRedirects=${defaultTestOverrides.followRedirects}`,
332
- `headers.Content-Type=${defaultTestOverrides.headers ? defaultTestOverrides.headers['Content-Type'] : ''}`,
333
- `headers.Authorization=${(_e = defaultTestOverrides.headers) === null || _e === void 0 ? void 0 : _e.Authorization}`,
334
- `locations=${(_f = defaultTestOverrides.locations) === null || _f === void 0 ? void 0 : _f.join(';')}`,
335
- `retry.count=${(_g = defaultTestOverrides.retry) === null || _g === void 0 ? void 0 : _g.count}`,
336
- `retry.interval=${(_h = defaultTestOverrides.retry) === null || _h === void 0 ? void 0 : _h.interval}`,
337
- `startUrl=${defaultTestOverrides.startUrl}`,
338
- `startUrlSubstitutionRegex=${defaultTestOverrides.startUrlSubstitutionRegex}`,
339
- `testTimeout=${defaultTestOverrides.testTimeout}`,
340
- `resourceUrlSubstitutionRegexes=${(_j = defaultTestOverrides.resourceUrlSubstitutionRegexes) === null || _j === void 0 ? void 0 : _j.join(';')}`,
341
- `variables.var1=${(_k = defaultTestOverrides.variables) === null || _k === void 0 ? void 0 : _k.var1}`,
342
- `variables.var2=${(_l = defaultTestOverrides.variables) === null || _l === void 0 ? void 0 : _l.var2}`,
343
- ];
344
- yield command['resolveConfig']();
345
- expect(command['config']).toEqual(Object.assign(Object.assign({}, run_tests_command_1.RunTestsCommand.getDefaultConfig()), { apiKey: 'fake_api_key', appKey: 'fake_app_key', batchTimeout: 1, configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file.json', datadogSite: 'datadoghq.eu', defaultTestOverrides: {
346
- allowInsecureCertificates: true,
347
- basicAuth: {
348
- password: 'password',
349
- username: 'username',
350
- },
351
- body: 'a body',
352
- bodyType: 'bodyType',
353
- cookies: {
354
- value: 'name1=value1;name2=value2;',
355
- append: true,
356
- },
357
- setCookies: {
358
- value: 'name1=value1 \n name2=value2; Domain=example.com \n name3=value3; Secure; HttpOnly',
359
- append: true,
360
- },
361
- defaultStepTimeout: 42,
362
- deviceIds: ['chrome.laptop_large', 'chrome.laptop_small', 'firefox.laptop_large'],
363
- executionRule: interfaces_1.ExecutionRule.BLOCKING,
364
- followRedirects: true,
365
- headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token' },
366
- locations: ['us-east-1', 'us-west-1'],
367
- mobileApplicationVersion: '00000000-0000-0000-0000-000000000000',
368
- mobileApplicationVersionFilePath: './path/to/application.apk',
369
- resourceUrlSubstitutionRegexes: [
370
- 's/(https://www.)(.*)/$1extra-$2',
371
- 'https://example.com(.*)|http://subdomain.example.com$1',
372
- ],
373
- retry: {
374
- count: 5,
375
- interval: 42,
376
- },
377
- startUrl: 'startUrl',
378
- startUrlSubstitutionRegex: 'startUrlSubstitutionRegex',
379
- testTimeout: 42,
380
- variables: { var1: 'value1', var2: 'value2' },
381
- }, failOnCriticalErrors: true, failOnMissingTests: true, failOnTimeout: false, files: ['new-file'], jUnitReport: 'junit-report.xml', publicIds: ['ran-dom-id2'], selectiveRerun: true, subdomain: 'new-sub-domain', testSearchQuery: 'a-search-query', tunnel: true }));
382
- }));
383
- // We have 2 code paths that handle different levels of configuration overrides:
384
- // 1) entire global config file < ENV (environment variables) < CLI (command flags)
385
- // 2) defaultTestOverrides in global config file < ENV (environment variables) < test file (test configuration)
386
- //
387
- // First, 1) configures datadog-ci itself and `defaultTestOverrides`,
388
- // Then, 2) configures the Synthetic tests to execute.
389
- //
390
- // So the bigger picture is:
391
- //
392
- // (config file < ENV < CLI < test file) => execute tests
393
- describe('override precedence - [config file < ENV < CLI < test file]', () => {
394
- const configFile = {
395
- apiKey: 'config_file_api_key',
396
- appKey: 'config_file_app_key',
397
- buildCommand: 'build-command',
398
- datadogSite: 'us3.datadoghq.com',
399
- defaultTestOverrides: {
400
- allowInsecureCertificates: true,
401
- basicAuth: {
402
- username: 'config-file-username',
403
- password: 'config-file-password',
404
- },
405
- body: '{"fakeContentFromConfigFile":true}',
406
- bodyType: 'application/json-from-config-file',
407
- cookies: {
408
- value: 'cookie1-from-config-file=cookie1-value;cookie2-from-config-file=cookie2-value;',
409
- append: true,
410
- },
411
- defaultStepTimeout: 10000,
412
- deviceIds: ['chrome.laptop_large_from_config_file', 'chrome.laptop_small_from_config_file'],
413
- executionRule: interfaces_1.ExecutionRule.BLOCKING,
414
- followRedirects: true,
415
- headers: { 'Config-File': 'This is a mess' },
416
- mobileApplicationVersion: '00000000-0000-0000-0000-000000000000-config-file',
417
- mobileApplicationVersionFilePath: './path/to/application-from-config-file.apk',
418
- retry: { count: 2, interval: 300 },
419
- resourceUrlSubstitutionRegexes: ['regex1-from-config-file', 'regex2-from-config-file'],
420
- startUrl: '{{URL}}?static_hash={{STATIC_HASH}}',
421
- startUrlSubstitutionRegex: 's/(https://www.)(.*)/$1extra-$2/',
422
- testTimeout: 200000,
423
- variables: { titleVariable: 'config file value' },
424
- },
425
- failOnCriticalErrors: false,
426
- failOnMissingTests: false,
427
- failOnTimeout: false,
428
- files: ['from_config_file.json'],
429
- jUnitReport: 'junit-report-from-config-file.xml',
430
- proxy: { protocol: 'http' },
431
- publicIds: ['public-id-from-config-file'],
432
- selectiveRerun: false,
433
- subdomain: 'subdomain_from_config_file',
434
- testSearchQuery: 'a-search-query-from-config-file',
435
- tunnel: false,
436
- };
437
- test('config file < ENV', () => __awaiter(void 0, void 0, void 0, function* () {
438
- var _a, _b, _c;
439
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementationOnce((baseConfig) => __awaiter(void 0, void 0, void 0, function* () {
440
- return (Object.assign(Object.assign({}, baseConfig), configFile));
441
- }));
442
- const overrideEnv = {
443
- DATADOG_API_KEY: 'env_api_key',
444
- DATADOG_APP_KEY: 'env_app_key',
445
- DATADOG_SITE: 'us5.datadoghq.com',
446
- DATADOG_SUBDOMAIN: 'subdomain_from_env',
447
- DATADOG_SYNTHETICS_BATCH_TIMEOUT: '1',
448
- DATADOG_SYNTHETICS_BUILD_COMMAND: 'build-command',
449
- DATADOG_SYNTHETICS_CONFIG_PATH: 'path/to/config_from_env.json',
450
- DATADOG_SYNTHETICS_FAIL_ON_CRITICAL_ERRORS: 'true',
451
- DATADOG_SYNTHETICS_FAIL_ON_MISSING_TESTS: 'true',
452
- DATADOG_SYNTHETICS_FAIL_ON_TIMEOUT: 'true',
453
- DATADOG_SYNTHETICS_FILES: '1_from_env.json;2_from_env.json',
454
- DATADOG_SYNTHETICS_JUNIT_REPORT: 'junit-report-from-env.xml',
455
- DATADOG_SYNTHETICS_PUBLIC_IDS: 'a-public-id-from-env;another-public-id-from-env',
456
- DATADOG_SYNTHETICS_SELECTIVE_RERUN: 'true',
457
- DATADOG_SYNTHETICS_TEST_SEARCH_QUERY: 'a-search-query-from-env',
458
- DATADOG_SYNTHETICS_TUNNEL: 'true',
459
- DATADOG_SYNTHETICS_OVERRIDE_ALLOW_INSECURE_CERTIFICATES: 'true',
460
- DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_PASSWORD: 'password-from-env',
461
- DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_USERNAME: 'username-from-env',
462
- DATADOG_SYNTHETICS_OVERRIDE_BODY: 'body-from-env',
463
- DATADOG_SYNTHETICS_OVERRIDE_BODY_TYPE: 'bodyType-from-env',
464
- DATADOG_SYNTHETICS_OVERRIDE_COOKIES: 'cookie1-from-env;cookie2-from-env;cookie3-from-env',
465
- DATADOG_SYNTHETICS_OVERRIDE_COOKIES_APPEND: 'true',
466
- DATADOG_SYNTHETICS_OVERRIDE_SET_COOKIES: 'cookie1-from-env \n cookie2-from-env; Domain=example.com \n cookie3-from-env; Secure; HttpOnly',
467
- DATADOG_SYNTHETICS_OVERRIDE_SET_COOKIES_APPEND: 'true',
468
- DATADOG_SYNTHETICS_OVERRIDE_DEFAULT_STEP_TIMEOUT: '42',
469
- DATADOG_SYNTHETICS_OVERRIDE_DEVICE_IDS: 'chrome.laptop_large_from_env',
470
- DATADOG_SYNTHETICS_OVERRIDE_EXECUTION_RULE: 'NON_BLOCKING',
471
- DATADOG_SYNTHETICS_OVERRIDE_FOLLOW_REDIRECTS: 'false',
472
- DATADOG_SYNTHETICS_OVERRIDE_HEADERS: "{'Content-Type': 'application/json', 'Authorization': 'Bearer token from env'}",
473
- DATADOG_SYNTHETICS_OVERRIDE_LOCATIONS: 'location_1_from_env;location_2_from_env',
474
- DATADOG_SYNTHETICS_OVERRIDE_MOBILE_APPLICATION_VERSION: '00000000-0000-0000-0000-000000000000',
475
- DATADOG_SYNTHETICS_OVERRIDE_RESOURCE_URL_SUBSTITUTION_REGEXES: 'regex1-from-env;regex2-from-env',
476
- DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT: '5',
477
- DATADOG_SYNTHETICS_OVERRIDE_RETRY_INTERVAL: '100',
478
- DATADOG_SYNTHETICS_OVERRIDE_START_URL: 'startUrl',
479
- DATADOG_SYNTHETICS_OVERRIDE_START_URL_SUBSTITUTION_REGEX: 'startUrlSubstitutionRegex',
480
- DATADOG_SYNTHETICS_OVERRIDE_TEST_TIMEOUT: '42',
481
- DATADOG_SYNTHETICS_OVERRIDE_VARIABLES: "{'var1': 'value1', 'var2': 'value2'}",
482
- };
483
- const expectedEnvOverrideResult = {
484
- apiKey: overrideEnv.DATADOG_API_KEY,
485
- appKey: overrideEnv.DATADOG_APP_KEY,
486
- batchTimeout: (0, env_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_BATCH_TIMEOUT),
487
- buildCommand: overrideEnv.DATADOG_SYNTHETICS_BUILD_COMMAND,
488
- configPath: overrideEnv.DATADOG_SYNTHETICS_CONFIG_PATH,
489
- datadogSite: overrideEnv.DATADOG_SITE,
490
- defaultTestOverrides: {
491
- allowInsecureCertificates: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_ALLOW_INSECURE_CERTIFICATES),
492
- basicAuth: {
493
- password: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_PASSWORD,
494
- username: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_USERNAME,
495
- },
496
- body: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BODY,
497
- bodyType: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_BODY_TYPE,
498
- cookies: {
499
- value: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_COOKIES,
500
- append: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_COOKIES_APPEND),
501
- },
502
- setCookies: {
503
- value: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_SET_COOKIES,
504
- append: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_SET_COOKIES_APPEND),
505
- },
506
- defaultStepTimeout: (0, env_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_DEFAULT_STEP_TIMEOUT),
507
- deviceIds: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_DEVICE_IDS.split(';'),
508
- executionRule: (0, internal_1.toExecutionRule)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_EXECUTION_RULE),
509
- followRedirects: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_FOLLOW_REDIRECTS),
510
- headers: Object.assign(Object.assign({}, configFile.defaultTestOverrides.headers), (0, env_1.toStringMap)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_HEADERS)),
511
- locations: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_LOCATIONS.split(';'),
512
- mobileApplicationVersion: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_MOBILE_APPLICATION_VERSION,
513
- resourceUrlSubstitutionRegexes: (_a = overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_RESOURCE_URL_SUBSTITUTION_REGEXES) === null || _a === void 0 ? void 0 : _a.split(';'),
514
- retry: {
515
- count: (0, env_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT),
516
- interval: (0, env_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_RETRY_INTERVAL),
517
- },
518
- startUrl: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_START_URL,
519
- startUrlSubstitutionRegex: overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_START_URL_SUBSTITUTION_REGEX,
520
- testTimeout: (0, env_1.toNumber)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_TEST_TIMEOUT),
521
- variables: Object.assign(Object.assign({}, configFile.defaultTestOverrides.variables), (0, env_1.toStringMap)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_VARIABLES)),
522
- // XXX: Added to make the test pass as we don't have an ENV variable for `mobileApplicationVersionFilePath`.
523
- mobileApplicationVersionFilePath: configFile.defaultTestOverrides.mobileApplicationVersionFilePath,
524
- },
525
- failOnCriticalErrors: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_CRITICAL_ERRORS),
526
- failOnMissingTests: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_MISSING_TESTS),
527
- failOnTimeout: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_FAIL_ON_TIMEOUT),
528
- files: (_b = overrideEnv.DATADOG_SYNTHETICS_FILES) === null || _b === void 0 ? void 0 : _b.split(';'),
529
- jUnitReport: overrideEnv.DATADOG_SYNTHETICS_JUNIT_REPORT,
530
- publicIds: (_c = overrideEnv.DATADOG_SYNTHETICS_PUBLIC_IDS) === null || _c === void 0 ? void 0 : _c.split(';'),
531
- selectiveRerun: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_SELECTIVE_RERUN),
532
- subdomain: overrideEnv.DATADOG_SUBDOMAIN,
533
- testSearchQuery: overrideEnv.DATADOG_SYNTHETICS_TEST_SEARCH_QUERY,
534
- tunnel: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_TUNNEL),
535
- // XXX: Added to make the test pass as we use well-known ENV variables to configure the proxy.
536
- proxy: configFile.proxy,
537
- };
538
- process.env = overrideEnv;
539
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
540
- yield command['resolveConfig']();
541
- expect(command['config']).toEqual(expectedEnvOverrideResult);
542
- }));
543
- test('config file < CLI', () => __awaiter(void 0, void 0, void 0, function* () {
544
- var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
545
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementationOnce((baseConfig) => __awaiter(void 0, void 0, void 0, function* () {
546
- return (Object.assign(Object.assign({}, baseConfig), configFile));
547
- }));
548
- const overrideCLI = {
549
- apiKey: 'cli_api_key',
550
- appKey: 'cli_app_key',
551
- batchTimeout: 1,
552
- buildCommand: 'build-command',
553
- configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file-from-cli.json',
554
- datadogSite: 'datadoghq.eu',
555
- failOnCriticalErrors: true,
556
- failOnMissingTests: true,
557
- failOnTimeout: true,
558
- files: ['new-file-from-cli'],
559
- jUnitReport: 'junit-report-from-cli.xml',
560
- mobileApplicationVersionFilePath: './path/to/application-from-cli.apk',
561
- publicIds: ['public-id-from-cli'],
562
- selectiveRerun: true,
563
- subdomain: 'subdomain-from-cli',
564
- testSearchQuery: 'a-search-query-from-cli',
565
- tunnel: true,
566
- };
567
- const defaultTestOverrides = {
568
- allowInsecureCertificates: false,
569
- basicAuth: {
570
- password: 'password-cli',
571
- username: 'username-cli',
572
- },
573
- body: '{"fakeContentFromCLI":true}',
574
- bodyType: 'application/json-from-cli',
575
- cookies: {
576
- value: 'cli1=value1;cli2=value2;',
577
- append: false,
578
- },
579
- setCookies: {
580
- value: 'cli1=value1 \n cli2=value2; Domain=example.com \n cli3=value3; Secure; HttpOnly',
581
- append: false,
582
- },
583
- defaultStepTimeout: 11,
584
- deviceIds: ['chrome.laptop_large_from_cli', 'chrome.laptop_small_from_cli', 'firefox.laptop_large_from_cli'],
585
- executionRule: interfaces_1.ExecutionRule.NON_BLOCKING,
586
- followRedirects: false,
587
- headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token from cli' },
588
- locations: ['cli-loc-1', 'cli-loc-2'],
589
- mobileApplicationVersion: '00000000-0000-0000-0000-000000000000-cli',
590
- resourceUrlSubstitutionRegexes: [
591
- 'cli-regex',
592
- 's/(https://www.)(.*)/$1extra-$2',
593
- 'https://example.com(.*)|http://subdomain.example.com$1',
594
- ],
595
- retry: {
596
- count: 13,
597
- interval: 14,
598
- },
599
- startUrl: 'startUrl-from-cli',
600
- startUrlSubstitutionRegex: 'startUrlSubstitutionRegex-from-cli',
601
- testTimeout: 15,
602
- variables: { cliVar1: 'value1', cliVar2: 'value2' },
603
- };
604
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
605
- command['apiKey'] = overrideCLI.apiKey;
606
- command['appKey'] = overrideCLI.appKey;
607
- command['batchTimeout'] = overrideCLI.batchTimeout;
608
- command['buildCommand'] = overrideCLI.buildCommand;
609
- command['configPath'] = overrideCLI.configPath;
610
- command['datadogSite'] = overrideCLI.datadogSite;
611
- command['failOnCriticalErrors'] = overrideCLI.failOnCriticalErrors;
612
- command['failOnMissingTests'] = overrideCLI.failOnMissingTests;
613
- command['failOnTimeout'] = overrideCLI.failOnTimeout;
614
- command['files'] = overrideCLI.files;
615
- command['jUnitReport'] = overrideCLI.jUnitReport;
616
- command['mobileApplicationVersion'] = defaultTestOverrides.mobileApplicationVersion;
617
- command['mobileApplicationVersionFilePath'] = overrideCLI.mobileApplicationVersionFilePath;
618
- command['publicIds'] = overrideCLI.publicIds;
619
- command['selectiveRerun'] = overrideCLI.selectiveRerun;
620
- command['subdomain'] = overrideCLI.subdomain;
621
- command['tunnel'] = overrideCLI.tunnel;
622
- command['testSearchQuery'] = overrideCLI.testSearchQuery;
623
- command['overrides'] = [
624
- `allowInsecureCertificates=${defaultTestOverrides.allowInsecureCertificates}`,
625
- `basicAuth.password=${(_d = defaultTestOverrides.basicAuth) === null || _d === void 0 ? void 0 : _d.password}`,
626
- `basicAuth.username=${(_e = defaultTestOverrides.basicAuth) === null || _e === void 0 ? void 0 : _e.username}`,
627
- `body=${defaultTestOverrides.body}`,
628
- `bodyType=${defaultTestOverrides.bodyType}`,
629
- `cookies=${defaultTestOverrides.cookies.value}`,
630
- `cookies.append=${defaultTestOverrides.cookies.append}`,
631
- `setCookies=${defaultTestOverrides.setCookies.value}`,
632
- `setCookies.append=${defaultTestOverrides.setCookies.append}`,
633
- `defaultStepTimeout=${defaultTestOverrides.defaultStepTimeout}`,
634
- `deviceIds=${(_f = defaultTestOverrides.deviceIds) === null || _f === void 0 ? void 0 : _f.join(';')}`,
635
- `executionRule=${defaultTestOverrides.executionRule}`,
636
- `followRedirects=${defaultTestOverrides.followRedirects}`,
637
- `headers.Content-Type=${(_g = defaultTestOverrides.headers) === null || _g === void 0 ? void 0 : _g['Content-Type']}`,
638
- `headers.Authorization=${(_h = defaultTestOverrides.headers) === null || _h === void 0 ? void 0 : _h.Authorization}`,
639
- `locations=${(_j = defaultTestOverrides.locations) === null || _j === void 0 ? void 0 : _j.join(';')}`,
640
- `retry.count=${(_k = defaultTestOverrides.retry) === null || _k === void 0 ? void 0 : _k.count}`,
641
- `retry.interval=${(_l = defaultTestOverrides.retry) === null || _l === void 0 ? void 0 : _l.interval}`,
642
- `startUrl=${defaultTestOverrides.startUrl}`,
643
- `startUrlSubstitutionRegex=${defaultTestOverrides.startUrlSubstitutionRegex}`,
644
- `testTimeout=${defaultTestOverrides.testTimeout}`,
645
- `resourceUrlSubstitutionRegexes=${(_m = defaultTestOverrides.resourceUrlSubstitutionRegexes) === null || _m === void 0 ? void 0 : _m.join(';')}`,
646
- `variables.cliVar1=${(_o = defaultTestOverrides.variables) === null || _o === void 0 ? void 0 : _o.cliVar1}`,
647
- `variables.cliVar2=${(_p = defaultTestOverrides.variables) === null || _p === void 0 ? void 0 : _p.cliVar2}`,
648
- ];
649
- yield command['resolveConfig']();
650
- const { mobileApplicationVersionFilePath } = overrideCLI, filteredOverrideCLI = __rest(overrideCLI, ["mobileApplicationVersionFilePath"]);
651
- const expectedCLIOverrideResult = Object.assign(Object.assign({}, filteredOverrideCLI), { defaultTestOverrides: Object.assign(Object.assign({}, defaultTestOverrides), { headers: Object.assign(Object.assign({}, configFile.defaultTestOverrides.headers), defaultTestOverrides.headers), mobileApplicationVersionFilePath, variables: Object.assign(Object.assign({}, configFile.defaultTestOverrides.variables), defaultTestOverrides.variables) }), proxy: configFile.proxy });
652
- expect(command['config']).toEqual(expectedCLIOverrideResult);
653
- }));
654
- test('ENV < CLI', () => __awaiter(void 0, void 0, void 0, function* () {
655
- var _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
656
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementationOnce((baseConfig) => __awaiter(void 0, void 0, void 0, function* () { return baseConfig; }));
657
- const overrideEnv = {
658
- DATADOG_API_KEY: 'env_api_key',
659
- DATADOG_APP_KEY: 'env_app_key',
660
- DATADOG_SITE: 'us5.datadoghq.com',
661
- DATADOG_SYNTHETICS_CONFIG_PATH: 'path/to/config_from_env.json',
662
- DATADOG_SUBDOMAIN: 'subdomain_from_env',
663
- DATADOG_SYNTHETICS_BUILD_COMMAND: 'default-build-command',
664
- DATADOG_SYNTHETICS_FAIL_ON_CRITICAL_ERRORS: 'true',
665
- DATADOG_SYNTHETICS_FAIL_ON_MISSING_TESTS: 'true',
666
- DATADOG_SYNTHETICS_FAIL_ON_TIMEOUT: 'true',
667
- DATADOG_SYNTHETICS_FILES: '1_from_env.json;2_from_env.json',
668
- DATADOG_SYNTHETICS_JUNIT_REPORT: 'junit-report-from-env.xml',
669
- DATADOG_SYNTHETICS_PUBLIC_IDS: 'a-public-id-from-env;another-public-id-from-env',
670
- DATADOG_SYNTHETICS_SELECTIVE_RERUN: 'true',
671
- DATADOG_SYNTHETICS_TEST_SEARCH_QUERY: 'a-search-query-from-env',
672
- DATADOG_SYNTHETICS_TUNNEL: 'false',
673
- DATADOG_SYNTHETICS_OVERRIDE_ALLOW_INSECURE_CERTIFICATES: 'true',
674
- DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_PASSWORD: 'password-from-env',
675
- DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_USERNAME: 'username-from-env',
676
- DATADOG_SYNTHETICS_OVERRIDE_BODY: 'body-from-env',
677
- DATADOG_SYNTHETICS_OVERRIDE_BODY_TYPE: 'bodyType-from-env',
678
- DATADOG_SYNTHETICS_OVERRIDE_COOKIES: 'cookie1-from-env;cookie2-from-env;cookie3-from-env',
679
- DATADOG_SYNTHETICS_OVERRIDE_COOKIES_APPEND: 'true',
680
- DATADOG_SYNTHEITCS_OVERRIDE_SET_COOKIES: 'cookie1-from-env \n cookie2-from-env; Domain=example.com \n cookie3-from-env; Secure; HttpOnly',
681
- DATADOG_SYNTHETICS_OVERRIDE_SET_COOKIES_APPEND: 'true',
682
- DATADOG_SYNTHETICS_OVERRIDE_DEFAULT_STEP_TIMEOUT: '42',
683
- DATADOG_SYNTHETICS_OVERRIDE_DEVICE_IDS: 'chrome.laptop_large_from_env',
684
- DATADOG_SYNTHETICS_OVERRIDE_EXECUTION_RULE: 'BLOCKING',
685
- DATADOG_SYNTHETICS_OVERRIDE_FOLLOW_REDIRECTS: 'true',
686
- DATADOG_SYNTHETICS_OVERRIDE_HEADERS: "{'Content-Type': 'application/json', 'Authorization': 'Bearer token from env'}",
687
- DATADOG_SYNTHETICS_OVERRIDE_LOCATIONS: 'location_1_from_env;location_2_from_env',
688
- DATADOG_SYNTHETICS_OVERRIDE_MOBILE_APPLICATION_VERSION: 'env-00000000-0000-0000-0000-000000000000',
689
- DATADOG_SYNTHETICS_OVERRIDE_RESOURCE_URL_SUBSTITUTION_REGEXES: 'env-regex1;env-regex2',
690
- DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT: '5',
691
- DATADOG_SYNTHETICS_OVERRIDE_RETRY_INTERVAL: '100',
692
- DATADOG_SYNTHETICS_OVERRIDE_START_URL: 'startUrl-from-env',
693
- DATADOG_SYNTHETICS_OVERRIDE_START_URL_SUBSTITUTION_REGEX: 'startUrlSubstitutionRegex-from-env',
694
- DATADOG_SYNTHETICS_OVERRIDE_TEST_TIMEOUT: '42',
695
- DATADOG_SYNTHETICS_OVERRIDE_VARIABLES: "{'envVar1': 'value1', 'envVar2': 'value2'}",
696
- };
697
- const overrideCLI = {
698
- apiKey: 'cli_api_key',
699
- appKey: 'cli_app_key',
700
- batchTimeout: 1,
701
- buildCommand: 'build-command',
702
- configPath: 'path/to/config_from_cli.json',
703
- datadogSite: 'datadoghq.eu',
704
- failOnCriticalErrors: false,
705
- failOnMissingTests: false,
706
- failOnTimeout: false,
707
- files: ['file-from-cli-1;file-from-cli-2'],
708
- jUnitReport: 'junit-report-from-cli.xml',
709
- mobileApplicationVersionFilePath: './path/to/application-from-cli.apk',
710
- publicIds: ['public-id-from-cli-1', 'public-id-from-cli-2'],
711
- selectiveRerun: false,
712
- subdomain: 'subdomain-from-cli',
713
- testSearchQuery: 'a-search-query-from-cli',
714
- tunnel: true,
715
- };
716
- const defaultTestOverrides = {
717
- allowInsecureCertificates: false,
718
- basicAuth: {
719
- password: 'password-cli',
720
- username: 'username-cli',
721
- },
722
- body: 'a body from cli',
723
- bodyType: 'bodyType from cli',
724
- cookies: {
725
- value: 'cli1=value1;cli2=value2;',
726
- append: false,
727
- },
728
- setCookies: {
729
- value: 'cli1=value1 \n cli2=value2; Domain=example.com \n cli3=value3; Secure; HttpOnly',
730
- append: false,
731
- },
732
- defaultStepTimeout: 11,
733
- deviceIds: ['chrome.laptop_large_from_cli', 'chrome.laptop_small_from_cli', 'firefox.laptop_large_from_cli'],
734
- executionRule: interfaces_1.ExecutionRule.NON_BLOCKING,
735
- followRedirects: false,
736
- headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token from cli' },
737
- locations: ['cli-loc-1', 'cli-loc-2'],
738
- mobileApplicationVersion: 'cli-00000000-0000-0000-0000-000000000000',
739
- resourceUrlSubstitutionRegexes: [
740
- 'from-cli-regex1',
741
- 's/(https://www.)(.*)/$1extra-$2',
742
- 'https://example.com(.*)|http://subdomain.example.com$1',
743
- ],
744
- retry: {
745
- count: 13,
746
- interval: 14,
747
- },
748
- startUrl: 'startUrl-from-cli',
749
- startUrlSubstitutionRegex: 'startUrlSubstitutionRegex-from-cli',
750
- testTimeout: 15,
751
- variables: { cliVar1: 'value1', cliVar2: 'value2' },
752
- };
753
- process.env = overrideEnv;
754
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
755
- command['apiKey'] = overrideCLI.apiKey;
756
- command['appKey'] = overrideCLI.appKey;
757
- command['batchTimeout'] = overrideCLI.batchTimeout;
758
- command['buildCommand'] = overrideCLI.buildCommand;
759
- command['configPath'] = overrideCLI.configPath;
760
- command['datadogSite'] = overrideCLI.datadogSite;
761
- command['failOnCriticalErrors'] = overrideCLI.failOnCriticalErrors;
762
- command['failOnMissingTests'] = overrideCLI.failOnMissingTests;
763
- command['failOnTimeout'] = overrideCLI.failOnTimeout;
764
- command['files'] = overrideCLI.files;
765
- command['jUnitReport'] = overrideCLI.jUnitReport;
766
- command['mobileApplicationVersion'] = defaultTestOverrides.mobileApplicationVersion;
767
- command['mobileApplicationVersionFilePath'] = overrideCLI.mobileApplicationVersionFilePath;
768
- command['publicIds'] = overrideCLI.publicIds;
769
- command['selectiveRerun'] = overrideCLI.selectiveRerun;
770
- command['subdomain'] = overrideCLI.subdomain;
771
- command['tunnel'] = overrideCLI.tunnel;
772
- command['testSearchQuery'] = overrideCLI.testSearchQuery;
773
- command['overrides'] = [
774
- `allowInsecureCertificates=${defaultTestOverrides.allowInsecureCertificates}`,
775
- `basicAuth.password=${(_q = defaultTestOverrides.basicAuth) === null || _q === void 0 ? void 0 : _q.password}`,
776
- `basicAuth.username=${(_r = defaultTestOverrides.basicAuth) === null || _r === void 0 ? void 0 : _r.username}`,
777
- `body=${defaultTestOverrides.body}`,
778
- `bodyType=${defaultTestOverrides.bodyType}`,
779
- `cookies=${defaultTestOverrides.cookies.value}`,
780
- `cookies.append=${defaultTestOverrides.cookies.append}`,
781
- `setCookies=${defaultTestOverrides.setCookies.value}`,
782
- `setCookies.append=${defaultTestOverrides.setCookies.append}`,
783
- `defaultStepTimeout=${defaultTestOverrides.defaultStepTimeout}`,
784
- `deviceIds=${(_s = defaultTestOverrides.deviceIds) === null || _s === void 0 ? void 0 : _s.join(';')}`,
785
- `executionRule=${defaultTestOverrides.executionRule}`,
786
- `followRedirects=${defaultTestOverrides.followRedirects}`,
787
- `headers.Content-Type=${defaultTestOverrides.headers ? defaultTestOverrides.headers['Content-Type'] : ''}`,
788
- `headers.Authorization=${(_t = defaultTestOverrides.headers) === null || _t === void 0 ? void 0 : _t.Authorization}`,
789
- `locations=${(_u = defaultTestOverrides.locations) === null || _u === void 0 ? void 0 : _u.join(';')}`,
790
- `retry.count=${(_v = defaultTestOverrides.retry) === null || _v === void 0 ? void 0 : _v.count}`,
791
- `retry.interval=${(_w = defaultTestOverrides.retry) === null || _w === void 0 ? void 0 : _w.interval}`,
792
- `startUrl=${defaultTestOverrides.startUrl}`,
793
- `startUrlSubstitutionRegex=${defaultTestOverrides.startUrlSubstitutionRegex}`,
794
- `testTimeout=${defaultTestOverrides.testTimeout}`,
795
- `resourceUrlSubstitutionRegexes=${(_x = defaultTestOverrides.resourceUrlSubstitutionRegexes) === null || _x === void 0 ? void 0 : _x.join(';')}`,
796
- `variables.cliVar1=${(_y = defaultTestOverrides.variables) === null || _y === void 0 ? void 0 : _y.cliVar1}`,
797
- `variables.cliVar2=${(_z = defaultTestOverrides.variables) === null || _z === void 0 ? void 0 : _z.cliVar2}`,
798
- ];
799
- yield command['resolveConfig']();
800
- const { mobileApplicationVersionFilePath } = overrideCLI, filteredOverrideCLI = __rest(overrideCLI, ["mobileApplicationVersionFilePath"]);
801
- const expectedCLIOverrideResult = Object.assign(Object.assign({}, filteredOverrideCLI), { defaultTestOverrides: Object.assign(Object.assign({}, defaultTestOverrides), { headers: Object.assign(Object.assign({}, (0, env_1.toStringMap)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_HEADERS)), defaultTestOverrides.headers), mobileApplicationVersionFilePath, variables: Object.assign(Object.assign({}, (0, env_1.toStringMap)(overrideEnv.DATADOG_SYNTHETICS_OVERRIDE_VARIABLES)), defaultTestOverrides.variables) }), proxy: { protocol: 'http' } });
802
- expect(command['config']).toEqual(expectedCLIOverrideResult);
803
- }));
804
- const overrideTestConfig = {
805
- allowInsecureCertificates: false,
806
- basicAuth: {
807
- password: 'password-test-file',
808
- username: 'username-test-file',
809
- },
810
- body: 'a body from test file',
811
- bodyType: 'bodyType from test file',
812
- cookies: {
813
- value: 'test-file1=value1;test-file2=value2;',
814
- append: false,
815
- },
816
- setCookies: {
817
- value: 'test-file1=value1 \n test-file2=value2; Domain=example.com \n test-file3=value3; Secure; HttpOnly',
818
- append: false,
819
- },
820
- defaultStepTimeout: 31,
821
- deviceIds: [
822
- 'chrome.laptop_large_from_test_file',
823
- 'chrome.laptop_small_from_test_file',
824
- 'firefox.laptop_large_from_test_file',
825
- ],
826
- executionRule: interfaces_1.ExecutionRule.NON_BLOCKING,
827
- followRedirects: false,
828
- headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token from test file' },
829
- locations: ['test-file-loc-1', 'test-file-loc-2'],
830
- mobileApplicationVersion: 'test-file-00000000-0000-0000-0000-000000000000',
831
- resourceUrlSubstitutionRegexes: [
832
- 'from-test-file-regex1',
833
- 's/(https://www.)(.*)/$1extra-$2',
834
- 'https://example.com(.*)|http://subdomain.example.com$1',
835
- ],
836
- retry: {
837
- count: 33,
838
- interval: 34,
839
- },
840
- startUrl: 'startUrl-from-test-file',
841
- startUrlSubstitutionRegex: 'startUrlSubstitutionRegex-from-test-file',
842
- testTimeout: 35,
843
- variables: { testFileVar1: 'value1', testFileVar2: 'value2' },
844
- };
845
- const triggerTests = jest.fn(() => {
846
- throw (0, fixtures_1.getAxiosError)(502, { message: 'Bad Gateway' });
847
- });
848
- const apiHelper = (0, fixtures_2.mockApi)({
849
- getTest: jest.fn(() => __awaiter(void 0, void 0, void 0, function* () { return (Object.assign({}, (0, fixtures_2.getApiTest)('publicId'))); })),
850
- triggerTests,
851
- });
852
- const getExpectedTestsToTriggerArguments = (testOverrides) => {
853
- return [
854
- // Parameters we care about.
855
- apiHelper,
856
- [{ suite: 'Suite 1', id: 'aaa-bbb-ccc', testOverrides }],
857
- // Ignore the rest of the parameters.
858
- expect.anything(),
859
- expect.anything(),
860
- expect.anything(),
861
- expect.anything(),
862
- ];
863
- };
864
- const testFile = { name: 'Suite 1', content: { tests: [{ id: 'aaa-bbb-ccc', testOverrides: {} }] } };
865
- test('config file < test file', () => __awaiter(void 0, void 0, void 0, function* () {
866
- const getTestsToTriggerMock = jest.spyOn(testUtils, 'getTestsToTrigger');
867
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
868
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementationOnce((baseConfig) => __awaiter(void 0, void 0, void 0, function* () {
869
- return Object.assign(Object.assign({}, baseConfig), { defaultTestOverrides: Object.assign(Object.assign({}, configFile.defaultTestOverrides), { mobileApplicationVersionFilePath: undefined }), testSearchQuery: undefined });
870
- }));
871
- jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
872
- jest.spyOn(utils, 'getSuites').mockResolvedValue([testFile]);
873
- testFile.content.tests[0].testOverrides = overrideTestConfig;
874
- expect(yield command.execute()).toBe(0);
875
- expect(getTestsToTriggerMock).toHaveBeenNthCalledWith(1, ...getExpectedTestsToTriggerArguments(overrideTestConfig));
876
- }));
877
- test('ENV < test file', () => __awaiter(void 0, void 0, void 0, function* () {
878
- const getTestsToTriggerMock = jest.spyOn(testUtils, 'getTestsToTrigger');
879
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
880
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, _) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
881
- jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
882
- jest.spyOn(utils, 'getSuites').mockResolvedValue([testFile]);
883
- testFile.content.tests[0].testOverrides = overrideTestConfig;
884
- const testOverrideEnv = {
885
- DATADOG_SYNTHETICS_OVERRIDE_ALLOW_INSECURE_CERTIFICATES: 'true',
886
- DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_PASSWORD: 'password-from-env',
887
- DATADOG_SYNTHETICS_OVERRIDE_BASIC_AUTH_USERNAME: 'username-from-env',
888
- DATADOG_SYNTHETICS_OVERRIDE_BODY: 'body-from-env',
889
- DATADOG_SYNTHETICS_OVERRIDE_BODY_TYPE: 'bodyType-from-env',
890
- DATADOG_SYNTHETICS_OVERRIDE_COOKIES: 'cookie1-from-env;cookie2-from-env;cookie3-from-env',
891
- DATADOG_SYNTHETICS_OVERRIDE_COOKIES_APPEND: 'true',
892
- DATADOG_SYNTHETICS_OVERRIDE_SET_COOKIES: 'cookie1-from-env \n cookie2-from-env; Domain=example.com \n cookie3-from-env; Secure; HttpOnly',
893
- DATADOG_SYNTHETICS_OVERRIDE_SET_COOKIES_APPEND: 'true',
894
- DATADOG_SYNTHETICS_OVERRIDE_DEFAULT_STEP_TIMEOUT: '42',
895
- DATADOG_SYNTHETICS_OVERRIDE_DEVICE_IDS: 'chrome.laptop_large_from_env',
896
- DATADOG_SYNTHETICS_OVERRIDE_EXECUTION_RULE: 'BLOCKING',
897
- DATADOG_SYNTHETICS_OVERRIDE_FOLLOW_REDIRECTS: 'true',
898
- DATADOG_SYNTHETICS_OVERRIDE_HEADERS: "{'Content-Type': 'application/json', 'Authorization': 'Bearer token from env'}",
899
- DATADOG_SYNTHETICS_OVERRIDE_LOCATIONS: 'location_1_from_env;location_2_from_env',
900
- DATADOG_SYNTHETICS_OVERRIDE_MOBILE_APPLICATION_VERSION: 'env-00000000-0000-0000-0000-000000000000',
901
- DATADOG_SYNTHETICS_OVERRIDE_RESOURCE_URL_SUBSTITUTION_REGEXES: 'env-regex1;env-regex2',
902
- DATADOG_SYNTHETICS_OVERRIDE_RETRY_COUNT: '5',
903
- DATADOG_SYNTHETICS_OVERRIDE_RETRY_INTERVAL: '100',
904
- DATADOG_SYNTHETICS_OVERRIDE_START_URL: 'startUrl-from-env',
905
- DATADOG_SYNTHETICS_OVERRIDE_START_URL_SUBSTITUTION_REGEX: 'startUrlSubstitutionRegex-from-env',
906
- DATADOG_SYNTHETICS_OVERRIDE_TEST_TIMEOUT: '42',
907
- DATADOG_SYNTHETICS_OVERRIDE_VARIABLES: "{'envVar1': 'value1', 'envVar2': 'value2'}",
908
- };
909
- process.env = testOverrideEnv;
910
- expect(yield command.execute()).toBe(0);
911
- expect(getTestsToTriggerMock).toHaveBeenNthCalledWith(1, ...getExpectedTestsToTriggerArguments(overrideTestConfig));
912
- }));
913
- test('CLI < test file', () => __awaiter(void 0, void 0, void 0, function* () {
914
- var _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
915
- const getTestsToTriggerMock = jest.spyOn(testUtils, 'getTestsToTrigger');
916
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand);
917
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, _) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
918
- jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
919
- jest.spyOn(utils, 'getSuites').mockResolvedValue([testFile]);
920
- const defaultTestOverrides = {
921
- allowInsecureCertificates: false,
922
- basicAuth: {
923
- password: 'password-cli',
924
- username: 'username-cli',
925
- },
926
- body: 'a body from cli',
927
- bodyType: 'bodyType from cli',
928
- cookies: {
929
- value: 'cli1=value1;cli2=value2;',
930
- append: false,
931
- },
932
- setCookies: {
933
- value: 'cli1=value1 \n cli2=value2; Domain=example.com \n cli3=value3; Secure; HttpOnly',
934
- append: false,
935
- },
936
- defaultStepTimeout: 11,
937
- deviceIds: ['chrome.laptop_large_from_cli', 'chrome.laptop_small_from_cli', 'firefox.laptop_large_from_cli'],
938
- executionRule: interfaces_1.ExecutionRule.NON_BLOCKING,
939
- followRedirects: false,
940
- headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token from cli' },
941
- locations: ['cli-loc-1', 'cli-loc-2'],
942
- mobileApplicationVersion: 'cli-00000000-0000-0000-0000-000000000000',
943
- resourceUrlSubstitutionRegexes: [
944
- 'from-cli-regex1',
945
- 's/(https://www.)(.*)/$1extra-$2',
946
- 'https://example.com(.*)|http://subdomain.example.com$1',
947
- ],
948
- retry: {
949
- count: 13,
950
- interval: 14,
951
- },
952
- startUrl: 'startUrl-from-cli',
953
- startUrlSubstitutionRegex: 'startUrlSubstitutionRegex-from-cli',
954
- testTimeout: 15,
955
- variables: { cliVar1: 'value1', cliVar2: 'value2' },
956
- };
957
- command['mobileApplicationVersion'] = defaultTestOverrides.mobileApplicationVersion;
958
- command['overrides'] = [
959
- `allowInsecureCertificates=${defaultTestOverrides.allowInsecureCertificates}`,
960
- `basicAuth.password=${(_0 = defaultTestOverrides.basicAuth) === null || _0 === void 0 ? void 0 : _0.password}`,
961
- `basicAuth.username=${(_1 = defaultTestOverrides.basicAuth) === null || _1 === void 0 ? void 0 : _1.username}`,
962
- `body=${defaultTestOverrides.body}`,
963
- `bodyType=${defaultTestOverrides.bodyType}`,
964
- `cookies=${defaultTestOverrides.cookies.value}`,
965
- `cookies.append=${defaultTestOverrides.cookies.append}`,
966
- `setCookies=${defaultTestOverrides.setCookies.value}`,
967
- `setCookies.append=${defaultTestOverrides.setCookies.append}`,
968
- `defaultStepTimeout=${defaultTestOverrides.defaultStepTimeout}`,
969
- `deviceIds=${(_2 = defaultTestOverrides.deviceIds) === null || _2 === void 0 ? void 0 : _2.join(';')}`,
970
- `executionRule=${defaultTestOverrides.executionRule}`,
971
- `followRedirects=${defaultTestOverrides.followRedirects}`,
972
- `headers.Content-Type=${defaultTestOverrides.headers ? defaultTestOverrides.headers['Content-Type'] : ''}`,
973
- `headers.Authorization=${(_3 = defaultTestOverrides.headers) === null || _3 === void 0 ? void 0 : _3.Authorization}`,
974
- `locations=${(_4 = defaultTestOverrides.locations) === null || _4 === void 0 ? void 0 : _4.join(';')}`,
975
- `retry.count=${(_5 = defaultTestOverrides.retry) === null || _5 === void 0 ? void 0 : _5.count}`,
976
- `retry.interval=${(_6 = defaultTestOverrides.retry) === null || _6 === void 0 ? void 0 : _6.interval}`,
977
- `startUrl=${defaultTestOverrides.startUrl}`,
978
- `startUrlSubstitutionRegex=${defaultTestOverrides.startUrlSubstitutionRegex}`,
979
- `testTimeout=${defaultTestOverrides.testTimeout}`,
980
- `resourceUrlSubstitutionRegexes=${(_7 = defaultTestOverrides.resourceUrlSubstitutionRegexes) === null || _7 === void 0 ? void 0 : _7.join(';')}`,
981
- `variables.cliVar1=${(_8 = defaultTestOverrides.variables) === null || _8 === void 0 ? void 0 : _8.cliVar1}`,
982
- `variables.cliVar2=${(_9 = defaultTestOverrides.variables) === null || _9 === void 0 ? void 0 : _9.cliVar2}`,
983
- ];
984
- yield command['resolveConfig']();
985
- expect(yield command.execute()).toBe(0);
986
- expect(getTestsToTriggerMock).toHaveBeenNthCalledWith(1, ...getExpectedTestsToTriggerArguments(overrideTestConfig));
987
- }));
988
- });
989
- test('fail on non-existing config file', () => __awaiter(void 0, void 0, void 0, function* () {
990
- const writeMock = jest.fn();
991
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: writeMock } });
992
- command['configPath'] = 'non-existing-config-file.json';
993
- yield expect(command.execute()).resolves.toBe(1);
994
- expect(writeMock).toHaveBeenCalledWith(expect.stringMatching('ERROR: invalid config \nConfig file not found'));
995
- }));
996
- });
997
- describe('exit code respects `failOnCriticalErrors`', () => {
998
- test('404 leading to `NO_TESTS_TO_RUN` never exits with 1', () => __awaiter(void 0, void 0, void 0, function* () {
999
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: jest.fn() } });
1000
- command['config'].failOnCriticalErrors = true;
1001
- const apiHelper = (0, fixtures_2.mockApi)({
1002
- getTest: jest.fn(() => {
1003
- throw (0, fixtures_1.getAxiosError)(404, { errors: ['Test not found'] });
1004
- }),
1005
- });
1006
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, _) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
1007
- jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
1008
- jest.spyOn(utils, 'getSuites').mockResolvedValue([(0, fixtures_2.getTestSuite)()]);
1009
- expect(yield command.execute()).toBe(0);
1010
- expect(apiHelper.getTest).toHaveBeenCalledTimes(1);
1011
- }));
1012
- describe.each([false, true])('%s', (failOnCriticalErrors) => {
1013
- const cases = [['HTTP 4xx error', 403], ['HTTP 5xx error', 502], ['Unknown error']];
1014
- const expectedExit = failOnCriticalErrors ? 1 : 0;
1015
- describe.each(cases)('%s', (_, errorCode) => {
1016
- test('unable to obtain test configurations', () => __awaiter(void 0, void 0, void 0, function* () {
1017
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: jest.fn() } });
1018
- command['config'].failOnCriticalErrors = failOnCriticalErrors;
1019
- command['testSearchQuery'] = 'test:search';
1020
- const apiHelper = (0, fixtures_2.mockApi)({
1021
- searchTests: jest.fn(() => {
1022
- throw errorCode ? (0, fixtures_1.getAxiosError)(errorCode, { message: 'Error' }) : new Error('Unknown error');
1023
- }),
1024
- });
1025
- jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
1026
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, __) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
1027
- expect(yield command.execute()).toBe(expectedExit);
1028
- expect(apiHelper.searchTests).toHaveBeenCalledTimes(1);
1029
- }));
1030
- test('unavailable test config', () => __awaiter(void 0, void 0, void 0, function* () {
1031
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: jest.fn() } });
1032
- command['config'].failOnCriticalErrors = failOnCriticalErrors;
1033
- const apiHelper = (0, fixtures_2.mockApi)({
1034
- getTest: jest.fn(() => {
1035
- throw errorCode ? (0, fixtures_1.getAxiosError)(errorCode, { message: 'Error' }) : new Error('Unknown error');
1036
- }),
1037
- });
1038
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, __) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
1039
- jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
1040
- jest.spyOn(utils, 'getSuites').mockResolvedValue([(0, fixtures_2.getTestSuite)()]);
1041
- expect(yield command.execute()).toBe(expectedExit);
1042
- expect(apiHelper.getTest).toHaveBeenCalledTimes(1);
1043
- }));
1044
- test('unable to trigger tests', () => __awaiter(void 0, void 0, void 0, function* () {
1045
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: jest.fn() } });
1046
- command['config'].failOnCriticalErrors = failOnCriticalErrors;
1047
- const apiHelper = (0, fixtures_2.mockApi)({
1048
- getTest: () => __awaiter(void 0, void 0, void 0, function* () { return (0, fixtures_2.getApiTest)('123-456-789'); }),
1049
- triggerTests: jest.fn(() => {
1050
- throw errorCode ? (0, fixtures_1.getAxiosError)(errorCode, { message: 'Error' }) : new Error('Unknown error');
1051
- }),
1052
- });
1053
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, __) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
1054
- jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
1055
- jest.spyOn(utils, 'getSuites').mockResolvedValue([(0, fixtures_2.getTestSuite)()]);
1056
- expect(yield command.execute()).toBe(expectedExit);
1057
- expect(apiHelper.triggerTests).toHaveBeenCalledTimes(1);
1058
- }));
1059
- test('unable to poll test results', () => __awaiter(void 0, void 0, void 0, function* () {
1060
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: jest.fn() } });
1061
- command['config'].failOnCriticalErrors = failOnCriticalErrors;
1062
- const apiHelper = (0, fixtures_2.mockApi)({
1063
- getBatch: () => __awaiter(void 0, void 0, void 0, function* () { return ({ results: [], status: 'passed' }); }),
1064
- getTest: () => __awaiter(void 0, void 0, void 0, function* () { return (0, fixtures_2.getApiTest)('123-456-789'); }),
1065
- pollResults: jest.fn(() => {
1066
- throw errorCode ? (0, fixtures_1.getAxiosError)(errorCode, { message: 'Error' }) : new Error('Unknown error');
1067
- }),
1068
- triggerTests: () => __awaiter(void 0, void 0, void 0, function* () { return fixtures_2.mockTestTriggerResponse; }),
1069
- });
1070
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, __) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
1071
- jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
1072
- jest.spyOn(utils, 'getSuites').mockResolvedValue([(0, fixtures_2.getTestSuite)()]);
1073
- expect(yield command.execute()).toBe(expectedExit);
1074
- expect(apiHelper.pollResults).toHaveBeenCalledTimes(1);
1075
- }));
1076
- });
1077
- });
1078
- });
1079
- describe('exit code respects `failOnMissingTests`', () => {
1080
- const cases = [
1081
- ['only missing tests', false, 0, ['mis-sin-ggg']],
1082
- ['only missing tests', true, 1, ['mis-sin-ggg']],
1083
- ['both missing and available tests', false, 0, ['mis-sin-ggg', 'abc-def-ghi']],
1084
- ['both missing and available tests', true, 1, ['mis-sin-ggg', 'abc-def-ghi']],
1085
- ];
1086
- test.each(cases)('%s with failOnMissingTests=%s exits with %s', (_, failOnMissingTests, exitCode, tests) => __awaiter(void 0, void 0, void 0, function* () {
1087
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: jest.fn() } });
1088
- command['config'].failOnMissingTests = failOnMissingTests;
1089
- const apiHelper = (0, fixtures_2.mockApi)({
1090
- getTest: jest.fn((testId) => __awaiter(void 0, void 0, void 0, function* () {
1091
- if (testId === 'mis-sin-ggg') {
1092
- throw (0, fixtures_1.getAxiosError)(404, { errors: ['Test not found'] });
1093
- }
1094
- return {};
1095
- })),
1096
- });
1097
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, __) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
1098
- jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
1099
- jest.spyOn(utils, 'getSuites').mockResolvedValue([
1100
- {
1101
- content: {
1102
- tests: tests.map((testId) => ({ id: testId })),
1103
- },
1104
- name: 'Suite 1',
1105
- },
1106
- ]);
1107
- expect(yield command.execute()).toBe(exitCode);
1108
- expect(apiHelper.getTest).toHaveBeenCalledTimes(tests.length);
1109
- }));
1110
- });
1111
- describe('API errors logging', () => {
1112
- test('enough context is provided', () => __awaiter(void 0, void 0, void 0, function* () {
1113
- const writeMock = jest.fn();
1114
- const command = (0, fixtures_1.createCommand)(run_tests_command_1.RunTestsCommand, { stdout: { write: writeMock } });
1115
- command['config'].failOnCriticalErrors = true;
1116
- const apiHelper = (0, fixtures_2.mockApi)({
1117
- getTest: jest.fn((testId) => __awaiter(void 0, void 0, void 0, function* () {
1118
- if (testId === 'for-bid-den') {
1119
- const serverError = (0, fixtures_1.getAxiosError)(403, { errors: ['Forbidden'] });
1120
- serverError.config.url = 'tests/for-bid-den';
1121
- throw serverError;
1122
- }
1123
- return { name: testId };
1124
- })),
1125
- });
1126
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementation((config, __) => __awaiter(void 0, void 0, void 0, function* () { return config; }));
1127
- jest.spyOn(api, 'getApiHelper').mockReturnValue(apiHelper);
1128
- jest.spyOn(utils, 'getSuites').mockResolvedValue([
1129
- {
1130
- content: {
1131
- tests: [
1132
- { testOverrides: {}, id: 'aaa-aaa-aaa' },
1133
- { testOverrides: { headers: {} }, id: 'bbb-bbb-bbb' },
1134
- { testOverrides: {}, id: 'for-bid-den' },
1135
- ],
1136
- },
1137
- name: 'Suite 1',
1138
- },
1139
- ]);
1140
- expect(yield command.execute()).toBe(1);
1141
- expect(apiHelper.getTest).toHaveBeenCalledTimes(3);
1142
- expect(writeMock).toHaveBeenCalledTimes(4);
1143
- expect(writeMock).toHaveBeenCalledWith('[aaa-aaa-aaa] Found test "aaa-aaa-aaa"\n');
1144
- expect(writeMock).toHaveBeenCalledWith('[bbb-bbb-bbb] Found test "bbb-bbb-bbb" (1 test override)\n');
1145
- expect(writeMock).toHaveBeenCalledWith('\n ERROR: authorization error \nFailed to get test: query on https://app.datadoghq.com/tests/for-bid-den returned: "Forbidden"\n\n\n');
1146
- expect(writeMock).toHaveBeenCalledWith('Credentials refused, make sure `apiKey`, `appKey` and `datadogSite` are correct.\n');
1147
- }));
1148
- });
1149
- });
1150
- describe('upload-application', () => {
1151
- beforeEach(() => {
1152
- process.env = {};
1153
- jest.restoreAllMocks();
1154
- });
1155
- describe('resolveConfig', () => {
1156
- beforeEach(() => {
1157
- process.env = {};
1158
- });
1159
- test('override from ENV', () => __awaiter(void 0, void 0, void 0, function* () {
1160
- const overrideEnv = {
1161
- DATADOG_API_KEY: 'fake_api_key',
1162
- DATADOG_APP_KEY: 'fake_app_key',
1163
- DATADOG_SITE: 'datadoghq.eu',
1164
- DATADOG_SYNTHETICS_CONFIG_PATH: 'path/to/config.json',
1165
- DATADOG_SYNTHETICS_VERSION_NAME: 'new',
1166
- DATADOG_SYNTHETICS_LATEST: 'true',
1167
- };
1168
- process.env = overrideEnv;
1169
- const command = (0, fixtures_1.createCommand)(upload_application_command_1.UploadApplicationCommand);
1170
- yield command['resolveConfig']();
1171
- expect(command['config']).toEqual(Object.assign(Object.assign({}, upload_application_command_1.UploadApplicationCommand.getDefaultConfig()), { apiKey: overrideEnv.DATADOG_API_KEY, appKey: overrideEnv.DATADOG_APP_KEY, configPath: overrideEnv.DATADOG_SYNTHETICS_CONFIG_PATH, datadogSite: overrideEnv.DATADOG_SITE, versionName: overrideEnv.DATADOG_SYNTHETICS_VERSION_NAME, latest: (0, env_1.toBoolean)(overrideEnv.DATADOG_SYNTHETICS_LATEST) }));
1172
- }));
1173
- test('override from config file', () => __awaiter(void 0, void 0, void 0, function* () {
1174
- const expectedConfig = {
1175
- apiKey: 'fake_api_key',
1176
- appKey: 'fake_app_key',
1177
- configPath: 'src/commands/synthetics/__tests__/config-fixtures/upload-app-config-with-all-keys.json',
1178
- datadogSite: 'datadoghq.eu',
1179
- proxy: { protocol: 'http' },
1180
- mobileApplicationVersionFilePath: 'fake_path/fake_app.apk',
1181
- mobileApplicationId: 'fake-abc',
1182
- versionName: 'new',
1183
- latest: true,
1184
- };
1185
- const command = (0, fixtures_1.createCommand)(upload_application_command_1.UploadApplicationCommand);
1186
- command['configPath'] = 'src/commands/synthetics/__tests__/config-fixtures/upload-app-config-with-all-keys.json';
1187
- yield command['resolveConfig']();
1188
- expect(command['config']).toEqual(expectedConfig);
1189
- }));
1190
- test('override from CLI', () => __awaiter(void 0, void 0, void 0, function* () {
1191
- const overrideCLI = {
1192
- apiKey: 'fake_api_key_cli',
1193
- appKey: 'fake_app_key_cli',
1194
- configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file.json',
1195
- datadogSite: 'datadoghq.cli',
1196
- mobileApplicationVersionFilePath: 'fake_path/cli_fake_app.apk',
1197
- mobileApplicationId: 'fake-abc-cli',
1198
- versionName: 'new cli',
1199
- latest: true,
1200
- };
1201
- const command = (0, fixtures_1.createCommand)(upload_application_command_1.UploadApplicationCommand);
1202
- command['apiKey'] = overrideCLI.apiKey;
1203
- command['appKey'] = overrideCLI.appKey;
1204
- command['configPath'] = overrideCLI.configPath;
1205
- command['datadogSite'] = overrideCLI.datadogSite;
1206
- command['mobileApplicationVersionFilePath'] = overrideCLI.mobileApplicationVersionFilePath;
1207
- command['mobileApplicationId'] = overrideCLI.mobileApplicationId;
1208
- command['versionName'] = overrideCLI.versionName;
1209
- command['latest'] = overrideCLI.latest;
1210
- yield command['resolveConfig']();
1211
- expect(command['config']).toEqual(Object.assign(Object.assign({}, upload_application_command_1.UploadApplicationCommand.getDefaultConfig()), { apiKey: 'fake_api_key_cli', appKey: 'fake_app_key_cli', configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file.json', datadogSite: 'datadoghq.cli', mobileApplicationVersionFilePath: 'fake_path/cli_fake_app.apk', mobileApplicationId: 'fake-abc-cli', versionName: 'new cli', latest: true }));
1212
- }));
1213
- test('override from config file < ENV < CLI', () => __awaiter(void 0, void 0, void 0, function* () {
1214
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementationOnce((baseConfig) => __awaiter(void 0, void 0, void 0, function* () {
1215
- return (Object.assign(Object.assign({}, baseConfig), { apiKey: 'api_key_config_file', appKey: 'app_key_config_file', datadogSite: 'us5.datadoghq.com', mobileApplicationVersionFilePath: 'fake_path/fake_app.apk', mobileApplicationId: 'fake-abc', versionName: 'new', latest: true }));
1216
- }));
1217
- process.env = {
1218
- DATADOG_API_KEY: 'api_key_env',
1219
- DATADOG_APP_KEY: 'app_key_env',
1220
- };
1221
- const command = (0, fixtures_1.createCommand)(upload_application_command_1.UploadApplicationCommand);
1222
- command['apiKey'] = 'api_key_cli';
1223
- command['mobileApplicationVersionFilePath'] = './path/to/application_cli.apk';
1224
- yield command['resolveConfig']();
1225
- expect(command['config']).toEqual(Object.assign(Object.assign({}, upload_application_command_1.UploadApplicationCommand.getDefaultConfig()), { apiKey: 'api_key_cli', appKey: 'app_key_env', datadogSite: 'us5.datadoghq.com', mobileApplicationVersionFilePath: './path/to/application_cli.apk', mobileApplicationId: 'fake-abc', versionName: 'new', latest: true }));
1226
- }));
1227
- });
1228
- describe('any kind of error is reported', () => {
1229
- test.each([
1230
- [
1231
- 'CI error',
1232
- new errors_1.CriticalError('INVALID_MOBILE_APP', 'some message'),
1233
- 'A CI error occurred: [INVALID_MOBILE_APP] some message',
1234
- ],
1235
- ['Endpoint error', new api.EndpointError('some message', 404), 'A backend error occurred: some message (404)'],
1236
- [
1237
- 'Axios error',
1238
- (0, fixtures_1.getAxiosError)(400, { message: 'Bad Request' }),
1239
- 'An unexpected error occurred: AxiosError: Bad Request\n at getAxiosError',
1240
- ],
1241
- ['Unknown error', new Error('Unknown error'), 'An unexpected error occurred: Error: Unknown error\n at '],
1242
- ])('%s', (_, error, expectedMessage) => __awaiter(void 0, void 0, void 0, function* () {
1243
- const writeMock = jest.fn();
1244
- const command = (0, fixtures_1.createCommand)(upload_application_command_1.UploadApplicationCommand, { stdout: { write: writeMock } });
1245
- jest.spyOn(mobile, 'uploadMobileApplicationVersion').mockImplementation(() => {
1246
- throw error;
1247
- });
1248
- expect(yield command['execute']()).toBe(1);
1249
- expect(writeMock).toHaveBeenCalledWith(expect.stringContaining(expectedMessage));
1250
- }));
1251
- });
1252
- });
1253
- describe('import-tests', () => {
1254
- beforeEach(() => {
1255
- process.env = {};
1256
- jest.restoreAllMocks();
1257
- });
1258
- describe('resolveConfig', () => {
1259
- beforeEach(() => {
1260
- process.env = {};
1261
- });
1262
- test('override from ENV', () => __awaiter(void 0, void 0, void 0, function* () {
1263
- var _a, _b;
1264
- const overrideEnv = {
1265
- DATADOG_API_KEY: 'fake_api_key',
1266
- DATADOG_APP_KEY: 'fake_app_key',
1267
- DATADOG_SYNTHETICS_CONFIG_PATH: 'path/to/config.json',
1268
- DATADOG_SITE: 'datadoghq.eu',
1269
- DATADOG_SYNTHETICS_FILES: 'test-file1;test-file2;test-file3',
1270
- DATADOG_SYNTHETICS_PUBLIC_IDS: 'a-public-id;another-public-id',
1271
- DATADOG_SYNTHETICS_TEST_SEARCH_QUERY: 'a-search-query',
1272
- };
1273
- process.env = overrideEnv;
1274
- const command = (0, fixtures_1.createCommand)(import_tests_command_1.ImportTestsCommand);
1275
- yield command['resolveConfig']();
1276
- expect(command['config']).toEqual(Object.assign(Object.assign({}, import_tests_command_1.ImportTestsCommand.getDefaultConfig()), { apiKey: overrideEnv.DATADOG_API_KEY, appKey: overrideEnv.DATADOG_APP_KEY, configPath: overrideEnv.DATADOG_SYNTHETICS_CONFIG_PATH, datadogSite: overrideEnv.DATADOG_SITE, files: (_a = overrideEnv.DATADOG_SYNTHETICS_FILES) === null || _a === void 0 ? void 0 : _a.split(';'), publicIds: (_b = overrideEnv.DATADOG_SYNTHETICS_PUBLIC_IDS) === null || _b === void 0 ? void 0 : _b.split(';'), testSearchQuery: overrideEnv.DATADOG_SYNTHETICS_TEST_SEARCH_QUERY }));
1277
- }));
1278
- test('override from config file', () => __awaiter(void 0, void 0, void 0, function* () {
1279
- const expectedConfig = {
1280
- apiKey: 'fake_api_key',
1281
- appKey: 'fake_app_key',
1282
- configPath: 'src/commands/synthetics/__tests__/config-fixtures/import-tests-config-with-all-keys.json',
1283
- datadogSite: 'datadoghq.eu',
1284
- files: ['my-new-file'],
1285
- proxy: { protocol: 'http' },
1286
- publicIds: ['ran-dom-id1'],
1287
- testSearchQuery: 'a-search-query',
1288
- };
1289
- const command = (0, fixtures_1.createCommand)(import_tests_command_1.ImportTestsCommand);
1290
- command['configPath'] = 'src/commands/synthetics/__tests__/config-fixtures/import-tests-config-with-all-keys.json';
1291
- yield command['resolveConfig']();
1292
- expect(command['config']).toEqual(expectedConfig);
1293
- }));
1294
- test('override from CLI', () => __awaiter(void 0, void 0, void 0, function* () {
1295
- const overrideCLI = {
1296
- apiKey: 'fake_api_key_cli',
1297
- appKey: 'fake_app_key_cli',
1298
- configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file.json',
1299
- datadogSite: 'datadoghq.cli',
1300
- files: ['new-file'],
1301
- publicIds: ['ran-dom-id2'],
1302
- testSearchQuery: 'a-search-query',
1303
- };
1304
- const command = (0, fixtures_1.createCommand)(import_tests_command_1.ImportTestsCommand);
1305
- command['apiKey'] = overrideCLI.apiKey;
1306
- command['appKey'] = overrideCLI.appKey;
1307
- command['configPath'] = overrideCLI.configPath;
1308
- command['datadogSite'] = overrideCLI.datadogSite;
1309
- command['files'] = overrideCLI.files;
1310
- command['publicIds'] = overrideCLI.publicIds;
1311
- command['testSearchQuery'] = overrideCLI.testSearchQuery;
1312
- yield command['resolveConfig']();
1313
- expect(command['config']).toEqual(Object.assign(Object.assign({}, import_tests_command_1.ImportTestsCommand.getDefaultConfig()), { apiKey: 'fake_api_key_cli', appKey: 'fake_app_key_cli', configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file.json', datadogSite: 'datadoghq.cli', files: ['new-file'], publicIds: ['ran-dom-id2'], testSearchQuery: 'a-search-query' }));
1314
- }));
1315
- test('override from config file < ENV < CLI', () => __awaiter(void 0, void 0, void 0, function* () {
1316
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementationOnce((baseConfig) => __awaiter(void 0, void 0, void 0, function* () {
1317
- return (Object.assign(Object.assign({}, baseConfig), { apiKey: 'api_key_config_file', appKey: 'app_key_config_file', datadogSite: 'us5.datadoghq.com' }));
1318
- }));
1319
- process.env = {
1320
- DATADOG_API_KEY: 'api_key_env',
1321
- DATADOG_APP_KEY: 'app_key_env',
1322
- };
1323
- const command = (0, fixtures_1.createCommand)(import_tests_command_1.ImportTestsCommand);
1324
- command['apiKey'] = 'api_key_cli';
1325
- yield command['resolveConfig']();
1326
- expect(command['config']).toEqual(Object.assign(Object.assign({}, import_tests_command_1.ImportTestsCommand.getDefaultConfig()), { apiKey: 'api_key_cli', appKey: 'app_key_env', datadogSite: 'us5.datadoghq.com' }));
1327
- }));
1328
- });
1329
- });
1330
- describe('deploy-tests', () => {
1331
- beforeEach(() => {
1332
- process.env = {};
1333
- jest.restoreAllMocks();
1334
- });
1335
- describe('resolveConfig', () => {
1336
- beforeEach(() => {
1337
- process.env = {};
1338
- });
1339
- test('override from ENV', () => __awaiter(void 0, void 0, void 0, function* () {
1340
- var _a, _b;
1341
- const overrideEnv = {
1342
- DATADOG_API_KEY: 'fake_api_key',
1343
- DATADOG_APP_KEY: 'fake_app_key',
1344
- DATADOG_SYNTHETICS_CONFIG_PATH: 'path/to/config.json',
1345
- DATADOG_SITE: 'datadoghq.eu',
1346
- DATADOG_SUBDOMAIN: 'custom',
1347
- DATADOG_SYNTHETICS_FILES: 'test-file1;test-file2;test-file3',
1348
- DATADOG_SYNTHETICS_PUBLIC_IDS: 'a-public-id;another-public-id',
1349
- };
1350
- process.env = overrideEnv;
1351
- const command = (0, fixtures_1.createCommand)(deploy_tests_command_1.DeployTestsCommand);
1352
- yield command['resolveConfig']();
1353
- expect(command['config']).toEqual(Object.assign(Object.assign({}, deploy_tests_command_1.DeployTestsCommand.getDefaultConfig()), { apiKey: overrideEnv.DATADOG_API_KEY, appKey: overrideEnv.DATADOG_APP_KEY, configPath: overrideEnv.DATADOG_SYNTHETICS_CONFIG_PATH, datadogSite: overrideEnv.DATADOG_SITE, files: (_a = overrideEnv.DATADOG_SYNTHETICS_FILES) === null || _a === void 0 ? void 0 : _a.split(';'), publicIds: (_b = overrideEnv.DATADOG_SYNTHETICS_PUBLIC_IDS) === null || _b === void 0 ? void 0 : _b.split(';'), subdomain: overrideEnv.DATADOG_SUBDOMAIN }));
1354
- }));
1355
- test('override from config file', () => __awaiter(void 0, void 0, void 0, function* () {
1356
- const expectedConfig = {
1357
- apiKey: 'fake_api_key',
1358
- appKey: 'fake_app_key',
1359
- configPath: 'src/commands/synthetics/__tests__/config-fixtures/deploy-tests-config-with-all-keys.json',
1360
- datadogSite: 'datadoghq.eu',
1361
- files: ['my-new-file'],
1362
- proxy: { protocol: 'http' },
1363
- publicIds: ['ran-dom-id1'],
1364
- subdomain: 'ppa',
1365
- };
1366
- const command = (0, fixtures_1.createCommand)(deploy_tests_command_1.DeployTestsCommand);
1367
- command['configPath'] = 'src/commands/synthetics/__tests__/config-fixtures/deploy-tests-config-with-all-keys.json';
1368
- yield command['resolveConfig']();
1369
- expect(command['config']).toEqual(expectedConfig);
1370
- }));
1371
- test('override from CLI', () => __awaiter(void 0, void 0, void 0, function* () {
1372
- const overrideCLI = {
1373
- apiKey: 'fake_api_key_cli',
1374
- appKey: 'fake_app_key_cli',
1375
- configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file.json',
1376
- datadogSite: 'datadoghq.cli',
1377
- files: ['new-file'],
1378
- publicIds: ['ran-dom-id2'],
1379
- subdomain: 'subdomain-from-cli',
1380
- };
1381
- const command = (0, fixtures_1.createCommand)(deploy_tests_command_1.DeployTestsCommand);
1382
- command['apiKey'] = overrideCLI.apiKey;
1383
- command['appKey'] = overrideCLI.appKey;
1384
- command['configPath'] = overrideCLI.configPath;
1385
- command['datadogSite'] = overrideCLI.datadogSite;
1386
- command['files'] = overrideCLI.files;
1387
- command['publicIds'] = overrideCLI.publicIds;
1388
- command['subdomain'] = overrideCLI.subdomain;
1389
- yield command['resolveConfig']();
1390
- expect(command['config']).toEqual(Object.assign(Object.assign({}, deploy_tests_command_1.DeployTestsCommand.getDefaultConfig()), { apiKey: 'fake_api_key_cli', appKey: 'fake_app_key_cli', configPath: 'src/commands/synthetics/__tests__/config-fixtures/empty-config-file.json', datadogSite: 'datadoghq.cli', files: ['new-file'], publicIds: ['ran-dom-id2'], subdomain: 'subdomain-from-cli' }));
1391
- }));
1392
- test('override from config file < ENV < CLI', () => __awaiter(void 0, void 0, void 0, function* () {
1393
- jest.spyOn(ciUtils, 'resolveConfigFromFile').mockImplementationOnce((baseConfig) => __awaiter(void 0, void 0, void 0, function* () {
1394
- return (Object.assign(Object.assign({}, baseConfig), { apiKey: 'api_key_config_file', appKey: 'app_key_config_file', datadogSite: 'us5.datadoghq.com' }));
1395
- }));
1396
- process.env = {
1397
- DATADOG_API_KEY: 'api_key_env',
1398
- DATADOG_APP_KEY: 'app_key_env',
1399
- };
1400
- const command = (0, fixtures_1.createCommand)(deploy_tests_command_1.DeployTestsCommand);
1401
- command['apiKey'] = 'api_key_cli';
1402
- yield command['resolveConfig']();
1403
- expect(command['config']).toEqual(Object.assign(Object.assign({}, deploy_tests_command_1.DeployTestsCommand.getDefaultConfig()), { apiKey: 'api_key_cli', appKey: 'app_key_env', datadogSite: 'us5.datadoghq.com' }));
1404
- }));
1405
- });
1406
- });
1407
- //# sourceMappingURL=cli.test.js.map