ChatGPT for QA: how to use

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
artificial intelligence is already here any changing the world in a pace that we could never imagine in the past thousands of people like recruiters designers writers QA Engineers or even developers are getting laid off on a daily basis and you thought it was because of a recession because of inflation or because of the war in Ukraine but no it was because of an AI that is replacing human on it every single day and I truly believe that in 2025 Humanity will be on a verge of Extinction just kidding my name is Sergio kromchenko I'm a founder of columnify QA boot camp that has helped hundreds of people without no prior experience to become a software qual Assurance Engineers automation Engineers or as dads but regardless today I'm going to show you how you can use chat GPT to boost up your skills to get a raise to get a promotion to become a senior or even a lead or a manager or even a director Chad GPT or Nai is pretty much a booster of our brain we don't have to get a chip we can simply navigate to chat GPT and use that you know what let me show you how you can boost up your skills with the chat GPT let's get into it at the beginning we're gonna have to register an account at the chat openai.com so please navigate here create a new account and then you will see the window in a way I can see it right here so on the left side you will see a new chat ability to add a new chat or a list of chats that you previously had as you can see it's an empty one because you have registered a new account on the right side you will see a list of models so these are pretty much a versions of the chat GPT currently the free version is called 3.5 or a default GPT 3.5 as you can see it has a fair it has good reasoning it has a really good speed and fair Consciousness there is also a legacy option available but there is also a paid version which is Chad gpt4 as you can see a reasoning is excellent speed is fair and Consciousness is really good at the version 4. currently you'll have to pay 20 dollars per month for the version 4 but we're going to use the default bt3 which is freely available for everyone in the world all right at the bottom we can we can send messages to charge GPT so let's ask it what can it help us with as the QA engineer who wants to grow very fast what can you help me with as I'm a mid-level QA engineer who wants to learn very fast and become a senior engineer all right let's see all the advices number one expand your technical knowledge as the key let's see you need to have a sole understanding of the programming languages and which we are going to learn today by the way learn programming automation testing blah blah blah awesome great familiarize yourself with the practices cool we have a list of advices from the AI but what I'm going to do I already know what do we need to work so I'm going to slowly take it from the from the easy questions such as bug reports test plans test mattresses into more technical such as API SQL shell and then some of the program including HTML CSS JavaScript and the test automation so let's get started and ask the first question how would you write a bug report for the case when user can't log in with more than 10 characters I would have more than 10 characters in email okay let's see an example from an AI so title unable to log in with email longer than 10 characters steps reproduce blah blah blah awesome you can clearly see steps reproduce actual result expected result additional information severity environment and attachments if you guys have attachments you should always add them that's great I believe that's really good that's a really good bug report okay let's take it to the next level some of our students did ask in the past how do you create a bug report for an API issue okay let's ask an AI can you create a bug report for API for API when when I send let's say create a post new user request but getting 403 instead of 201 okay and by the way please make sure guys whenever you use chai gbt that you are very descriptive otherwise you will get a very general information as a response and you if you will simply copy paste it you will have issues at the job so make sure that you have a Basics before you simply start asking chat gbt and copy pasting answers so let's read it and see if it gave us a good answer title post request to create a new user returned for three instead of 201 that makes sense very simple send stats reproduce send a post request to the user endpoint that is correct that's what we gave it as an example with a valid user data in a request body that is correct it gives us an example we should provide actual data that we did check this HTTP response status code great because we expect result we expect 201 that user was created but we get 403 gonna be creative due to insufficient permissions awesome additional information if you have severity environment and attachments perfect I like it a lot I think it did a really good job okay let's take it to the next level can you write a test case for the UI bug we've [Music] previously found let's see if it's number one if it remembers all of the questions would ask and second of all if you can write a test case certainly here's an example of a UI bug was previously found okay test steps open application click on yeah we should provide a partial URL or actually the the website where it needs to be it needs to go click on the email field enter then email perfect click on the password field attempt attempt to enter valid password observe Behavior Okay so we've entered email we click password we attempt to to enter a valid email observe the behavior of the email input okay so what happens is there is an issue in this test case I do not recommend you guys to copy paste it and I hope you understand why because we did not click on a login button so the Nai assumed that we are seeing a field validation issue so step number seven should have been click on a login because maybe we have to click on the login and then we will get an error message but it's saying that just enter email right here and attempt to enter valid password and then observe a behavior okay let's ask it a question what if debug what if the issue appears only when we click login button let's see what we'll say okay it actually rewrites an email the test case would need to be modified to reflect the behavior click the login button and then observe the behavior perfect now so you guys can see that you cannot clearly copy paste things you can use it as a template you can use it as the booster but please do not copy paste results and expect that they would be excellent because you will get fired all right let's keep going I like it a lot so task Matrix can you create a test Matrix for facebook.com just for example so we would see an example of a task Matrix all right certainly okay that's great I like it a lot that looks really professional no questions asked we could expand it if if we think there is not enough we could make it shorter if we think that it's too much for us but you guys can definitely take it as the base and keep going with this Matrix all right awesome how about a test plan how about a test plan for for Facebook .com but be let's be a little bit more detailed uh make sure make sure to make sure to count our the resources uh actually let's let's rewrite it how about a teslan let's create a task plan for Facebook dot com that has three manual qas two QA automation engineers we have two weeks we have two weeks before new changes go to production okay what else do we have I think that should be enough let's see what we'll say sure well let's get an example project name release testing duration two weeks tax the test objectives testing approach awesome you guys can see all of the things that it's using for them for the test plan testing tasks testing deliverabilities or deliverables testing tools testing risks selenium testing timeline awesome it's specific it even specifies what and when should be tested I like it a lot but once again don't use it as the CL as the plan that you would copy paste and bring it to your team read it thoroughly see what needs to be updated because once again we're just using it we're just using facebook.com as a dummy project all right I like it a lot so far we do have to work with this AI this AI is pretty much like a smart student that some sometimes gets drunk but let's keep going with it because we're we're almost getting into technical details which I like a lot all right the next one API testing with a curl awesome so sometimes you guys would have to be testing apis and you have no user interface so you would use Curl so let's just ask how do you use Curl for API testing curls a command line tool that allows you to make HTTP requests okay we all know that right awesome it gives us some information let's stop the generation and let's say cool but can you show me an example how to send an API a request with curl okay let's see an example great we can see how to send a request but what type of request is it this is an example sending the get request to the endpoint here's a breakdown of different parts curl then curl is the curl command that we utilize then get specifies the method and then a URL which is actually an endpoint perfect now it even gave us a post request so now you guys know how to post it so curl minus X post minus h which means headers then we specify our headers and then minus D which stands for body and then we specify body right here or payload and then actual URL or an endpoint perfect in the same way you guys can okay you could see you could assume you can use patch in the same way but let's actually ask it how about patch request with curl if you do need to send the patch let's see how it will specify it okay exactly the same thing we just replaced post with the patch great okay how about we add a little bit more complexity by complexity I mean actually how do we add a bidder token how do we add a bitter token to this API as you guys know most of the time when you are testing apis you will have to specify your authorization and here's a way you can specify your beauty token you would put it as one of the headers say authorization as the key and then a bitter space and then you put your token as the value great easy peasy all right let's move forward so we've learned how to do a bit of API testing through the curl and then now let's get into technical into technicals and especially shell so let's learn how how to generate a file actually let me see we should generate a file with a hundred lines can you generate a shell script that will create a file with a hundred lines of text and this is a real case scenario sometimes you will need to upload a file with a hundred lines of text you could simply ask chat GPT to do so it will create you but also if you need to do it on a daily basis you could simply use this file this shell file to create it on your own because it's much quicker and let me quickly show you how to do that it actually specifies you it actually explains things right here so I'm going to copy this you can click you could click on a copy right here or you could just Mouse you could highlight it then do your command C now I'm going to create a new file here in a vs code let's call it test.sh let's paste paste it here and now let's run this code so it sh ast.sh output file blah blah blah created with 100 okay awesome the file is right here and you can see there we have a hundred lines of text in this file this one is empty so it doesn't count and we can even remove it perfect easy peasy right we we got it we save it but once again guys when you use it make sure you understand what happens here make uh if if you guys want to learn shell if you want to learn scripting please do so okay the next step is uh how about this imagine situation where you would need to generate a 100 files because you need to test an application that would be there would be up to which you would be uploading 100 files so let's quickly test it can you generate a shell script to create 100 txd files all right easy peasy perfect and here we go once again it gives us complete instructions of what exactly we of how to how this code is written which is really good way to learn it and then also it tells us how we could run it on our computer okay I'm going to copy it then I'm going to remove this one paste it here and then I'm not going to run it run this code right here because I'm going to have a hundred of files right there I don't want to do that I'm going to create a new folder let's call it a test then CD test then I'm going to I'm going to throw this file into it I'm going to remove an old one okay so we have a test folder with a test SH now let's run it so sh dot sh spass space test sh cool 100 files created with a prefix output output one two three and hundred okay awesome now we can move sh out of it let's just move it all the way to the top so it wouldn't get stuck at the bottom is we wouldn't remove it I'll move it back to sh okay now I I mean to CI and now we can remove the test folder with 100 files because we don't need it anymore great now you know how to create how to easily create 100 files with the help of shell all right let's move forward with our AI testing so the next question would be would be finding links in a file imagine the situation we have we have a file actually generated can you write 100 lines of text with multiple hyperlinks so this is imagine this situation you have a hundred well I'm not talking about the hold on not a script not a script I just need text with multiple links in it okay sure perfect with a hundred lines of code with the multiple links in them and imagine this we need to we need to find all of the links with the stack Overflow website so now we're going to wait until it's done or actually we can use 20 20 will be enough we're going to copy this code we're going to paste it in here create a new file and let's call it so let's call it links.txt we're going to paste it here perfect we have a line we have a file with 20 lines of code now in the test shell we need a script that would Loop through and find all of the stack Overflow links imagine this situation in your automation code and you need to find you need to quickly find all the stack Overflow links and put them in one place okay now can you generate a shell script that will find all of the links all of this stack overflow links in the text above certainly I like I like the confidence of this AI okay perfect we're going to specify a file name and we're going to use the grab command to find all of the stack Overflow links okay so use graph Define always tagore full links in the file let's do that let's copy it let's paste it into our test sh now let's run it and let's see what's going to happen okay we are oh we're inside of the test folder that was removed we had to let me quickly navigate CD LS let me get back to this folder desktop projects see why okay we're back in Cy okay now let's run it so sh test sh output okay that is correct you see guys that we did create file called links but AI gave us if gave us a code and it thought it assumed that our file will be called output so we have to change it if the person from the street would try to run this code on a computer you would simply not know what's happening it's an easy fix but just make sure that you have a Basics before you do so awesome seems like we have only one link let's double check it stack Overflow let's look for it let's copy it from here and let's look for it right there that is correct we have only one so our code did work so we did we did run it and it did find the find the link in a txt file and it gave us an output so it would know what exactly it is it's useful in the cases where we would have let's say I'm going to copy paste it a lot of times look at it we have 1 000 lines of code I'm going to run my script again and it found all of them you guys can see that right imagine if these these links are different and you need to find all of the links and you have 1 000 lines of text and you need to find let's say 20 links easy peasy with the help of shell all right let's clean it up let's remove all of those all of the code and move forward so the next question let's see if if the shell can replace oh that's actually very common issue so when we are working with let's say insomnia when we use when we copy API response from from insomnia I'm going to copy it and then you paste it somewhere into editor or something and double quotes are replaced with a single quotes or other the other way around and you paste it into your code and you're like oh let's say these are single quotes just for example and you you need to change them so you would manually you would have to manually go through and change those but how about we write the code that would replace it let's put it into let's create a separate file so we're going to create a file called API dot Json then I'm going to paste it in here and now we will ask our we will ask share GPT to create a script that will go through every single line of code and replace double quote with single quotes okay can you write a shell script to replace all double quotes with a single let's see if we can do it sure you can all right you said to replace all the currencies of the double quotes with a single quote okay let's give it a shot we did copy our code let's paste it into test.sh let's change the file name from input.txt into api.json okay we did copy it let's clear the terminal let's make sure we do have a double quotes here okay let's run the file api.json command a expect followed by text what does that mean let's see this is okay so we're getting error so let's tell GPT and see why are we getting this error it did not work I got this error I apologize for the confusion okay looks like there was an issue of the command I provided earlier here's the correct correct command to replace double quotes okay okay so now it gives us this code right here let's give it a shot let's replace it all right let's change it from the API Json to Output Json it just wants to create a new one okay let's do so okay now we should be getting output Json perfect and you can see single quotes in every single on every single line instead of the double quotes great moving forward that was an easy task although it took a little bit time and we had to train we actually had to train our AI because he made a mistake great now let's talk about SQL so since a lot of QA Engineers use SQL let's say that you do not know SQL but you need to find you need to find a user with a certain email in that that exists in two tables okay let's ask you let's ask Chad gbt can you find let's see SQL can you find a user with email Sergey at gmail.com in users table assuming that you have a table named users with a column email here's a script okay that's a very easy script right perfect copy paste run it it will work I promise okay can you you create join join SQL script to join to to join in information of this user from two tables users and then we're also gonna have user address okay and then if you guys know whenever you use join you need to know how to combine two tables but I'm not going to specify that information I'm just going to tell it to you so I'm pretty sure you will tell us that it assumes that it has to combine them by some data assuming you have a users table with columns there we go ID and the user's address table with the user ID that's correct so we're going to combine users table with the user address table by user ID and ID those will be the same in both tables and this script will actually work perfect great I like it a lot all right so we did join two tables let's see can you join the three tables would you be able be able to join three tables to also add all of the purchases imagine that we're working for Amazon to add all of the purchases of user of user with email Sergey at gmail.com that were made with the last two weeks okay let's see Beth sure assuming users then user addresses and then purchases with the columns user ID that is correct so we're joining user address a purchase or email and pre-purchase date okay that makes sense so we specify in a row within the last two weeks and it did join let's see all three tables perfect great results all right so we've learned how to use SQL now let's move forward and see how can can actually create us a website just so we could learn how does it work can you create a basic a resume let's say QA resume website I don't have the capability to create a website or web application however I can provide some general guidance of how to create those okay I'm going to stop it that's not going to work that's cool but can you can you create uh can you write HTML code for it certainly that's what I was looking for you see guys you don't always get a clear answer from Chad gbt but if you know if you can train it if you can show what mistakes they make if you can guide it then it will give you a responses you're looking for it just takes a bit of time and expertise okay it's creating quite a bit okay it's even specified that I'm a dedicated to engineer with a five years of experience in the software testing amazing okay cool that's done let's see if it works I'm going to well let's ask it how do I run this file I know how to run it but let's see if it will give us a clear instruction okay run an HTML file you can simply open a browser okay so it says it should be an HTML file well that's somewhat clear so let's go ahead and remove all of the files create a new one call it index.html and paste the code inside of it okay now let's run open space that so we could open our finder and let's drop it into into the Google Chrome perfect you can see guys that our website looks like this it's good but it's just a text right text with a couple of links that it just takes us up and down it's a pure HTML okay awesome let's say that's cool but can you also add CSS to make it a bit more beautiful [Music] certainly okay awesome we see some CSS great and imagine this you're a person that never run never used the code before so you see the CSS and you're like okay that's cool how do I add it okay to use the CSS code you can save it into the file whoa let's follow this instruction I like it a lot let's get here let's create a new file what was the name of it style.css style dot CSS then we're gonna paste this code into it okay and then what do we do next and then we put this one into HTML then you can link it to your HTML by adding a following line with the within head tags so make sure you add it within the head tags so let's get to HTML find our head okay and we can paste it oh actually it's right there yeah that's awesome okay now let's see our browser again refresh it oh that's beautiful right awesome and now you guys know number one how to link how to link HTML and the CSS and number two how it will work so can you also add a bit JavaScript to it okay that's great we're adding some JavaScript here to add some attributes this JavaScript will not help as much it will just activate some of the hyperlinks add an ID and a section you'll find a section and add an ID there okay still but it's a JavaScript we're pretty much creating a fully functioning website with the help of HTML all right now let's create a new file call it J uh let's see call it index.js and let's paste our code into it so we did index.js.js let's just do one.js we don't need two of them okay I'm pretty sure you told us how to import it okay and we put it into body tag then you can link let's see in the same directory as your HTML file so we added in same directly then you can link to your HTML by adding the following line at the end of the body tag okay let's follow the instruction and edit at the end of the body tag the body tag would be ending let's see where does it end let me just pull it okay right here it starts and then it goes all the way here oh I didn't see it's closing interesting we'll see am I missing something did I not fully copy it hold on that's not correct oh it just gave us unfinished power unless it didn't finish a writing for some reason that's interesting okay well let's just paste it let's see so if we open it here then we're gonna have to close it close it right there and I'm going to beautify it what is that okay I think this should work so now I did copy it let me paste it right here before the end that that's the footer so we did create a footer but we're gonna have to remove it okay we're gonna paste it right there perfect it looks like you guys can see that AI can makes mistakes AI can write unfinished code and you have to you have to encounter for it you have to make sure that you understand what you're working on because once again if you just copy paste it some sometime later you will find out that oh shoot I it didn't finish the code and I don't know how it works so I cannot fix it so make sure you know how to work with the code that it writes or at least you learn it after it writes it for you okay so we did edit let's go to the browser refresh the page okay and now I'm going to open up elements tab to see if we've added those IDs okay so we were adding get attribute ID section tab what do we do here for each remove active then if link href add active Okay so we're just adding active okay there is not much fun here let's do it differently let's ask can you add unique attributes so what we're doing now we are adding when new QA Engineers joins the company and you do not have any you do not have any unique attributes to write automation for you would ask your developers to do so so let's ask AI to add unique attributes uh can you add unique attributes so so I as a QA automation automation um why am I spelling it automation engineer could easily could easily find selectors for our for UI automation sure updated code right there let's see data QA that's the one you can see it right here right so this is the unique attribute that was added by AI so we could easily then say Cyprus get data Q8 equals to header title put it into square brackets because this attribute and we could get the we could get this text easily and as you can see we are it's getting those everywhere this is amazing that's like a Dev work that every QA dreams about awesome so I'm going to copy it here then I'm going to navigate back to the code replace our HTML file and now let's navigate back here refresh our page and let's see if we can see those data header title perfect is there data QA main nav awesome it is there so as you guys can see we have added unique attributes for every single element on a page which is amazing all right thanks AI moving forward so the next question we are learning JavaScript we've added CSS we've added we added Jazz we've added attributes now let's see if let's learn algorithms as every QA engineer you do have to know how to solve algorithms so can you create 10 very base actually just basic 10 basic Jazz algorithms for QA engineer all right let's see those palindrome checker awesome that's a very very famous one and by famous I mean this is very popular one when you go for an interview and as you guys can see you can even get the resp you can get a solution right away factorial calculator also a common one Fibonacci also very common one okay greatest common divisor I haven't gotten the this one in my life reverse the string super easy one I got it once about eight years ago okay so let's see if this case uh title case title case a sentence but a function that capitalizes the first letter of each word in a given sentence okay this is the cool one I would actually ask people to write it if I would want to find out if they know JavaScript on a mid-level for the QA engineer count vowels okay fairly fairly simple one find the sum all numbers find the largest number remove duplicates yeah very very good I would say these are very valuable algorithms for the for the mid level of a QA automation engineer and it's amazing you guys can already see the solution for them all right that's great let's move on to the next one so with the JS let's say these are the mid-level how about the junior or the very very beginning can you give me 10 very easy Jazz algorithms as I'm as I'm just starting with JavaScript imagine this you are a junior or even you're just starting and so let's see what kind of algorithms you would need to know in order to slowly improve your skills so the first one say hello world that's like a very basic I would say but that's what we ask for by the program that adds numbers and prints result to the console that's a good one odd or even that's a good one yeah these are very easy these are for people who just started and learned JavaScript for a couple of days but I like this a lot perfect and find the largest number okay this is getting a little more complicated because you're learning for Loops but that's that's the way to progress awesome let's move forward so the next one can you write a JavaScript that reads a file and finds a duplicated emails that's a good one can you write a jet so this is actually an algorithm that I think one of our students had in the past can you write a jazz code that loops through all lines of the file and finds actually hold on we don't need to specify it has to look we should figure it out on its own can you write a jazz code Jazz code that finds all duplicated emails in the txt file imagine this you are a QA engineer and the data analyst or someone from every team comes to you and asks you hey I have a file with a lot of emails some of them are duplicated can you find those which are duplicated because we have a production issue and now we might be able to find out what's causing it so yes let's do that can write a JS code it finds all duplicated emails in the in the txt file let's see sure I can all right email it reads it it splits it okay let's test it out so cool now can you generate 20 lines of code of text with two duplicated emails in it we'll generate a text and test it out right away so while it's doing it I'm going to copy this code navigate back here remove all Let's see we can remove all of these then we can create a new one touch test.js okay we have a JS file here perfect now we've copied the code now let's copy a lot of emails and find just a duplicate it once create file and let's call it users.txt pasted run our code uh oh adder what does it say no such a file or directory open emails.txt so with a user St but the AI gave us email 60 so we'll just simply update it and run it again and let's see if it's going to work amazing results it did work duplicated emails although we did ask for two duplicated emails we've got quite more than two I think it was an AI issue but just in case let's double check it and see it manually command F command v21 okay so this is definitely duplicated let's see this one this one is also duplicated let's see this one this is also duplicated yeah unfortunately AI did not listen to us because we did ask with two duplicated emails well that's actually double check why did you give me more than two duplicated emails I apologize for the conclusion you asked for 20 lines of text with two duplicated emails but I misunderstood and provided 20 lines with the multiple with the multiple duplicated emails okay that's fine we do not care about the amount we we truly believe that now it can fix its own issue okay now let's go ahead and get to the next challenge so I think we're good with the JavaScript we've written a lot of JavaScript now let's learn how to how to automate tests how to write UI test automation can you show me how to how to automate Facebook login page let's see Facebook login functionality with Cyprus now Cyprus is the one of the most popular it's at least it's becoming one of the most popular test automation Frameworks in the world actually it's already one of the most it's already the most popular because a lot of devs are using it switching to it right now okay cool certainly you guys see the JavaScript test automation that it did right for us and it's amazing it full it's a fully working one the only trick here is that we do not have Cyprus installed so let's ask it can you I would say it doesn't work it doesn't work as I don't have Cyprus installed we'll just play dumb yep you're right my apologies assuming Cyprus installed here are the steps okay and we have a steps to install Cyprus and those steps will definitely work okay let's take a look at it so it did write a test and then in this test we have a title it logs in successfully facebook.com get get URL so get the login button click it you would have to type in your email here and your password Here I hope you guys understand that so this is the very basic code how to how to log into facebook.com okay let's say we want to be a little bit more advanced uh let's say can you please utilize page object model for this login test let's just see if it understands the page object model Okay it definitely does awesome so it did create a page object model and now it shows us how to use this page object model to write a test and it's actually perfect I do not have any problems with it yeah it looks really good to me okay awesome so we did write Cyprus front-end test for the for the Facebook it's amazing but how about API test let's see if we can write some API tests with the with the help of child GPT can you generate API test for Facebook get let's see for Facebook get users HTTP call sure let's see an example okay it's using Cyprus to do that awesome and it even found that it even found the URL for the or the endpoint for this API that's cool awesome so let's take a look at it describe Facebook access token you've got to paste your access token here returns a user profile okay that's great I like it a lot but how about we want to use something so this is end to end test right that's a full for a QA engineer so let's try to use a different API clients such as access for example can you use axis for the same API let's see access API client for the same API okay cool let's take a look exhales get headers then blah blah awesome all right now let's ask it if you can write a same test with the playwright because playwright and the Cyprus are two the most popular UI automation Frameworks in the JS and access is just an API API client which can only be used for API so we can also ask it which one would be better can you write the same code with playwright can you test the same API with playwright okay let's take a look at that so playwright will look very similar to Cypress but the main difference would be that it's using a single weight and a Cyprus hides it underneath of the hood okay so we gotta we're gonna play it right right here we've got access right here and we'll get a Cypress right here let's ask one simple question before we get to the unit testing of the API what would be let's see what would be the easiest framework to use for a key for a junior let's see for junior QA engineer business framework to use for an engineer to start with API testing access Cyprus or playwright and let me know in the comments guys what do you think would be the easiest one to start with so for the junior one I would recommend access or Cypress as both easy to set up and use access is simple lightweight library for making HP requests in JavaScript while Cypress is more comprehensive test automation framework this supports UI and API I do agree that access would be the probably the easiest one to start start with based on my experience but all of them are fairly easy but Cyprus and this and the playwright are more powerful and then I would say the playwright is the most configurable and the most powerful now let's create a unit test let's create our first unit test as sometimes QA Engineers would be required to create those very rarely but once in a while one of our students recently got a job offer after she passed the interview by creating unit tests so let's do so can you show me how to create unit tests for API in JavaScript certainly okay awesome we are using access we are using super tests perfect so we're going to create it and send it import the necessary dependencies okay so it seems like it's expecting that we will have application already installed okay let's do that let's copy this code but remember that we do not have anything installed create file test.js paste the code run it and it will not it will not work because module not found access number one let's install Xs let's run a code again now it says the app cannot be found because we do not have it let's just tell it that we're getting this error are getting this adder means that the app does not exist can you create can you create that file for me can you create a code for that file for me since it does not it cannot create files but it can create code all right perfect so we are getting a server now we will be able to copy it create a file called app.js paste it now we're going to need to run it so let's run it node app.js it says express is not found okay we're gonna have to install it npm I install Express and also install body parser okay if those were installed let's try to run our server again server does not run why is that happening maybe we don't have to run it this file defines Express okay getting list getting user okay the body browser no no that this is just a simple example of you would likely need to modify with your specific API okay can you just generate a very simple API server so I could run it actually can you just do a very simple API server and unit tests for it a very simple API so you can test for it so I could run it all on my local sure there we go first you need to create a new project okay okay we'll get a project then we've got a test okay I agree with that let's run it let's do so so install make your my API City my API npny okay we can do all of that very quickly we already have everything installed so we don't have to worry about it okay though it's just in case I'm gonna run those even if you we have those created we can create them one more time it's not going to it's not going to hurt anything if it's already if it has already been installed it will just skip it or install the newer version okay and now we have so this is the app right okay we did copy paste the app but just in case let's do it again and now we have tests okay perfect how do we run our tests okay this code defines test the test use the separate test library to make HTTP request yeah super test is a very very popular one now okay npm test in terminal to run our test perfect let's run it okay this does not work and I'll explain it to you guys I'll explain to you guys why so when we see code through directory okay when we create a new when we create a new application and if someone tells us to run npm test and the test should run this means when we run npm test it will trigger a script which is written right here but it doesn't exist so test and then here we're going to have to specify the command which should run in order to kick off the tests so let's just tell our AI that we are getting missing script let's see what's going to say if you're getting okay that means that script defined in a package that is correct that's what we've just learned about okay we just have to specify just that's easy actually this way not the way I showed you in a second second ago all right now let's try to run again npm test perfect now all of our all of our unit tests have passed let's take a look at them so test number one get hello should return to your status code and hello world perfect the second test get user ID should return to your status code and a user object perfect we did get that third one get user ID should return for for status code if user is not found so pretty much a negative task awesome now you guys know how the unit tests look like how to create them and how to run it how to run them this is this application is utilizing a super task but you can use Cyprus you can use playwright you can use access you can use anything you want but this is just one of the examples that recently one of our students had to learn from me and then after she passed it after she passed an interview by showing how she used how she writes uni test she got the job after you saw how powerful chat GPT is after you've learned how to use it and how it can boost up your skills do you guys think Chad GPT or other AIS they're going to be helping us to be more efficient smarter faster and better or do you think they will actually replace Us in the near future please let me know in the comment below and don't forget to hit that big fat thumb up button if you guys did enjoy this video and you if you want to help me out to spread the word over the YouTube thank you and I'll see you next time [Music]
Info
Channel: Codemify
Views: 44,063
Rating: undefined out of 5
Keywords: qa, code, visual studio code, visual studio, java script, job online, software engineer, software developer, qa engineer, quality assurance, qa school, learn qa, codemify, wdio, qa bootcamp, learn qa online, how to become a qa engineer, qa tester, Gpt, Chatgpt, How to use chatgpt, How to use gpt, Gpt for qa engineers, Chatgpt for qa, Chatgpt for qa engineers, chatgpt for testers, ai for qa, ai for testers, ai software testing, test ai, ai testing, ai testers, ai qa, qa ai
Id: iOheLWYbILw
Channel Id: undefined
Length: 60min 29sec (3629 seconds)
Published: Mon Apr 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.