You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2025-05-30] [$250] [Test] OnyxDerivedTest not working as expected #61897
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Please re-state the problem that we are trying to solve in this issue.
Tests in OnyxDerivedTest are giving false-positive results — they appear to pass even when a clearly failing assertion like expect(1).toBe(2) is added. This gives the false impression that the test logic is correct when it may not even be executing.
What is the root cause of that problem?
Several tests use waitForBatchedUpdates().then(...) without properly awaiting the returned promise. Because Jest does not wait for these promises to resolve, any assertions inside them are never executed. As a result, even failing assertions do not cause the test to fail, and Jest incorrectly reports the test as passed.
What changes do you think we should make in order to solve the problem?
We should refactor all affected tests to use async/await syntax instead of .then(...) chaining. Specifically, convert the test functions to async, await the waitForBatchedUpdates() call, and then perform the remaining logic and assertions. This ensures Jest waits for the entire async test body before considering the test complete. example change
it('returns empty reports when dependencies are not set',async()=>{awaitwaitForBatchedUpdates();constderivedReportAttributes=awaitOnyxUtils.get(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES);expect(derivedReportAttributes).toEqual({reports: {},locale: null,});});
We can apply the suggested change in the following places: here, here, and here.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
None
What alternative solutions did you explore? (Optional)
1a. Result of the original design (eg. a case wasn't considered)
1b. Mistake during implementation
1c. Backend bug
1z. Other:
Where bug was reported:
2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
2b. Reported on staging (eg. found during regression or PR testing)
2d. Reported on a PR
2z. Other: Does not apply, this isn't an bug in the App, this is a bug in test suite
Who reported the bug:
3a. Expensify user
3b. Expensify employee
3c. Contributor
3d. QA
3z. Other: N/A
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: no offending PR, this is the result of the original tests implementation
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: regression wasn't critical
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
No regression tests are needed as this was a bug in unit tests suite
Regression Test Proposal Template
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Activity
melvin-bot commentedon May 13, 2025
Triggered auto assignment to @slafortune (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.kacper-mikolajczak commentedon May 13, 2025
CC @TMisiukiewicz @hoangzinh
nabi-ebrahimi commentedon May 13, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
Tests in OnyxDerivedTest are giving false-positive results — they appear to pass even when a clearly failing assertion like
expect(1).toBe(2)is added. This gives the false impression that the test logic is correct when it may not even be executing.What is the root cause of that problem?
Several tests use
waitForBatchedUpdates().then(...)without properly awaiting the returned promise. Because Jest does not wait for these promises to resolve, any assertions inside them are never executed. As a result, even failing assertions do not cause the test to fail, and Jest incorrectly reports the test as passed.What changes do you think we should make in order to solve the problem?
We should refactor all affected tests to use
async/awaitsyntax instead of.then(...)chaining. Specifically, convert the test functions toasync,awaitthewaitForBatchedUpdates()call, and then perform the remaining logic and assertions. This ensures Jest waits for the entire async test body before considering the test complete. example changeWe can apply the suggested change in the following places: here, here, and here.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
None
What alternative solutions did you explore? (Optional)
hoangzinh commentedon May 15, 2025
Hi @kacper-mikolajczak, will you work on this issue or someone else?
[-][Test] OnyxDerivedTest not working as expected[/-][+][$250] [Test] OnyxDerivedTest not working as expected[/+]melvin-bot commentedon May 15, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021923022935652145824
melvin-bot commentedon May 15, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak (
External)30 remaining items
melvin-bot commentedon May 31, 2025
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
melvin-bot commentedon Jun 2, 2025
@slafortune Whoops! This issue is 2 days overdue. Let's get this updated quick!
slafortune commentedon Jun 2, 2025
@eVoloshchak can you complete the checklist when you get a chance?
melvin-bot commentedon Jun 6, 2025
@slafortune Whoops! This issue is 2 days overdue. Let's get this updated quick!
melvin-bot commentedon Jun 7, 2025
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
eVoloshchak commentedon Jun 8, 2025
BugZero Checklist:
Bug classification
Source of bug:
Where bug was reported:
Who reported the bug:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: no offending PR, this is the result of the original tests implementation
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: regression wasn't critical
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
No regression tests are needed as this was a bug in unit tests suite
Regression Test Proposal Template
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
melvin-bot commentedon Jun 10, 2025
@slafortune 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
luacmartins commentedon Jun 10, 2025
Are we good to close this issue?
slafortune commentedon Jun 10, 2025
Now we can - I was waiting for the checklist to be complete to post the payment summary.
slafortune commentedon Jun 10, 2025
@eVoloshchak Role C+ requires payment through NewDot Manual Requests - Due $250
garrettmknight commentedon Dec 7, 2025
$250 approved for @eVoloshchak