Skip to content

Commit

Permalink
[Security Solution] [Attack discovery] Fixes a flakey jest test (elas…
Browse files Browse the repository at this point in the history
…tic#191736)

Fixes a flakey jest test that failed twice since it was introduced ~2 months ago in [this pr](elastic#186679), as tracked by elastic#189757

### CI and desk flake testing

To test the fix for fakyness, it ran `10,000` times in CI, and locally, with a `100%` success rate. (The test was wrapped in a loop to execute 10,000 times.)

- Tested in CI 10,000 times via following Buildkite build:

:green_heart: Build Succeeded
[Buildkite Build](https://buildkite.com/elastic/kibana-pull-request/builds/230901)

The 10,000 passing test runs are included in the following (abbreviated) build log output:

```
Ran all test suites.
$ node scripts/jest --config x-pack/plugins/security_solution/public/attack_discovery/jest.config.js
actual full command is:
NODE_OPTIONS="--max-old-space-size=12288 --trace-warnings" node ./scripts/jest --config="x-pack/plugins/security_solution/public/attack_discovery/jest.config.js" --runInBand --coverage=false --passWithNoTests
 PASS  x-pack/plugins/security_solution/public/attack_discovery/pages/loading_callout/countdown/index.test.tsx (742.054 s)
# other passing tests...

Test Suites: 54 passed, 54 total
Tests:       10297 passed, 10297 total
Snapshots:   0 total
Time:        962.106 s
```

- Tested locally 10,000 times, as illustrated by the following console output:

```
    ✓ renders the expected the timer text - iteration 9996 (43 ms)
    ✓ renders the expected the timer text - iteration 9997 (44 ms)
    ✓ renders the expected the timer text - iteration 9998 (48 ms)
    ✓ renders the expected the timer text - iteration 9999 (49 ms)
    ✓ renders the expected the timer text - iteration 10000 (46 ms)

Test Suites: 1 passed, 1 total
Tests:       10002 passed, 10002 total
Snapshots:   0 total
Time:        294.54 s
Ran all test suites matching /x-pack\/plugins\/security_solution\/public\/attack_discovery\/pages\/loading_callout\/countdown\/index.test.tsx/i.
```
  • Loading branch information
andrew-goldstein authored Aug 29, 2024
1 parent 55781b7 commit e0f8eb1
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Countdown', () => {
];

beforeAll(() => {
jest.useFakeTimers({ legacyFakeTimers: true });
jest.useFakeTimers();
});

beforeEach(() => {
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('Countdown', () => {
);

act(() => {
jest.runOnlyPendingTimers();
jest.advanceTimersByTime(1000);
});

expect(screen.getByTestId('timerText')).toHaveTextContent('00:59');
Expand Down

0 comments on commit e0f8eb1

Please sign in to comment.