Commit 7fad9f5
[EDR Workflows] Speed up MS Defender runscript Jest tests by mocking p-retry (#268311)
## Summary
Two tests in `ms_defender_endpoint_actions_client.test.ts` (`should
throw error when GET_ACTIONS returns no action details after retry` and
`should throw error when GET_ACTIONS call fails`) intermittently
exceeded Jest's 5s default. Both exercise the production retry path in
`fetchAndValidateRunscriptActionDetails`, which uses `pRetry` with
`retries: 5, minTimeout: 300, maxTimeout: 1500, factor: 1.5` — ~4s of
real-time sleep before the outer catch returns `Action details not
found`.
This PR mocks `p-retry` at the file level (delegating to the real
implementation by default), and short-circuits it with
`mockImplementationOnce(async (fn) => fn(1))` in the two slow tests.
Mirrors the existing pattern in `license_watch.test.ts` and
`reference_data/helpers.test.ts`. The two `// TODO: Fix this slow test`
markers are removed.1 parent c590144 commit 7fad9f5
1 file changed
Lines changed: 11 additions & 2 deletions
File tree
- x-pack/solutions/security/plugins/security_solution/server/endpoint/services/actions/clients/microsoft/defender/endpoint
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
49 | 55 | | |
| 56 | + | |
50 | 57 | | |
51 | 58 | | |
52 | 59 | | |
| |||
603 | 610 | | |
604 | 611 | | |
605 | 612 | | |
606 | | - | |
607 | 613 | | |
608 | 614 | | |
609 | 615 | | |
| |||
630 | 636 | | |
631 | 637 | | |
632 | 638 | | |
| 639 | + | |
| 640 | + | |
633 | 641 | | |
634 | 642 | | |
635 | 643 | | |
| |||
642 | 650 | | |
643 | 651 | | |
644 | 652 | | |
645 | | - | |
646 | 653 | | |
647 | 654 | | |
648 | 655 | | |
| |||
664 | 671 | | |
665 | 672 | | |
666 | 673 | | |
| 674 | + | |
| 675 | + | |
667 | 676 | | |
668 | 677 | | |
669 | 678 | | |
| |||
0 commit comments