Member Junction
    Preparing search index...
    • Registers llm on the real MJGlobal.Instance.ClassFactory under one or more DriverClass names — exactly how production drivers resolve. Every ClassFactory.CreateInstance<BaseLLM>(BaseLLM, driverClass, apiKey) for a registered name yields the SAME scripted instance, so a test scripts and asserts through one object no matter how many drivers the code under test instantiates.

      Registrations persist on the MJGlobal singleton and the ClassFactory has no unregister API. In unit tests, pair with resetMJSingletons() from this package in beforeEach/afterEach so each test gets a fresh factory. In a long-lived process that must keep its real providers (the integration suite runs every bundle in one process), call the returned restore() in a finally instead: it re-registers, above the TestLLM, whatever class each name resolved to before. A name that had no prior registration has nothing to restore and keeps resolving to the TestLLM. The TestLLM is registered at priority or above every registration the name already has, whichever is higher, so it also wins over a class an earlier restore() put back.

      Parameters

      • llm: TestLLM
      • driverClass: string | string[]
      • priority: number = 100

      Returns () => void

      restore — hands every name back to its previous class.