Support async test content in mochalite

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • DevProd Correctness
    • Correctness 2025-06-30
    • 200
    • None
    • 3
    • Hour
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      mochalite does not await anything async, which can lead to passing tests that haven't actually run their intended content.

      Below is an example of an async test that can't leverage mochalite:

      // Setup
      import {workerThread} from "jstests/concurrency/fsm_libs/worker_thread.js";
      const conn = MongoRunner.runMongod();
      
      function setTimeout(fn, ms) {
          const args = {
              host: conn.host,
              dbName: 'test',
              tid: 'thread0',
              clusterOptions: {sharded: false, replication: false},
              latch: new CountDownLatch(1),
              errorLatch: new CountDownLatch(1)
          };
          workerThread.main([], args, function() {
              sleep(ms);
              fn();
          });
      }
      
      // Test
      let hit = false;
      let p = new Promise(resolve => {    
          setTimeout(() => {
              hit = true;
              resolve();
          }, 5_000)
      });
      assert.eq(hit, false);
      await p;
      assert.eq(hit, true);
      
      // Cleanup
      MongoRunner.stopMongod(conn);
      

            Assignee:
            Steve McClure
            Reporter:
            Steve McClure
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: