Skip to content

[Due for payment 2025-05-30] [$250] [Test] OnyxDerivedTest not working as expected #61897

Closed

Description

@kacper-mikolajczak

Summary

OnyxDerivedTest are giving false positive results.

Action Performed:

  1. Add crashing assertion to any of OnyxDerivedTest tests: `expect(1).toBe(2)
  2. Run npm run test -- OnyxDerivedTest

Expected Result:

Test that was supplied with crashing assertion should fail

Actual Result:

All tests passed

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021923022935652145824
  • Upwork Job ID: 1923022935652145824
  • Last Price Increase: 2025-06-07
Issue OwnerCurrent Issue Owner: @slafortune

Activity

  1. added
    Daily
    Bug
    on May 13, 2025
  2. melvin-bot commented on May 13, 2025

    @melvin-bot

    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.

  3. kacper-mikolajczak commented on May 13, 2025

    @kacper-mikolajczak
    ContributorAuthor
  4. nabi-ebrahimi commented on May 13, 2025

    @nabi-ebrahimi
    Contributor

    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/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 () => {
                await waitForBatchedUpdates();
    
                const derivedReportAttributes = await OnyxUtils.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)

  5. hoangzinh commented on May 15, 2025

    @hoangzinh
    Contributor

    Hi @kacper-mikolajczak, will you work on this issue or someone else?

  6. added
    External
    on May 15, 2025
  7. changed the title [-][Test] OnyxDerivedTest not working as expected[/-] [+][$250] [Test] OnyxDerivedTest not working as expected[/+] on May 15, 2025
  8. melvin-bot commented on May 15, 2025

    @melvin-bot
  9. added
    Help Wanted
    on May 15, 2025
  10. melvin-bot commented on May 15, 2025

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak (External)

  11. 30 remaining items

  12. melvin-bot commented on May 31, 2025

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  13. melvin-bot commented on Jun 2, 2025

    @melvin-bot

    @slafortune Whoops! This issue is 2 days overdue. Let's get this updated quick!

  14. slafortune commented on Jun 2, 2025

    @slafortune
    Contributor

    @eVoloshchak can you complete the checklist when you get a chance?

  15. melvin-bot commented on Jun 6, 2025

    @melvin-bot

    @slafortune Whoops! This issue is 2 days overdue. Let's get this updated quick!

  16. melvin-bot commented on Jun 7, 2025

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  17. eVoloshchak commented on Jun 8, 2025

    @eVoloshchak
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 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.

      Link to issue:

    Regression Test Proposal

    Precondition:

    Test:

    Do we agree 👍 or 👎

  18. melvin-bot commented on Jun 10, 2025

    @melvin-bot

    @slafortune 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  19. luacmartins commented on Jun 10, 2025

    @luacmartins
    Contributor

    Are we good to close this issue?

  20. slafortune commented on Jun 10, 2025

    @slafortune
    Contributor

    Now we can - I was waiting for the checklist to be complete to post the payment summary.

  21. slafortune commented on Jun 10, 2025

    @slafortune
    Contributor

    @eVoloshchak Role C+ requires payment through NewDot Manual Requests - Due $250

  22. garrettmknight commented on Dec 7, 2025

    @garrettmknight
    Contributor

    $250 approved for @eVoloshchak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternalHelp Wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions