DataDog / browser-sdk

Datadog Browser SDK
Apache License 2.0
279 stars 130 forks source link

♻️ [RUM-5101] Use registerCleanupTask instead of afterEach for test cleanup #2837

Open amortemousque opened 1 week ago

amortemousque commented 1 week ago

Motivation

Previously, we had to manually clean up every test mock in the afterEach block of every test. (ex)

Now, with registerCleanupTask, the cleanup task is automatically registered directly from the test mock itself, simplifying the process (ex)

Let’s generalize its usage!

Changes

Uses registerCleanupTask for

Testing


I have gone over the contributing documentation.

cit-pr-commenter[bot] commented 1 week ago

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 161.24 KiB 161.24 KiB 0 B 0.00%
Logs 57.96 KiB 57.96 KiB 0 B 0.00%
Rum Slim 109.18 KiB 109.18 KiB 0 B 0.00%
Worker 25.21 KiB 25.21 KiB 0 B 0.00%

🚀 CPU Performance | Action Name | Base Average Cpu Time (ms) | Local Average Cpu Time (ms) | 𝚫 | | --- | --- | --- | --- | | addglobalcontext | 0.001 | 0.002 | 0.000 | | addaction | 0.032 | 0.033 | 0.002 | | adderror | 0.031 | 0.036 | 0.005 | | addtiming | 0.001 | 0.001 | 0.000 | | startview | 0.977 | 0.884 | -0.092 | | startstopsessionreplayrecording | 0.791 | 0.888 | 0.097 | | logmessage | 0.019 | 0.020 | 0.001 |
🧠 Memory Performance | Action Name | Base Consumption Memory (bytes) | Local Consumption Memory (bytes) | 𝚫 (bytes) | | --- | --- | --- | --- | | addglobalcontext | 19.32 KiB | 20.16 KiB | 865 B | | addaction | 69.04 KiB | 72.70 KiB | 3.66 KiB | | adderror | 85.08 KiB | 85.33 KiB | 250 B | | addtiming | 18.97 KiB | 18.43 KiB | -559 B | | startview | 330.91 KiB | 336.16 KiB | 5.25 KiB | | startstopsessionreplayrecording | 13.34 KiB | 13.49 KiB | 154 B | | logmessage | 67.70 KiB | 71.02 KiB | 3.32 KiB |

🔗 RealWorld

codecov-commenter commented 19 hours ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 93.35%. Comparing base (5e97b4e) to head (161b9f2).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2837 +/- ## ========================================== + Coverage 93.34% 93.35% +0.01% ========================================== Files 263 263 Lines 7525 7524 -1 Branches 1676 1675 -1 ========================================== Hits 7024 7024 + Misses 501 500 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.