Copilot Code Completion | Bondar Academy
Course: Playwright API Testing with TypeScript
Module: AI-Assisted Scripting with Copilot
Instructor: Artem Bondar
Lesson Summary
In this lesson, we explore how Copilot code completion functions within a project. Here are the key points discussed: Getting Started Ensure Copilot and Copilot Chat are installed and running. Code completion is activated automatically upon installation. Code Suggestions When typing in your document, Copilot provides suggestions based on context: Typing a keyword prompts Copilot to suggest relevant imports or functions. For example, placing the cursor and typing may yield suggestions like import API request context or get articles test . Limitations of Copilot Despite its capabilities, Copilot has notable limitations: It may suggest imports or files that do not exist in your project, leading to confusion. Common mistakes include incorrect syntax and variable handling. Personal Opinion The instructor likens Copilot's assistance to a puppy that is enthusiastic but ultimately unhelpful. While some users find it useful for boilerplate code, the instructor recommends disabling Copilot code completion due to its frequent inaccuracies. Disabling Copilot Code Completion To disable this feature: 1. Click on the Copilot icon at the bottom of the screen. 2. Unselect both checkboxes to disable code completion. In conclusion, while Copilot offers some assistance, the instructor suggests focusing on Copilot Chat for a better experience. Experimentation is encouraged to find what works best for you.
Video Transcript
Hey guys, welcome back and in this lesson, I will show you how Copilot code completion works. All right, let's get into it. So this is our project and so far you should be able to install Copilot and Copilot Chat should be up and running for you. So if you did this, then code completion should be activated automatically for you. And how do you know it? So if you put Courser in any place on your document and let's say I put to the next line right here, and look, you immediately see the suggestion that Copilot think, hey, probably you want to add this import over here with API request context. We actually don't, but it thinks that we need it. Or here, for example, if you put the next line over here, I think, hey, probably you need test before all and this before all hook, maybe you need to want to create the new token right here and it's partially giving you even the object over there. Or if you put the Courser over here, somewhere after the before all and hit enter, any suggestion? Yeah. Now it thinks that we want to write the test to get the articles and it even got almost everything correctly. Yeah. But I think everything correctly. Look. And if you like this suggestion, hey, yeah, I need get articles test. Then you put just stop and everything automatically pasted into your code. Or if we go, let's say somewhere, I don't know, in the middle of get all articles test, type enter, and it thinks that we want to add assertion. So this is kind of the stuff about Copilot completion. Now let's try how intelligent it is. So for example, previously we already did this article request payload JSON. We imported this JSON object to use inside of our request. Let's say that we want to use exactly the same import inside of the spec file. Will Copilot be able to figure this out? Let's find this. So I start typing the import, okay, import. It still thinks that we need API request context, but no, I want to import article request and it suggests, hey, you want to import article request from utils.article.requests. But wait a second. We don't have utils.article.requests at all. Where did you get it from? Anyway, let's keep typing. So article request payload. So we type in like this and it says from fixtures article request payload.json. Wait a second. We don't have fixtures folder and we don't have article request payload.json file. And if I type tab, of course, VS Code immediately will tell us that this file does not exist. You see, so not pretty accurate. So let's try something with the test. Let's say I start typing a new test and it thinks that I want to create get articles test. No, I want to create, let's say, delete article test and it suggests that, yeah, I need a async request. So if you like the next line, so you can put the command tab and to the right and instead of accepting everything, putting just the tab, you can put a command and arrow to the right or on Windows it would be control and arrow to the right to accept the next phrase or next character. So I accept the title, I accept the comma, I accept async request. Okay, this is good. I need this. And this is the object and start of my test pretty much. So go into the next line and then suggest that, hey, now you probably want to request delete conduit API. So this almost correct. And let me hit tab to accept this. And we immediately have another two problems. Look, so it suggested that slug should be a part of URL as a string, but as we know, it should be a variable like this. So miss, right? And also when I accepted this, it missed the correct syntax to properly close the test at the end. So we have the open brace over here. So it's open it over here and we need the closing brace right here to completely finalize this test. So you see, it's kind of, so very mixed feeling. From one perspective, it's kind of helping you to write that, you know, big chunks of code probably fast. But in my opinion, it's making too much mistakes and create too much confusions. Like missing the closing quotes or replacing the variable with a string or providing or giving you the suggestion of the files that do not even exist in your project. So I mean, up to you. In my opinion, that copilot code completion is like, you know, a puppy that loves you so much, won't help you very much, jumping around you with throwing you a different suggestions, but it just can't help you, unfortunately. I read, I checked the articles on the internet and some people were able to figure out, use it for some setting up boiler plates and stuff like that. I think it's rather confusing than helpful. Copilot chat is significantly better experience than this. So I would suggest you just to disable this and down the road, we're not going to use it. We disable the copilot code completion. You go to the bottom screen over here to this copilot icon and just unselect both of those checkbox and this annoying code completion will not bother you again. It will be just disabled. That's it. That's my opinion, guys. Try it, play around with this, with copilot code completion. Maybe you find the approach how to use it. So far, we're not going to use it down the road, we're going to use copilot chat, but feel free to experiment. If you like it, you're more than welcome to use. So that's pretty much it and see you in the next lesson.