From the course: Building Test-Driven React Components with Copilot
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Crafting effective test prompts - Microsoft Copilot Tutorial
From the course: Building Test-Driven React Components with Copilot
Crafting effective test prompts
- [Instructor] The difference between getting mediocre test suggestions and really good ones from Copilot often just comes down to how you communicate with it. So we want to think about Copilot as being the senior developer who needs clear context to help give us the best advice. So inside of our source folder, let's go ahead and create a new file. It's going to be called SearchBox.test.jsx. And this is going to take in some sort of a prompt here. Couple ways that we can handle this. I could say, "Test that SearchBox calls onSearch when the user types and presses Enter." So from here, I can Tab through. And this is going to create this for me. Nice. So now, this is a test that has this title. We're going to mock the onSearch function using jest, we're going to handle the input, and that should be everything that we need. We also, because we're using the latest version of react, we can get rid of this import. That's unnecessary, but old habits die hard. They always like to import that,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.