{
  "title": "Mockingbird",
  "video_id": "MK6JHmclC-E",
  "published": "2025-07-14T07:41:39+0000",
  "complexity": "Normal",
  "old_url": "https://workflows-of-ai.com/workflow/mockingbird",
  "description": "Mock OpenAI responses with the AI Test module in Drupal AI: record a real answer, replay it while developing and export it for automated tests.",
  "subtitle": "Record a real AI response once, replay it for free while you develop, and use the same recording in FunctionalJavascript tests and CI.",
  "summary": "The AI Test module ships an echo provider that mirrors your prompt back, and it can record real responses from providers like OpenAI. A recorded response is replayed for the exact same input, with or without the original processing time. Exported as a YAML file into the tests folder, it lets a FunctionalJavascript test run the AI API Explorer end to end, with screenshots you can check locally or in GitLab CI.",
  "categories": [
    "Drupal AI"
  ],
  "intro_html": "<p>When you are developing a module for Drupal AI, nothing is as frustrating as having to wait for the OpenAI or Anthropic provider when you know what the response should be. You are only interested in solving your code, but you have to waste money and time using a real provider.</p><p>And then you want to run Kernel and Functional tests against your newly developed module, but you do not want to put your API key in the CI, and you do not want every test to run an actual call against the provider. It will cost money, and the provider could have availability problems.</p><p>Drupal AI solves this with its own mockup provider, AI Test, that by default exposes a mirror provider: you say Jump, it says Jump. But it can also be used to record actual responses from the AI and replay them over and over, when you are developing or when you are running tests.</p><p>The AI Test module is part of the AI core module and can be used by anyone extending it.</p>",
  "intro_added": false,
  "chapters": [
    "0:00 Why mock AI responses",
    "1:30 A real call to OpenAI",
    "2:18 The AI Test echo provider",
    "4:14 Recording responses from OpenAI",
    "5:58 Replaying a mocked response",
    "7:42 Writing a FunctionalJavascript test",
    "11:21 Exporting the mock to the test",
    "12:22 Checking the test screenshots",
    "13:17 Screenshots in GitLab CI"
  ],
  "corrections": [
    [
      "Freely G",
      "FreelyGive"
    ],
    [
      "Drupal NAI",
      "Drupal AI"
    ],
    [
      "contra module",
      "contrib module"
    ],
    [
      "Leon Messi",
      "Lionel Messi"
    ],
    [
      "Leonel",
      "Lionel"
    ],
    [
      "open AI",
      "OpenAI"
    ],
    [
      "Open AI",
      "OpenAI"
    ],
    [
      "echo AAI",
      "Echo AI"
    ],
    [
      "EQI GPT",
      "Echo AI GPT"
    ],
    [
      "echoi GPT",
      "Echo AI GPT"
    ],
    [
      "GPD test",
      "GPT test"
    ],
    [
      "JAML",
      "YAML"
    ],
    [
      "ejax",
      "Ajax"
    ],
    [
      "PHP unit",
      "PHPUnit"
    ]
  ],
  "ai_note": "The video and the introduction are Marcus's own, first published on workflows-of-ai.com. AI wrote the subtitle, the summary and the video chapters from the transcript, and corrected misheard names in YouTube's automatic captions."
}