Update Assertions using Copilot Agent Mode | Bondar Academy
Course: Playwright API Testing with TypeScript
Module: AI-Assisted Scripting with Copilot
Instructor: Artem Bondar
Lesson Summary
In this lesson, we explore using Copilot agent mode to enhance our testing process by adding new assertions to our tests automatically. The focus is on utilizing Copilot to fill gaps in our existing tests, specifically by implementing schema validation assertions for all API requests that return responses. Key Steps in the Process: Open the smoke test.spec.ts file, which already contains some tests and assertions. Identify that schema assertions were previously added only for get articles , get tags , and post articles . Switch to agent mode in Copilot and use the CLAW 3.5 model. Craft a specific prompt to instruct Copilot to add schema validation for all relevant API requests. Prompt Structure: Your prompt should include: A clear headline stating the task. Specific details on how to implement the task. Contextual information about the method should match schema , including its arguments: Folder name of the schema location. File name format: [request type]_[endpoint] . An optional Boolean argument to generate a new schema file. Execution and Review: After running the prompt, Copilot adds the necessary assertions while respecting existing ones. It also generates new schemas as required. The process concludes with running tests to ensure everything functions correctly. Finally, a follow-up task is performed to remove the true flag from all assertions. Takeaway: The effectiveness of Copilot relies heavily on the clarity and specificity of your prompts. Experimentation with different tasks will enhance your interaction with AI tools. For reference, the prompts used in this lesson will be provided in a separate document.