Mochalite after() hook doesn't run after assertion failures in it() blocks

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • DevProd Correctness
    • Fully Compatible
    • Correctness 2025-08-11
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      Mochalite framework should run after() hook even if assertion failures occur in it() blocks. 

      Steps to Reproduce

      1. import {after, it} from "jstests/libs/mochalite.js";
        it("assertion failure", function() {     assert(false); }

        );
        after(function()

        {     jsTest.info.log("this should run."); }

        );

      Expected Result

      The after block should run even though the assert failed in the it() block.

      Actual Result

      after() block doesn't run.

      Impact

      We currently can't use the mochalite framework for testing as we need to clean up some test set up after the test runs. Since the mochalite after() doesn't work, we are forced to use try/finally blocks in testing.

            Assignee:
            Steve McClure
            Reporter:
            Erin Zhu
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: