@llmist/testing 16.0.4 → 16.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -648,25 +648,18 @@ declare class MockBuilder {
648
648
  /**
649
649
  * Match calls to a specific model (by name, supports partial matching).
650
650
  *
651
- * @example
652
- * mockLLM().forModel('gpt-5')
653
- * mockLLM().forModel('claude') // matches any Claude model
651
+ * @alias forModel
654
652
  */
655
653
  forModel(modelName: string): this;
656
654
  /**
657
655
  * Match calls to any model.
658
656
  * Useful when you want to mock responses regardless of the model used.
659
- *
660
- * @example
661
- * mockLLM().forAnyModel()
662
657
  */
663
658
  forAnyModel(): this;
664
659
  /**
665
660
  * Match calls to a specific provider.
666
661
  *
667
- * @example
668
- * mockLLM().forProvider('openai')
669
- * mockLLM().forProvider('anthropic')
662
+ * @alias forProvider
670
663
  */
671
664
  forProvider(provider: string): this;
672
665
  /**
@@ -722,6 +715,12 @@ declare class MockBuilder {
722
715
  * })
723
716
  */
724
717
  when(matcher: MockMatcher): this;
718
+ /**
719
+ * Match when any message contains an image.
720
+ *
721
+ * @alias whenMessageHasImage
722
+ */
723
+ forImage(): this;
725
724
  /**
726
725
  * Match when any message contains an image.
727
726
  *
@@ -729,6 +728,12 @@ declare class MockBuilder {
729
728
  * mockLLM().whenMessageHasImage().returns("I see an image of a sunset.")
730
729
  */
731
730
  whenMessageHasImage(): this;
731
+ /**
732
+ * Match when any message contains audio.
733
+ *
734
+ * @alias whenMessageHasAudio
735
+ */
736
+ forAudio(): this;
732
737
  /**
733
738
  * Match when any message contains audio.
734
739
  *
@@ -739,10 +744,34 @@ declare class MockBuilder {
739
744
  /**
740
745
  * Match based on the number of images in the last message.
741
746
  *
747
+ * @alias whenImageCount
748
+ */
749
+ withImageCount(predicate: (count: number) => boolean | number): this;
750
+ /**
751
+ * Match based on the number of images in the conversation.
752
+ *
742
753
  * @example
743
754
  * mockLLM().whenImageCount((n) => n >= 2).returns("Comparing multiple images...")
744
755
  */
745
756
  whenImageCount(predicate: (count: number) => boolean): this;
757
+ /**
758
+ * Return a sequence of responses. Each time the mock matches, it will return the next response in the sequence.
759
+ * If the sequence reaches the end, it will cycle back to the beginning.
760
+ *
761
+ * @example
762
+ * mockLLM().returnsSequence([
763
+ * { text: 'First response' },
764
+ * { text: 'Second response' }
765
+ * ])
766
+ */
767
+ returnsSequence(responses: MockResponse[]): this;
768
+ /**
769
+ * Set a dynamic response generator function.
770
+ * Equivalent to withResponse(fn).
771
+ *
772
+ * @alias withResponse
773
+ */
774
+ returnsDynamic(generator: (context: MockMatcherContext) => MockResponse | Promise<MockResponse>): this;
746
775
  /**
747
776
  * Set the text response to return.
748
777
  * Can be a static string or a function that returns a string dynamically.
@@ -1291,6 +1320,11 @@ declare class MockManager {
1291
1320
  * Helper function to get the global mock manager instance.
1292
1321
  */
1293
1322
  declare function getMockManager(options?: MockOptions): MockManager;
1323
+ /**
1324
+ * Reset the global MockManager instance.
1325
+ * Useful for clearing all mocks and state between tests.
1326
+ */
1327
+ declare function resetMocks(): void;
1294
1328
 
1295
1329
  /**
1296
1330
  * Create a mock LLM stream from a mock response.
@@ -1419,4 +1453,43 @@ declare function createEmptyStream(): LLMStream;
1419
1453
  */
1420
1454
  declare function createErrorStream(chunksBeforeError: LLMStreamChunk[], error: Error): LLMStream;
1421
1455
 
1422
- export { type MockAudioData, MockBuilder, MockConversationManager, type MockGadget, MockGadgetBuilder, type MockGadgetConfig, type MockImageData, MockManager, type MockMatcher, type MockMatcherContext, type MockOptions, MockPromptRecorder, MockProviderAdapter, type MockRegistration, type MockResponse, type MockStats, type RecordedCall, type TestEnvironment, type TestEnvironmentOptions, type TestGadgetOptions, type TestGadgetResult, collectOutput, collectStream, collectStreamText, createAssistantMessage, createConversation, createConversationWithGadgets, createEmptyStream, createErrorStream, createLargeConversation, createMinimalConversation, createMockAdapter, createMockClient, createMockConversationManager, createMockGadget, createMockPrompt, createMockReadable, createMockStream, createMockWritable, createSystemMessage, createTestEnvironment, createTestStream, createTextMockStream, createTextStream, createUserMessage, estimateTokens, getBufferedOutput, getMockManager, getStreamFinalChunk, mockGadget, mockLLM, testGadget, testGadgetBatch, waitFor };
1456
+ /**
1457
+ * Mock TUI App interface.
1458
+ */
1459
+ interface MockTUIApp {
1460
+ setProfiles: any;
1461
+ setFocusMode: any;
1462
+ startWaitingForPrompt: any;
1463
+ destroy: any;
1464
+ onQuit: any;
1465
+ onCancel: any;
1466
+ showLLMCallStart: any;
1467
+ updateStreamingTokens: any;
1468
+ clearRetry: any;
1469
+ showThrottling: any;
1470
+ addSystemMessage: any;
1471
+ clearThrottling: any;
1472
+ showRetry: any;
1473
+ showApproval: any;
1474
+ waitForInput: any;
1475
+ subscribeToTree: any;
1476
+ handleEvent: any;
1477
+ addGadgetCost: any;
1478
+ flushText: any;
1479
+ resetAbort: any;
1480
+ startNewSession: any;
1481
+ showUserMessage: any;
1482
+ clearPreviousSession: any;
1483
+ clearStatusBar: any;
1484
+ onMidSessionInput: any;
1485
+ waitForPrompt: any;
1486
+ getAbortSignal: any;
1487
+ }
1488
+ /**
1489
+ * Creates a mock TUI app for testing.
1490
+ *
1491
+ * NOTE: This currently uses Vitest's `vi` for mocks.
1492
+ */
1493
+ declare const createMockTUIApp: () => MockTUIApp;
1494
+
1495
+ export { type MockAudioData, MockBuilder, MockConversationManager, type MockGadget, MockGadgetBuilder, type MockGadgetConfig, type MockImageData, MockManager, type MockMatcher, type MockMatcherContext, type MockOptions, MockPromptRecorder, MockProviderAdapter, type MockRegistration, type MockResponse, type MockStats, type MockTUIApp, type RecordedCall, type TestEnvironment, type TestEnvironmentOptions, type TestGadgetOptions, type TestGadgetResult, collectOutput, collectStream, collectStreamText, createAssistantMessage, createConversation, createConversationWithGadgets, createEmptyStream, createErrorStream, createLargeConversation, createMinimalConversation, createMockAdapter, createMockClient, createMockConversationManager, createMockGadget, createMockPrompt, createMockReadable, createMockStream, createMockTUIApp, createMockWritable, createSystemMessage, createTestEnvironment, createTestStream, createTextMockStream, createTextStream, createUserMessage, estimateTokens, getBufferedOutput, getMockManager, getStreamFinalChunk, mockGadget, mockLLM, resetMocks, testGadget, testGadgetBatch, waitFor };
package/dist/index.d.ts CHANGED
@@ -648,25 +648,18 @@ declare class MockBuilder {
648
648
  /**
649
649
  * Match calls to a specific model (by name, supports partial matching).
650
650
  *
651
- * @example
652
- * mockLLM().forModel('gpt-5')
653
- * mockLLM().forModel('claude') // matches any Claude model
651
+ * @alias forModel
654
652
  */
655
653
  forModel(modelName: string): this;
656
654
  /**
657
655
  * Match calls to any model.
658
656
  * Useful when you want to mock responses regardless of the model used.
659
- *
660
- * @example
661
- * mockLLM().forAnyModel()
662
657
  */
663
658
  forAnyModel(): this;
664
659
  /**
665
660
  * Match calls to a specific provider.
666
661
  *
667
- * @example
668
- * mockLLM().forProvider('openai')
669
- * mockLLM().forProvider('anthropic')
662
+ * @alias forProvider
670
663
  */
671
664
  forProvider(provider: string): this;
672
665
  /**
@@ -722,6 +715,12 @@ declare class MockBuilder {
722
715
  * })
723
716
  */
724
717
  when(matcher: MockMatcher): this;
718
+ /**
719
+ * Match when any message contains an image.
720
+ *
721
+ * @alias whenMessageHasImage
722
+ */
723
+ forImage(): this;
725
724
  /**
726
725
  * Match when any message contains an image.
727
726
  *
@@ -729,6 +728,12 @@ declare class MockBuilder {
729
728
  * mockLLM().whenMessageHasImage().returns("I see an image of a sunset.")
730
729
  */
731
730
  whenMessageHasImage(): this;
731
+ /**
732
+ * Match when any message contains audio.
733
+ *
734
+ * @alias whenMessageHasAudio
735
+ */
736
+ forAudio(): this;
732
737
  /**
733
738
  * Match when any message contains audio.
734
739
  *
@@ -739,10 +744,34 @@ declare class MockBuilder {
739
744
  /**
740
745
  * Match based on the number of images in the last message.
741
746
  *
747
+ * @alias whenImageCount
748
+ */
749
+ withImageCount(predicate: (count: number) => boolean | number): this;
750
+ /**
751
+ * Match based on the number of images in the conversation.
752
+ *
742
753
  * @example
743
754
  * mockLLM().whenImageCount((n) => n >= 2).returns("Comparing multiple images...")
744
755
  */
745
756
  whenImageCount(predicate: (count: number) => boolean): this;
757
+ /**
758
+ * Return a sequence of responses. Each time the mock matches, it will return the next response in the sequence.
759
+ * If the sequence reaches the end, it will cycle back to the beginning.
760
+ *
761
+ * @example
762
+ * mockLLM().returnsSequence([
763
+ * { text: 'First response' },
764
+ * { text: 'Second response' }
765
+ * ])
766
+ */
767
+ returnsSequence(responses: MockResponse[]): this;
768
+ /**
769
+ * Set a dynamic response generator function.
770
+ * Equivalent to withResponse(fn).
771
+ *
772
+ * @alias withResponse
773
+ */
774
+ returnsDynamic(generator: (context: MockMatcherContext) => MockResponse | Promise<MockResponse>): this;
746
775
  /**
747
776
  * Set the text response to return.
748
777
  * Can be a static string or a function that returns a string dynamically.
@@ -1291,6 +1320,11 @@ declare class MockManager {
1291
1320
  * Helper function to get the global mock manager instance.
1292
1321
  */
1293
1322
  declare function getMockManager(options?: MockOptions): MockManager;
1323
+ /**
1324
+ * Reset the global MockManager instance.
1325
+ * Useful for clearing all mocks and state between tests.
1326
+ */
1327
+ declare function resetMocks(): void;
1294
1328
 
1295
1329
  /**
1296
1330
  * Create a mock LLM stream from a mock response.
@@ -1419,4 +1453,43 @@ declare function createEmptyStream(): LLMStream;
1419
1453
  */
1420
1454
  declare function createErrorStream(chunksBeforeError: LLMStreamChunk[], error: Error): LLMStream;
1421
1455
 
1422
- export { type MockAudioData, MockBuilder, MockConversationManager, type MockGadget, MockGadgetBuilder, type MockGadgetConfig, type MockImageData, MockManager, type MockMatcher, type MockMatcherContext, type MockOptions, MockPromptRecorder, MockProviderAdapter, type MockRegistration, type MockResponse, type MockStats, type RecordedCall, type TestEnvironment, type TestEnvironmentOptions, type TestGadgetOptions, type TestGadgetResult, collectOutput, collectStream, collectStreamText, createAssistantMessage, createConversation, createConversationWithGadgets, createEmptyStream, createErrorStream, createLargeConversation, createMinimalConversation, createMockAdapter, createMockClient, createMockConversationManager, createMockGadget, createMockPrompt, createMockReadable, createMockStream, createMockWritable, createSystemMessage, createTestEnvironment, createTestStream, createTextMockStream, createTextStream, createUserMessage, estimateTokens, getBufferedOutput, getMockManager, getStreamFinalChunk, mockGadget, mockLLM, testGadget, testGadgetBatch, waitFor };
1456
+ /**
1457
+ * Mock TUI App interface.
1458
+ */
1459
+ interface MockTUIApp {
1460
+ setProfiles: any;
1461
+ setFocusMode: any;
1462
+ startWaitingForPrompt: any;
1463
+ destroy: any;
1464
+ onQuit: any;
1465
+ onCancel: any;
1466
+ showLLMCallStart: any;
1467
+ updateStreamingTokens: any;
1468
+ clearRetry: any;
1469
+ showThrottling: any;
1470
+ addSystemMessage: any;
1471
+ clearThrottling: any;
1472
+ showRetry: any;
1473
+ showApproval: any;
1474
+ waitForInput: any;
1475
+ subscribeToTree: any;
1476
+ handleEvent: any;
1477
+ addGadgetCost: any;
1478
+ flushText: any;
1479
+ resetAbort: any;
1480
+ startNewSession: any;
1481
+ showUserMessage: any;
1482
+ clearPreviousSession: any;
1483
+ clearStatusBar: any;
1484
+ onMidSessionInput: any;
1485
+ waitForPrompt: any;
1486
+ getAbortSignal: any;
1487
+ }
1488
+ /**
1489
+ * Creates a mock TUI app for testing.
1490
+ *
1491
+ * NOTE: This currently uses Vitest's `vi` for mocks.
1492
+ */
1493
+ declare const createMockTUIApp: () => MockTUIApp;
1494
+
1495
+ export { type MockAudioData, MockBuilder, MockConversationManager, type MockGadget, MockGadgetBuilder, type MockGadgetConfig, type MockImageData, MockManager, type MockMatcher, type MockMatcherContext, type MockOptions, MockPromptRecorder, MockProviderAdapter, type MockRegistration, type MockResponse, type MockStats, type MockTUIApp, type RecordedCall, type TestEnvironment, type TestEnvironmentOptions, type TestGadgetOptions, type TestGadgetResult, collectOutput, collectStream, collectStreamText, createAssistantMessage, createConversation, createConversationWithGadgets, createEmptyStream, createErrorStream, createLargeConversation, createMinimalConversation, createMockAdapter, createMockClient, createMockConversationManager, createMockGadget, createMockPrompt, createMockReadable, createMockStream, createMockTUIApp, createMockWritable, createSystemMessage, createTestEnvironment, createTestStream, createTextMockStream, createTextStream, createUserMessage, estimateTokens, getBufferedOutput, getMockManager, getStreamFinalChunk, mockGadget, mockLLM, resetMocks, testGadget, testGadgetBatch, waitFor };