Unit Test for chatGPT in Node.JS (jest)

Hello everyone, I’ve got a little situation and I’m hoping to gather some ideas and opinions from you. So, I’ve been using OpenAI (ChatGPT) in a Node.js project to generate responses based on input prompts. Now, I’m looking to create some test cases for unit testing. The goal is to prepare for a potential future scenario where the project might switch from one GPT model (e.g., gpt-3.5-turbo-0613) to another (e.g., gpt-3.5-turbo-1106). In such cases, the responses may change, and I want to be prepared for that.
Currently, my project uses JestJS for writing unit tests. Any ideas or suggestions on what to expect or how to approach writing these unit tests would be greatly appreciated. I’m thankful for your assistance!


I know this was asked a while ago, but if it’s still an issue for you, and also for others running into this
I suggest taking a look at GitHub - codeably-io/jest-ai: Custom jest matchers for testing AI applications
It’s a small library with jest matchers I’ve built for cases like this

1 Like