title
Jest Crash Course - Unit Testing in JavaScript

description
In this video we will get started with JavaScript unit testing using Jest. We will look at how to setup Jest, different matchers as well as how to test async code, run functions before and after different tests, etc. This is for developers that are fairly new to testing and the Jest testing framework. Code: Github Repo: https://github.com/bradtraversy/jest_testing_basics Sponsor: Anthrodesk http://anthrodesk.com/ 💖 Become a Patron: Show support & get perks! http://www.patreon.com/traversymedia Website & Udemy Courses http://www.traversymedia.com Follow Traversy Media: http://www.facebook.com/traversymedia http://www.twitter.com/traversymedia http://www.instagram.com/traversymedia

detail
{'title': 'Jest Crash Course - Unit Testing in JavaScript', 'heatmap': [{'end': 241.268, 'start': 167.556, 'weight': 0.91}, {'end': 344.838, 'start': 268.295, 'weight': 0.744}, {'end': 1518.504, 'start': 1409.101, 'weight': 0.715}], 'summary': "Provides a comprehensive guide to javascript unit testing with jest, covering setup, writing and running tests, handling asynchronous data, and testing various javascript functions, achieving a total of 11 passed tests. it also emphasizes the importance of back health and productivity for programmers, promoting anthro desk's stand sit desks and accessories.", 'chapters': [{'end': 49.006, 'segs': [{'end': 49.006, 'src': 'embed', 'start': 7.608, 'weight': 0, 'content': [{'end': 11.749, 'text': 'Hey guys, being a programmer or a web developer, or any job at all, where you sit all day,', 'start': 7.608, 'duration': 4.141}, {'end': 15.031, 'text': 'can do horrible things to your back and your health in general over time.', 'start': 11.749, 'duration': 3.282}, {'end': 23.253, 'text': 'So I would definitely suggest looking into a stand sit desk and anthro desk has affordable and quality solutions for maximum health and productivity.', 'start': 15.311, 'duration': 7.942}, {'end': 26.254, 'text': 'You can choose from different frame widths depending on your needs.', 'start': 23.574, 'duration': 2.68}, {'end': 28.975, 'text': 'I actually just got one myself and I love it.', 'start': 26.615, 'duration': 2.36}, {'end': 32.537, 'text': 'They also offer accessories like standing converters and floor mats.', 'start': 29.035, 'duration': 3.502}, {'end': 36.498, 'text': 'So check out anthro desk.com or click the link in the description below.', 'start': 32.837, 'duration': 3.661}, {'end': 46.205, 'text': 'hey guys, one thing that i can admit that i i really slack on in development is testing, and i think that a lot of developers are in this boat.', 'start': 38.089, 'duration': 8.116}, {'end': 49.006, 'text': 'it really it seems to add work,', 'start': 46.764, 'duration': 2.242}], 'summary': 'Using a stand-sit desk can improve health and productivity at work. anthro desk offers affordable solutions, with accessories like standing converters and floor mats.', 'duration': 41.398, 'max_score': 7.608, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho7608.jpg'}], 'start': 7.608, 'title': 'Health and productivity with anthro desk', 'summary': "Emphasizes the importance of maintaining back health and productivity for programmers, promoting anthro desk's affordable and quality stand sit desks and accessories, with a special emphasis on the benefits of these solutions for maximum health and productivity.", 'chapters': [{'end': 49.006, 'start': 7.608, 'title': 'Health and productivity with anthro desk', 'summary': "Emphasizes the importance of maintaining back health and productivity for programmers, promoting anthro desk's affordable and quality stand sit desks and accessories, with a special emphasis on the benefits of these solutions for maximum health and productivity.", 'duration': 41.398, 'highlights': ['Anthro Desk provides affordable and quality stand sit desks and accessories for maintaining back health and productivity, catering to different frame widths based on individual needs.', 'The speaker personally recommends Anthro Desk and emphasizes its positive impact on health and productivity.', 'The chapter highlights the common issue of developers neglecting testing in their work, suggesting that it adds extra work and emphasizing the need for improvement.']}], 'duration': 41.398, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho7608.jpg', 'highlights': ['Anthro Desk provides affordable and quality stand sit desks and accessories for maintaining back health and productivity, catering to different frame widths based on individual needs.', 'The speaker personally recommends Anthro Desk and emphasizes its positive impact on health and productivity.', 'The chapter highlights the common issue of developers neglecting testing in their work, suggesting that it adds extra work and emphasizing the need for improvement.']}, {'end': 901.818, 'segs': [{'end': 106.656, 'src': 'embed', 'start': 49.006, 'weight': 0, 'content': [{'end': 55.53, 'text': 'but in the long run it can really help you out and give you a more efficient way to check things and prevent future errors and issues,', 'start': 49.006, 'duration': 6.524}, {'end': 56.83, 'text': 'stuff like that.', 'start': 55.53, 'duration': 1.3}, {'end': 61.894, 'text': "so if you're looking at the big picture, it can really lessen your workload, not add to it.", 'start': 56.83, 'duration': 5.064}, {'end': 65.296, 'text': "now i do think that writing unit tests and stuff like that it's not.", 'start': 61.894, 'duration': 3.402}, {'end': 71.48, 'text': "it's definitely not necessary in all projects, especially really small projects.", 'start': 65.296, 'duration': 6.184}, {'end': 79.568, 'text': 'i do, however, think that all developers they should put at least some time into learning basic testing practices and technologies,', 'start': 71.48, 'duration': 8.088}, {'end': 82.671, 'text': 'because you you most likely will deal with them at some point.', 'start': 79.568, 'duration': 3.103}, {'end': 88.818, 'text': 'uh, especially if you plan on working for a company, as opposed to you know, doing your own thing and freelancing.', 'start': 82.671, 'duration': 6.147}, {'end': 97.166, 'text': 'so what i want to do in this video is just some basic javascript unit testing with jest, which is a great testing solution for javascript.', 'start': 89.338, 'duration': 7.828}, {'end': 101.431, 'text': "it's simple to get up and running and the basics are very, very easy to learn.", 'start': 97.166, 'duration': 4.265}, {'end': 104.554, 'text': 'i will warn you that this is a beginner tutorial.', 'start': 101.431, 'duration': 3.123}, {'end': 106.656, 'text': "so if you've done stuff like this in real life.", 'start': 104.554, 'duration': 2.102}], 'summary': 'Unit testing with jest can lessen workload and is valuable for developers to learn basic testing practices and technologies.', 'duration': 57.65, 'max_score': 49.006, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho49006.jpg'}, {'end': 241.268, 'src': 'heatmap', 'start': 167.556, 'weight': 0.91, 'content': [{'end': 172.219, 'text': "So if you don't have that, just go to nodejs.org, download it, and install it.", 'start': 167.556, 'duration': 4.663}, {'end': 174.001, 'text': "All right, so we'll go ahead and run that.", 'start': 172.66, 'duration': 1.341}, {'end': 177.358, 'text': 'And it creates our package.json, which looks like this.', 'start': 174.657, 'duration': 2.701}, {'end': 179.519, 'text': "And then we're going to install Jest.", 'start': 178.039, 'duration': 1.48}, {'end': 182.441, 'text': "So let's say npm i or npm install.", 'start': 179.559, 'duration': 2.882}, {'end': 186.582, 'text': "I'm going to use dash uppercase D, which will save it as a dependency.", 'start': 182.461, 'duration': 4.121}, {'end': 190.944, 'text': 'You can also do dash dash save dash dev and then Jest.', 'start': 186.702, 'duration': 4.242}, {'end': 195.566, 'text': 'And you can also install Jest globally and run the Jest command directly.', 'start': 191.645, 'duration': 3.921}, {'end': 199.348, 'text': "But we're just going to install it locally and we're going to create a script for it.", 'start': 195.686, 'duration': 3.662}, {'end': 204.883, 'text': "All right, so now that that's installed, let's create our script.", 'start': 202.301, 'duration': 2.582}, {'end': 212.71, 'text': 'Okay, we already have our test script here, but we just want to change the value to simply Jest and save.', 'start': 204.983, 'duration': 7.727}, {'end': 213.831, 'text': "And that's it for now.", 'start': 212.93, 'duration': 0.901}, {'end': 214.852, 'text': "So let's close that up.", 'start': 213.891, 'duration': 0.961}, {'end': 217.154, 'text': "And now we're going to create a new file.", 'start': 215.332, 'duration': 1.822}, {'end': 224.08, 'text': "Now I want to create just some basic functions to test, so I'm going to create a file called functions.js.", 'start': 217.754, 'duration': 6.326}, {'end': 230.185, 'text': "Instead of putting every little function in its own file, we're just going to create basically a collection of functions here.", 'start': 224.64, 'duration': 5.545}, {'end': 235.981, 'text': 'We also want to create a file called functions.test.js.', 'start': 231.014, 'duration': 4.967}, {'end': 239.186, 'text': 'So it should have the same name as the file, just .test.', 'start': 236.021, 'duration': 3.165}, {'end': 241.268, 'text': 'And Jess will automatically pick that up.', 'start': 239.246, 'duration': 2.022}], 'summary': 'Installing and configuring jest for testing node.js applications', 'duration': 73.712, 'max_score': 167.556, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho167556.jpg'}, {'end': 204.883, 'src': 'embed', 'start': 172.66, 'weight': 3, 'content': [{'end': 174.001, 'text': "All right, so we'll go ahead and run that.", 'start': 172.66, 'duration': 1.341}, {'end': 177.358, 'text': 'And it creates our package.json, which looks like this.', 'start': 174.657, 'duration': 2.701}, {'end': 179.519, 'text': "And then we're going to install Jest.", 'start': 178.039, 'duration': 1.48}, {'end': 182.441, 'text': "So let's say npm i or npm install.", 'start': 179.559, 'duration': 2.882}, {'end': 186.582, 'text': "I'm going to use dash uppercase D, which will save it as a dependency.", 'start': 182.461, 'duration': 4.121}, {'end': 190.944, 'text': 'You can also do dash dash save dash dev and then Jest.', 'start': 186.702, 'duration': 4.242}, {'end': 195.566, 'text': 'And you can also install Jest globally and run the Jest command directly.', 'start': 191.645, 'duration': 3.921}, {'end': 199.348, 'text': "But we're just going to install it locally and we're going to create a script for it.", 'start': 195.686, 'duration': 3.662}, {'end': 204.883, 'text': "All right, so now that that's installed, let's create our script.", 'start': 202.301, 'duration': 2.582}], 'summary': 'Installing jest locally using npm i or npm install with option -d as a dependency', 'duration': 32.223, 'max_score': 172.66, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho172660.jpg'}, {'end': 344.838, 'src': 'heatmap', 'start': 268.295, 'weight': 0.744, 'content': [{'end': 276.705, 'text': "but it's going to take in num1, num2 and then we just want to return num1 plus num2.", 'start': 268.295, 'duration': 8.41}, {'end': 287.62, 'text': 'all right, and if you want to do it without arrow functions, you could simply say function And just pass in here num1, num2,', 'start': 276.705, 'duration': 10.915}, {'end': 291.602, 'text': 'and just return num1 plus num2..', 'start': 287.62, 'duration': 3.982}, {'end': 297.426, 'text': 'Okay, so same exact thing, but I think our functions are a shorter, cleaner syntax.', 'start': 291.803, 'duration': 5.623}, {'end': 303.651, 'text': "So we're going to actually have to export this so that we can use it in our test file.", 'start': 298.487, 'duration': 5.164}, {'end': 309.515, 'text': "So we're going to say exports, module.exports functions, and save.", 'start': 303.671, 'duration': 5.844}, {'end': 317.408, 'text': "All right, so let's go to functions dot test and we're going to bring that file in, of course, if we want to use it.", 'start': 310.305, 'duration': 7.103}, {'end': 319.589, 'text': 'So functions equals require.', 'start': 317.488, 'duration': 2.101}, {'end': 328.313, 'text': "And let's do dot slash functions and we're going to write our first test.", 'start': 319.609, 'duration': 8.704}, {'end': 331.115, 'text': 'OK, so we simply need to do test.', 'start': 329.054, 'duration': 2.061}, {'end': 334.13, 'text': "And then we're going to pass in a description.", 'start': 332.188, 'duration': 1.942}, {'end': 335.611, 'text': 'And this can be anything we want.', 'start': 334.31, 'duration': 1.301}, {'end': 342.436, 'text': "I'm going to say adds 2 plus 2 to equal 4.", 'start': 335.631, 'duration': 6.805}, {'end': 344.838, 'text': 'And then the next parameter will be our function.', 'start': 342.436, 'duration': 2.402}], 'summary': 'Creating a function to add two numbers, exporting it for testing', 'duration': 76.543, 'max_score': 268.295, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho268295.jpg'}, {'end': 764.195, 'src': 'embed', 'start': 741.351, 'weight': 6, 'content': [{'end': 752.091, 'text': "I'm just going to call it create user and I'm going to use curly braces here because we're doing more than just returning one thing.", 'start': 741.351, 'duration': 10.74}, {'end': 754.412, 'text': "We're going to create a variable.", 'start': 752.111, 'duration': 2.301}, {'end': 760.934, 'text': 'Basically, what I want this to do is create a user with a first name and a last name of my first name and last name.', 'start': 754.692, 'duration': 6.242}, {'end': 762.154, 'text': 'And we can do it anyway.', 'start': 760.974, 'duration': 1.18}, {'end': 764.195, 'text': "It doesn't matter how we do it in the function.", 'start': 762.174, 'duration': 2.021}], 'summary': 'Creating a user with first and last name using a function.', 'duration': 22.844, 'max_score': 741.351, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho741351.jpg'}], 'start': 49.006, 'title': 'Javascript unit testing with jest', 'summary': "Introduces basic javascript unit testing with jest, emphasizing its importance for developers in a company setting. it covers setting up jest using 'npm init' and 'npm i jest', writing and running tests for functions, and creating and testing a user object.", 'chapters': [{'end': 147.774, 'start': 49.006, 'title': 'Basic javascript unit testing with jest', 'summary': 'Discusses the importance of learning basic testing practices and technologies for developers, especially if planning to work for a company, and provides an introduction to basic javascript unit testing with jest.', 'duration': 98.768, 'highlights': ['Developers should put time into learning basic testing practices and technologies The speaker emphasizes that all developers should invest time in learning basic testing practices and technologies, as it will most likely be relevant at some point, especially for those planning to work for a company.', 'Introduction to basic JavaScript unit testing with Jest The chapter provides an introduction to basic JavaScript unit testing with Jest, highlighting its simplicity and the ease of learning its basics, which can be beneficial for those new to testing or Jest.', 'The importance of unit testing in reducing workload and preventing errors The speaker emphasizes that unit testing can lessen workload and prevent future errors and issues, providing a more efficient way to check things in the long run.']}, {'end': 901.818, 'start': 148.654, 'title': 'Setting up jest and writing tests', 'summary': "Details the setup of jest by running 'npm init' and 'npm i jest' to create a package.json file and install jest as a dependency. it demonstrates writing and running tests using jest to validate functions, such as add, is null, and check value, providing examples of passing and failing tests with specific matchers, and creating and testing a function that creates a user object.", 'duration': 753.164, 'highlights': ["Setup of Jest and package.json file creation The chapter begins with the setup of Jest by running 'npm init' and creating a package.json file, enabling the installation of Jest as a dependency.", "Installation and usage of Jest The chapter demonstrates the installation of Jest using 'npm i jest' and the creation of a script to run Jest locally, showcasing the usage of Jest for testing JavaScript code.", "Writing and running tests using Jest The chapter illustrates writing and running tests using Jest to validate functions like add, is null, and check value, showing examples of passing and failing tests with specific matchers, such as 'toBe' and 'not.toBe'.", 'Creation and testing of a function to create a user object The chapter covers the creation and testing of a function that creates a user object, demonstrating the use of Jest to validate the returned user object with specific properties.']}], 'duration': 852.812, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho49006.jpg', 'highlights': ['Developers should put time into learning basic testing practices and technologies', 'Introduction to basic JavaScript unit testing with Jest', 'The importance of unit testing in reducing workload and preventing errors', 'Setup of Jest and package.json file creation', 'Installation and usage of Jest', 'Writing and running tests using Jest', 'Creation and testing of a function to create a user object']}, {'end': 1293.82, 'segs': [{'end': 934.806, 'src': 'embed', 'start': 902.499, 'weight': 0, 'content': [{'end': 908.282, 'text': 'So if we scroll up here it actually gives us a pretty good excuse or not excuse, reason why it failed.', 'start': 902.499, 'duration': 5.783}, {'end': 912.545, 'text': 'It says compared values have no visual difference which is true.', 'start': 908.703, 'duration': 3.842}, {'end': 919.669, 'text': 'Looks like you wanted to test for an object or an array equality with the strict 2B matcher.', 'start': 913.145, 'duration': 6.524}, {'end': 921.19, 'text': 'We use the 2B matcher.', 'start': 920.049, 'duration': 1.141}, {'end': 923.592, 'text': 'You probably need to use 2Equal instead.', 'start': 921.23, 'duration': 2.362}, {'end': 934.806, 'text': 'So basically to be is for basically primitive type, so like for is is to be for a strip, which is a number.', 'start': 924.412, 'duration': 10.394}], 'summary': 'The transcript discusses the reason for a test failure due to incorrect matcher usage.', 'duration': 32.307, 'max_score': 902.499, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho902499.jpg'}, {'end': 1011.119, 'src': 'embed', 'start': 979.436, 'weight': 1, 'content': [{'end': 980.456, 'text': 'So keep that in mind.', 'start': 979.436, 'duration': 1.02}, {'end': 984.979, 'text': "And I'll just put a comment here that says to equal.", 'start': 981.317, 'duration': 3.662}, {'end': 987.22, 'text': 'All right.', 'start': 984.999, 'duration': 2.221}, {'end': 997.286, 'text': 'Now, just to touch on some other matches that are available, we have like less than greater than so.', 'start': 987.26, 'duration': 10.026}, {'end': 1010.158, 'text': "to give you an example, we'll say test, let's say should be under 1600.", 'start': 997.286, 'duration': 12.872}, {'end': 1011.119, 'text': "let's say maybe it was.", 'start': 1010.158, 'duration': 0.961}], 'summary': 'Demonstrating the usage of comparison operators, such as equal to, less than, and greater than, with an example of a test value being under 1600.', 'duration': 31.683, 'max_score': 979.436, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho979436.jpg'}, {'end': 1229.932, 'src': 'embed', 'start': 1187.662, 'weight': 2, 'content': [{'end': 1192.065, 'text': "because it has an i, whether it's lowercase or uppercase, it should fail.", 'start': 1187.662, 'duration': 4.403}, {'end': 1195.948, 'text': "okay, so that's regular expressions.", 'start': 1192.065, 'duration': 3.883}, {'end': 1204.095, 'text': "also, if we want to work with arrays, let's do a test.", 'start': 1195.948, 'duration': 8.147}, {'end': 1210.279, 'text': "let's say admin should be in usernames.", 'start': 1204.095, 'duration': 6.184}, {'end': 1220.056, 'text': "so basically what i'm going to do here is i'm going to have an array of usernames And we'll have some names.", 'start': 1210.279, 'duration': 9.777}, {'end': 1222.225, 'text': "So we'll have, let's say, John.", 'start': 1220.197, 'duration': 2.028}, {'end': 1228.691, 'text': "I'll say Karen and admin.", 'start': 1225.388, 'duration': 3.303}, {'end': 1229.932, 'text': 'All right.', 'start': 1228.711, 'duration': 1.221}], 'summary': "Using regular expressions and arrays to enforce username validation, including 'admin' as a required username.", 'duration': 42.27, 'max_score': 1187.662, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho1187662.jpg'}], 'start': 902.499, 'title': 'Javascript testing methods and matchers', 'summary': 'Explains the difference between 2b matcher and 2equal in javascript testing, highlighting their specific use cases. it also covers various testing methods and matchers, demonstrating their usage with examples of passing and failing test cases.', 'chapters': [{'end': 978.595, 'start': 902.499, 'title': 'Javascript testing: 2b matcher vs 2equal', 'summary': 'Explains the difference between 2b matcher and 2equal in javascript testing, highlighting that 2b matcher is for primitive types and 2equal is for objects and arrays, with an example demonstrating the use of 2equal resulting in a passing test.', 'duration': 76.096, 'highlights': ['The 2B matcher is used for primitive types, while 2Equal is used for objects or arrays, with a demonstration of using 2Equal resulting in a passing test', 'Explanation of how objects and arrays are treated differently due to being reference types in JavaScript, with the example of the same-looking objects being stored in different memory areas', "The reason for the failure of the test due to using the 2B matcher instead of 2Equal, with the specific error message indicating 'compared values have no visual difference'"]}, {'end': 1293.82, 'start': 979.436, 'title': 'Testing methods and matchers', 'summary': "Covers various testing methods including comparing values, using regular expressions, and working with arrays. it demonstrates the usage of matchers like 'to equal', 'less than', and 'to contain'. it also provides examples of passing and failing test cases for each method.", 'duration': 314.384, 'highlights': ["It demonstrates the usage of matchers like 'to equal', 'less than', and 'to contain'. The chapter introduces and demonstrates the usage of important matchers like 'to equal', 'less than', and 'to contain' for testing values and arrays.", 'It covers various testing methods including comparing values, using regular expressions, and working with arrays. The chapter provides a comprehensive overview of testing methods, including value comparison, regular expressions, and array manipulation.', 'It also provides examples of passing and failing test cases for each method. The chapter includes examples of both passing and failing test cases to illustrate the effectiveness of the testing methods and matchers.']}], 'duration': 391.321, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho902499.jpg', 'highlights': ['The 2B matcher is used for primitive types, while 2Equal is used for objects or arrays, with a demonstration of using 2Equal resulting in a passing test', "It demonstrates the usage of matchers like 'to equal', 'less than', and 'to contain'. The chapter introduces and demonstrates the usage of important matchers like 'to equal', 'less than', and 'to contain' for testing values and arrays.", 'It covers various testing methods including comparing values, using regular expressions, and working with arrays. The chapter provides a comprehensive overview of testing methods, including value comparison, regular expressions, and array manipulation.']}, {'end': 2103.556, 'segs': [{'end': 1351.187, 'src': 'embed', 'start': 1319.568, 'weight': 1, 'content': [{'end': 1330.531, 'text': "And then we're going to go back to our functions.js, and let's create a function here called fetch user.", 'start': 1319.568, 'duration': 10.963}, {'end': 1336.432, 'text': "And what I'm going to do here, actually, I don't even need that.", 'start': 1333.731, 'duration': 2.701}, {'end': 1338.917, 'text': "Let's say axios.get.", 'start': 1337.216, 'duration': 1.701}, {'end': 1343.701, 'text': "And I'm going to make a get request to the JSON placeholder API.", 'start': 1339.458, 'duration': 4.243}, {'end': 1349.966, 'text': "So if you guys don't know what that is, it's basically a fake REST API for testing.", 'start': 1344.582, 'duration': 5.384}, {'end': 1351.187, 'text': 'You can make requests to.', 'start': 1350.006, 'duration': 1.181}], 'summary': 'Creating a fetch user function using axios.get to make a get request to the json placeholder api for testing.', 'duration': 31.619, 'max_score': 1319.568, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho1319568.jpg'}, {'end': 1524.91, 'src': 'heatmap', 'start': 1409.101, 'weight': 0, 'content': [{'end': 1410.582, 'text': 'All right.', 'start': 1409.101, 'duration': 1.481}, {'end': 1413.725, 'text': "So that's something that you would have in your application.", 'start': 1410.722, 'duration': 3.003}, {'end': 1416.668, 'text': "You're just making a request to an API and you're getting the data.", 'start': 1413.745, 'duration': 2.923}, {'end': 1424.556, 'text': "So let's go into our test file and let's put a comment here.", 'start': 1417.769, 'duration': 6.787}, {'end': 1430.142, 'text': "We'll say working with async data.", 'start': 1424.596, 'duration': 5.546}, {'end': 1446.853, 'text': "Okay, so let's create a test and let's say user fetched name should be, how do we spell this? Leanne Graham.", 'start': 1431.485, 'duration': 15.368}, {'end': 1466.333, 'text': "Okay, When we're dealing with asynchronous data, we actually need to add in here expect.assertions, and then the number of assertions we expect,", 'start': 1452.496, 'duration': 13.837}, {'end': 1467.013, 'text': 'which is 1..', 'start': 1466.333, 'duration': 0.68}, {'end': 1474.478, 'text': 'Now expect.assertions verifies that a certain number of assertions are called, which in this case is 1.', 'start': 1467.013, 'duration': 7.465}, {'end': 1484.109, 'text': 'And this is used when testing asynchronous code in order to make sure that the assertions in a callback or in this case, a dot then of a promise,', 'start': 1474.478, 'duration': 9.631}, {'end': 1485.15, 'text': 'actually get called.', 'start': 1484.109, 'duration': 1.041}, {'end': 1493.219, 'text': "And I believe if we leave this out and the name doesn't match the test will still pass and we can see if that's true or not.", 'start': 1485.871, 'duration': 7.348}, {'end': 1496.623, 'text': "But let's go ahead and keep going here.", 'start': 1494.18, 'duration': 2.443}, {'end': 1501.61, 'text': 'Another thing you want to do is you want to return the promise.', 'start': 1497.004, 'duration': 4.606}, {'end': 1511.183, 'text': 'If you omit this return statement then the test will basically complete before the fetch completes or in this case our Axios get.', 'start': 1502.711, 'duration': 8.472}, {'end': 1518.504, 'text': "So let's say return functions, dot, and we called it what fetch user right?", 'start': 1511.818, 'duration': 6.686}, {'end': 1523.648, 'text': "So fetch user, and it's going to give us a promise.", 'start': 1519.385, 'duration': 4.263}, {'end': 1524.91, 'text': 'so we want to do dot then.', 'start': 1523.648, 'duration': 1.262}], 'summary': 'Testing asynchronous data with assertions to verify one called, and returning the promise for completion.', 'duration': 57.897, 'max_score': 1409.101, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho1409101.jpg'}, {'end': 1714.138, 'src': 'embed', 'start': 1682.478, 'weight': 3, 'content': [{'end': 1686.881, 'text': "So make sure that you have both of those when you're dealing with asynchronous data like this.", 'start': 1682.478, 'duration': 4.403}, {'end': 1688.362, 'text': 'All right.', 'start': 1688.062, 'duration': 0.3}, {'end': 1693.666, 'text': 'Now, if we wanted to refactor this as an async await, we could do that.', 'start': 1688.422, 'duration': 5.244}, {'end': 1695.468, 'text': "So let's just say promise.", 'start': 1693.806, 'duration': 1.662}, {'end': 1697.91, 'text': "And then I'll just grab this.", 'start': 1696.749, 'duration': 1.161}, {'end': 1711.498, 'text': "All right, so to refactor this, what we'll do is we'll mark this as async, as an async function.", 'start': 1704.656, 'duration': 6.842}, {'end': 1714.138, 'text': 'We want to leave the expect assertions.', 'start': 1712.018, 'duration': 2.12}], 'summary': 'Refactor asynchronous data to async await function.', 'duration': 31.66, 'max_score': 1682.478, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho1682478.jpg'}], 'start': 1294.44, 'title': 'Asynchronous data handling and testing', 'summary': 'Covers integrating axios for asynchronous data requests and testing the response, as well as refactoring with async/await syntax. it includes testing async data using assertions, verifying the number of assertions called, and achieving 11 passed tests in total.', 'chapters': [{'end': 1416.668, 'start': 1294.44, 'title': 'Asynchronous data with axios', 'summary': 'Focuses on integrating axios for making asynchronous data requests to a fake rest api and testing the response to ensure the data is retrieved correctly.', 'duration': 122.228, 'highlights': ['The chapter focuses on integrating Axios for making asynchronous data requests to a fake REST API and testing the response to ensure the data is retrieved correctly. The chapter discusses the integration of Axios for asynchronous data requests and testing the response for accurate data retrieval.', 'Axios is installed using npm i axios to facilitate easier HTTP requests compared to using fetch. The instructor installs Axios using npm i axios to simplify HTTP requests, providing an easier alternative to fetch.', "A function called fetch user is created to make a get request to the JSON placeholder API, retrieving a specific user's data. The instructor creates a function called fetch user to perform a get request to the JSON placeholder API and retrieve specific user data.", 'The chapter demonstrates the use of promises with axios.get and tests the response data to ensure the correct information is retrieved. The chapter showcases the use of promises with axios.get to test and verify the accuracy of the retrieved data.']}, {'end': 2103.556, 'start': 1417.769, 'title': 'Testing async data and refactoring with async/await', 'summary': 'Covers testing asynchronous data using assertions in a javascript test file, demonstrating the use of expect.assertions to verify the number of assertions called, and the need to return the promise to ensure completion. it also includes refactoring the code to use async/await syntax and testing a string reversal function with multiple test cases, achieving 11 passed tests in total.', 'duration': 685.787, 'highlights': ['Demonstrating the use of expect.assertions to verify the number of assertions called The chapter emphasizes the use of expect.assertions to ensure a certain number of assertions are called, particularly in testing asynchronous code, thus providing clarity and reliability in the testing process.', 'Need to return the promise to ensure completion and avoid premature test completion The importance of including a return statement for the promise is highlighted, as it ensures the test does not complete prematurely, providing accurate testing of asynchronous data fetching.', 'Refactoring the code to use async/await syntax for improved readability and simplicity The chapter demonstrates the refactoring of code to use the async/await syntax, simplifying the handling of asynchronous operations and enhancing the readability of the test file.', 'Testing a string reversal function with multiple test cases and achieving 11 passed tests The transcript illustrates the testing of a string reversal function with various test cases, including one involving an uppercase letter, and successfully achieving 11 passed tests, showcasing the reliability and correctness of the function.']}], 'duration': 809.116, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho1294440.jpg', 'highlights': ['The chapter demonstrates the use of promises with axios.get and tests the response data to ensure the correct information is retrieved.', 'The chapter focuses on integrating Axios for making asynchronous data requests to a fake REST API and testing the response to ensure the data is retrieved correctly.', 'The chapter emphasizes the use of expect.assertions to ensure a certain number of assertions are called, particularly in testing asynchronous code, thus providing clarity and reliability in the testing process.', 'Refactoring the code to use async/await syntax for improved readability and simplicity']}, {'end': 2827.532, 'segs': [{'end': 2157.832, 'src': 'embed', 'start': 2103.556, 'weight': 1, 'content': [{'end': 2110.161, 'text': 'that it all gets turned to lowercase here before it splits into an array, reverses and then joins back into a string.', 'start': 2103.556, 'duration': 6.605}, {'end': 2111.281, 'text': 'All right.', 'start': 2110.981, 'duration': 0.3}, {'end': 2112.022, 'text': "So that's that.", 'start': 2111.301, 'duration': 0.721}, {'end': 2113.563, 'text': "Let's do another one.", 'start': 2112.222, 'duration': 1.341}, {'end': 2114.944, 'text': "Let's try the chunk.", 'start': 2113.643, 'duration': 1.301}, {'end': 2117.566, 'text': 'Let me just show you real quick what that is.', 'start': 2115.744, 'duration': 1.822}, {'end': 2118.446, 'text': 'The array chunk.', 'start': 2117.606, 'duration': 0.84}, {'end': 2121.008, 'text': 'I think it was session two, actually.', 'start': 2119.047, 'duration': 1.961}, {'end': 2121.589, 'text': 'Yeah, it was.', 'start': 2121.028, 'duration': 0.561}, {'end': 2124.571, 'text': "So let's go back to session two.", 'start': 2121.669, 'duration': 2.902}, {'end': 2129.734, 'text': 'Right here, array chunking.', 'start': 2128.533, 'duration': 1.201}, {'end': 2137.139, 'text': 'And basically what happens is we want to be able to pass in an array and then a number, a length.', 'start': 2130.214, 'duration': 6.925}, {'end': 2141.121, 'text': 'And we want to split this up into chunks of this length.', 'start': 2137.639, 'duration': 3.482}, {'end': 2145.424, 'text': 'So if we passed in 1 through 7, we would want to get this back.', 'start': 2141.241, 'duration': 4.183}, {'end': 2147.425, 'text': 'So chunks of 3.', 'start': 2145.984, 'duration': 1.441}, {'end': 2150.728, 'text': 'So 1, 2, 3 would be one chunk, 4, 5, 6 another.', 'start': 2147.425, 'duration': 3.303}, {'end': 2157.832, 'text': "And then whatever is left over would be put into the next chunk, even if it wasn't 3.", 'start': 2150.808, 'duration': 7.024}], 'summary': 'Demonstrates array chunking by splitting into chunks of 3 and handling leftovers.', 'duration': 54.276, 'max_score': 2103.556, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho2103556.jpg'}, {'end': 2220.35, 'src': 'embed', 'start': 2183.804, 'weight': 3, 'content': [{'end': 2187.026, 'text': "It's not the actual function call, so we'll have to add that in the file.", 'start': 2183.804, 'duration': 3.222}, {'end': 2192.01, 'text': "But I'm going to copy this, and let's create a new file.", 'start': 2187.066, 'duration': 4.944}, {'end': 2195.012, 'text': "We'll call it chunk.js.", 'start': 2192.05, 'duration': 2.962}, {'end': 2202.698, 'text': "Oops, I didn't want that in there, that l.", 'start': 2195.893, 'duration': 6.805}, {'end': 2204.239, 'text': "And then let's create chunk.test.json.", 'start': 2202.698, 'duration': 1.541}, {'end': 2220.35, 'text': "js. okay, and inside chunk we're gonna say const, let's call it chunk array and it's going to take in two things.", 'start': 2208.723, 'duration': 11.627}], 'summary': 'Creating a new file chunk.js and chunk.test.json.js, defining a const chunk array to take in two things.', 'duration': 36.546, 'max_score': 2183.804, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho2183804.jpg'}, {'end': 2308.307, 'src': 'embed', 'start': 2264.39, 'weight': 0, 'content': [{'end': 2266.951, 'text': 'We can grab that from the reverse string test.', 'start': 2264.39, 'duration': 2.561}, {'end': 2273.232, 'text': "So this right here, this first one, and we'll just put that in and we'll check for chunk array.", 'start': 2267.711, 'duration': 5.521}, {'end': 2276.293, 'text': "Let's change the description.", 'start': 2273.252, 'duration': 3.041}, {'end': 2283.435, 'text': "OK, so now let's do a test case, so we'll do test.", 'start': 2276.313, 'duration': 7.122}, {'end': 2298.465, 'text': "and let's say chunk an array of 10 values with a length of 2.", 'start': 2286.523, 'duration': 11.942}, {'end': 2305.386, 'text': "All right, so let's create an array.", 'start': 2298.465, 'duration': 6.921}, {'end': 2308.307, 'text': "They're just arrays of numbers, so I'll call it numbers.", 'start': 2305.646, 'duration': 2.661}], 'summary': 'Testing reverse string with chunk array of 10 values and length of 2', 'duration': 43.917, 'max_score': 2264.39, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho2264390.jpg'}, {'end': 2359.63, 'src': 'embed', 'start': 2332.01, 'weight': 2, 'content': [{'end': 2335.651, 'text': "We're testing an array of 10 values, which we have here, and then a length of two.", 'start': 2332.01, 'duration': 3.641}, {'end': 2341.673, 'text': "And then we're going to say expect and we're going to call chunk.", 'start': 2336.151, 'duration': 5.522}, {'end': 2347.976, 'text': 'Actually, you know what? We want to create a variable called chunked.', 'start': 2343.394, 'duration': 4.582}, {'end': 2354.208, 'text': "say chunked AR, and then this is where we're gonna call the function.", 'start': 2350.367, 'duration': 3.841}, {'end': 2359.63, 'text': "Okay, so we'll say chunk array, and then we'll pass in the numbers array, and we'll pass in the length.", 'start': 2354.228, 'duration': 5.402}], 'summary': 'Testing an array of 10 values, calling chunk function with a length of two.', 'duration': 27.62, 'max_score': 2332.01, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho2332010.jpg'}], 'start': 2103.556, 'title': 'Array chunking algorithm and testing javascript functions', 'summary': 'Demonstrates the array chunking algorithm for splitting arrays into specified lengths, and discusses testing javascript functions for chunking arrays and checking anagrams, with examples of test cases and expected outcomes.', 'chapters': [{'end': 2183.744, 'start': 2103.556, 'title': 'Array chunking algorithm', 'summary': 'Demonstrates the array chunking algorithm, which involves splitting an array into chunks of a specified length and handling the remaining elements, and also introduces the javascript cardio for further learning.', 'duration': 80.188, 'highlights': ['The array chunking algorithm involves splitting an array into chunks of a specified length and handling the remaining elements, as demonstrated using the example of splitting the array 1 through 7 into chunks of 3.', 'Introduction of the JavaScript cardio for further learning and practice with algorithms and problem-solving.', 'Demonstration of converting text to lowercase, splitting it into an array, reversing the array, and joining it back into a string.']}, {'end': 2827.532, 'start': 2183.804, 'title': 'Testing javascript functions', 'summary': 'Discusses creating and testing javascript functions for chunking arrays and checking for anagrams, with examples of test cases and their expected outcomes.', 'duration': 643.728, 'highlights': ['The chapter covers creating and testing JavaScript functions for chunking arrays and checking for anagrams, with examples of test cases and their expected outcomes.', "The process involves creating a new file for the function, defining the function, exporting it, and writing test cases to validate the function's correctness.", 'An example test case involves chunking an array of 10 values with a length of 2, with an expected outcome of an array of chunks.', 'The process of testing the anagram function involves defining the function, exporting it, and writing test cases to validate its correctness, including checking for truthy and falsy outcomes.']}], 'duration': 723.976, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho2103556.jpg', 'highlights': ['The chapter covers creating and testing JavaScript functions for chunking arrays and checking for anagrams, with examples of test cases and their expected outcomes.', 'The array chunking algorithm involves splitting an array into chunks of a specified length and handling the remaining elements, as demonstrated using the example of splitting the array 1 through 7 into chunks of 3.', 'An example test case involves chunking an array of 10 values with a length of 2, with an expected outcome of an array of chunks.', "The process involves creating a new file for the function, defining the function, exporting it, and writing test cases to validate the function's correctness.", 'Demonstration of converting text to lowercase, splitting it into an array, reversing the array, and joining it back into a string.']}, {'end': 3437.34, 'segs': [{'end': 2877.152, 'src': 'embed', 'start': 2852.913, 'weight': 6, 'content': [{'end': 2861.379, 'text': 'now there may be cases where you want to run something before or after a test, or before or after all your tests, and we can.', 'start': 2852.913, 'duration': 8.466}, {'end': 2862.42, 'text': "actually, there's actually.", 'start': 2861.379, 'duration': 1.041}, {'end': 2865.102, 'text': "um, i don't even know what these are really called.", 'start': 2862.42, 'duration': 2.682}, {'end': 2874.33, 'text': "they're kind of like life cycle methods, i guess, but they're functions that will run just then, before, before each test or after each test.", 'start': 2865.102, 'duration': 9.228}, {'end': 2877.152, 'text': 'so i want to show you guys how to use those.', 'start': 2874.33, 'duration': 2.822}], 'summary': 'Demonstrating the use of lifecycle methods for running code before or after tests.', 'duration': 24.239, 'max_score': 2852.913, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho2852913.jpg'}, {'end': 2946.695, 'src': 'embed', 'start': 2911.791, 'weight': 8, 'content': [{'end': 2920.858, 'text': "And then I'll just copy that down and let's say database closed and we'll change this to closed database.", 'start': 2911.791, 'duration': 9.067}, {'end': 2925.362, 'text': 'All right.', 'start': 2925.082, 'duration': 0.28}, {'end': 2926.703, 'text': 'So we have these two functions.', 'start': 2925.382, 'duration': 1.321}, {'end': 2934.029, 'text': "Now, let's say we want to run these before and after each test in this file.", 'start': 2927.103, 'duration': 6.926}, {'end': 2941.652, 'text': "So what we would do is we would say before each And inside here, we'll put in a function.", 'start': 2934.149, 'duration': 7.503}, {'end': 2943.033, 'text': "I'm going to use an arrow function.", 'start': 2941.692, 'duration': 1.341}, {'end': 2946.695, 'text': "And let's say init database.", 'start': 2943.874, 'duration': 2.821}], 'summary': 'Script involves copying, changing database status, and implementing functions for test setup.', 'duration': 34.904, 'max_score': 2911.791, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho2911791.jpg'}, {'end': 3014.592, 'src': 'embed', 'start': 2983.997, 'weight': 0, 'content': [{'end': 2987.801, 'text': 'And then the closed database ran after everyone.', 'start': 2983.997, 'duration': 3.804}, {'end': 2997.93, 'text': 'All right, now what if we want to just run it before all of the tests and then once all the tests complete, we want to run closed database.', 'start': 2988.988, 'duration': 8.942}, {'end': 3002.81, 'text': "So what we would do then, let's actually copy this and comment it out.", 'start': 2998.51, 'duration': 4.3}, {'end': 3009.712, 'text': 'But what we would do then is we would use before all and after all.', 'start': 3005.051, 'duration': 4.661}, {'end': 3014.592, 'text': "Okay, so we'll say before all, after all.", 'start': 3009.732, 'duration': 4.86}], 'summary': 'Using before all and after all to run closed database before and after tests.', 'duration': 30.595, 'max_score': 2983.997, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho2983997.jpg'}, {'end': 3108.419, 'src': 'embed', 'start': 3076.725, 'weight': 2, 'content': [{'end': 3083.09, 'text': "And let's see, we'll create a couple simple tests here that will check names.", 'start': 3076.725, 'duration': 6.365}, {'end': 3087.114, 'text': "So we'll say describe checking names.", 'start': 3083.251, 'duration': 3.863}, {'end': 3090.316, 'text': 'And then we want to put a function.', 'start': 3088.455, 'duration': 1.861}, {'end': 3094.58, 'text': 'And then in here is where we want to put our before each.', 'start': 3090.336, 'duration': 4.244}, {'end': 3096.381, 'text': "Let's just do before each.", 'start': 3095.06, 'duration': 1.321}, {'end': 3105.809, 'text': 'And what I want to run here is a function called name check.', 'start': 3101.405, 'duration': 4.404}, {'end': 3108.419, 'text': 'like that.', 'start': 3107.878, 'duration': 0.541}], 'summary': 'Creating tests to check names using a function called name check.', 'duration': 31.694, 'max_score': 3076.725, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho3076725.jpg'}, {'end': 3322.944, 'src': 'embed', 'start': 3221.519, 'weight': 1, 'content': [{'end': 3225.52, 'text': 'If you need to whatever initialize a database, whatever it may be,', 'start': 3221.519, 'duration': 4.001}, {'end': 3234.763, 'text': 'any kind of functionality that you want to run before a test or before all tests or a certain group of tests, you can do that with these before each,', 'start': 3225.52, 'duration': 9.243}, {'end': 3236.923, 'text': 'before all, and describe.', 'start': 3234.763, 'duration': 2.16}, {'end': 3239.984, 'text': 'And this stuff is all in the documentation, guys.', 'start': 3237.384, 'duration': 2.6}, {'end': 3245.546, 'text': 'If you want to get deeper into it at this time, I would suggest using the documentation.', 'start': 3240.024, 'duration': 5.522}, {'end': 3246.426, 'text': "It's really clear.", 'start': 3245.606, 'duration': 0.82}, {'end': 3247.527, 'text': 'I actually really like it.', 'start': 3246.446, 'duration': 1.081}, {'end': 3253.33, 'text': "Now, there's one more thing that I wanted to show you guys, and that is the watch all flag.", 'start': 3248.547, 'duration': 4.783}, {'end': 3256.892, 'text': "You can actually have your tests run as you're developing.", 'start': 3253.39, 'duration': 3.502}, {'end': 3262.695, 'text': "So what we're going to do is we're going to go to the package JSON file and I'm going to add an additional script here.", 'start': 3257.192, 'duration': 5.503}, {'end': 3273.42, 'text': "You could add it to your just your regular test script if you want, but I'm just going to add a new one called we'll call it test watch.", 'start': 3263.275, 'duration': 10.145}, {'end': 3283.775, 'text': "And then we're going to set this to just And we're going to add the flag dash dash watch all like that.", 'start': 3274.601, 'duration': 9.174}, {'end': 3285.298, 'text': 'All right.', 'start': 3283.795, 'duration': 1.503}, {'end': 3288.164, 'text': "And then down here, I'm going to go ahead and run NPM run test watch.", 'start': 3285.318, 'duration': 2.846}, {'end': 3296.259, 'text': 'All right.', 'start': 3295.939, 'duration': 0.32}, {'end': 3299.142, 'text': "So it's going to go through, it's going to run our tests, I believe.", 'start': 3296.299, 'duration': 2.843}, {'end': 3300.684, 'text': 'Yes, it runs it right off the bat.', 'start': 3299.182, 'duration': 1.502}, {'end': 3311.495, 'text': "But now you can see that it's actually watching and you can press F to run only fail tests or O to run tests related to change files and so on.", 'start': 3301.304, 'duration': 10.191}, {'end': 3317.501, 'text': "But if we leave it as is and we go and we change something like let's go to.", 'start': 3312.015, 'duration': 5.486}, {'end': 3320.683, 'text': "We'll go to reverse string.", 'start': 3319.282, 'duration': 1.401}, {'end': 3322.944, 'text': "And let's remove the two lowercase.", 'start': 3321.203, 'duration': 1.741}], 'summary': 'Demonstrates using before each, before all, and describe in testing, and adding watch all flag for continuous testing.', 'duration': 101.425, 'max_score': 3221.519, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho3221519.jpg'}], 'start': 2827.532, 'title': 'Javascript testing methods', 'summary': 'Covers using before and after methods for initializing and closing a database, targeting specific tests using the describe function and before each hook in jest, and utilizing jest test watch mode for continuous testing and automatic test runs on file changes.', 'chapters': [{'end': 3043.841, 'start': 2827.532, 'title': 'Using lifecycle methods in testing', 'summary': 'Demonstrates how to use before and after methods for initializing and closing a database before or after each test, and before or after all tests, in a javascript testing environment, resulting in all tests passing and running the initialization and closing functions as intended.', 'duration': 216.309, 'highlights': ['The chapter demonstrates how to use before and after methods for initializing and closing a database before or after each test, and before or after all tests, in a JavaScript testing environment. The chapter provides a practical demonstration of using before and after methods for initializing and closing a database before or after each test, and before or after all tests, in a JavaScript testing environment.', 'All of the tests have passed, demonstrating successful implementation of the before and after methods. The chapter confirms that all tests have passed, indicating the successful implementation of the before and after methods for initializing and closing the database.', 'The before and after methods are used to initialize and close the database before or after each test, and before or after all tests. The before and after methods are specifically utilized to initialize and close the database before or after each test, and before or after all tests, ensuring proper execution of these actions within the testing environment.']}, {'end': 3245.546, 'start': 3044.421, 'title': 'Targeted test execution with jest', 'summary': 'Explains how to target specific tests using the describe function and before each hook in jest, allowing for customized test execution and initialization, as demonstrated by running a name check function before specific tests.', 'duration': 201.125, 'highlights': ['The chapter explains how to target specific tests using the describe function and before each hook in Jest. Demonstrates the use of describe and before each for targeted test execution.', 'Running a name check function before specific tests inside the describe block is showcased. Illustrates executing a name check function before specific tests.', 'The chapter emphasizes the flexibility of before each, before all, and describe functions for customizing test execution and initialization. Highlights the flexibility of before each, before all, and describe functions for customization.']}, {'end': 3437.34, 'start': 3245.606, 'title': 'Jest test watch mode', 'summary': 'Explains how to use jest test watch mode in development, enabling continuous testing and automatic test runs on file changes, improving productivity and efficiency for developers.', 'duration': 191.734, 'highlights': ["Jest test watch mode enables continuous testing and automatic test runs on file changes, improving productivity and efficiency for developers. The test watch mode allows tests to run continuously and automatically on file changes, enhancing developers' productivity and efficiency.", "Adding a 'test watch' script in the package.json file with the flag '--watch all' activates the Jest test watch mode for continuous testing. Demonstrates how to set up a 'test watch' script in the package.json file with the '--watch all' flag to enable continuous testing using Jest.", 'Modifying a file triggers automatic test runs, with options to run only fail tests or tests related to changed files, enhancing the development process. Explains how modifying a file triggers automatic test runs, providing options to run only fail tests or tests related to changed files, which enhances the development process.']}], 'duration': 609.808, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7r4xVDI2vho/pics/7r4xVDI2vho2827532.jpg', 'highlights': ['The before and after methods are specifically utilized to initialize and close the database before or after each test, and before or after all tests, ensuring proper execution of these actions within the testing environment.', "The test watch mode allows tests to run continuously and automatically on file changes, enhancing developers' productivity and efficiency.", 'Illustrates executing a name check function before specific tests.', 'The chapter confirms that all tests have passed, indicating the successful implementation of the before and after methods for initializing and closing the database.', "Demonstrates how to set up a 'test watch' script in the package.json file with the '--watch all' flag to enable continuous testing using Jest.", 'Highlights the flexibility of before each, before all, and describe functions for customization.', 'All of the tests have passed, demonstrating successful implementation of the before and after methods.', 'Explains how modifying a file triggers automatic test runs, providing options to run only fail tests or tests related to changed files, which enhances the development process.', 'The chapter provides a practical demonstration of using before and after methods for initializing and closing a database before or after each test, and before or after all tests, in a JavaScript testing environment.', 'Running a name check function before specific tests inside the describe block is showcased.']}], 'highlights': ['Anthro Desk provides affordable and quality stand sit desks and accessories for maintaining back health and productivity, catering to different frame widths based on individual needs.', 'The speaker personally recommends Anthro Desk and emphasizes its positive impact on health and productivity.', 'Developers should put time into learning basic testing practices and technologies', 'Introduction to basic JavaScript unit testing with Jest', 'The importance of unit testing in reducing workload and preventing errors', 'Setup of Jest and package.json file creation', 'Installation and usage of Jest', 'Writing and running tests using Jest', 'Creation and testing of a function to create a user object', 'The 2B matcher is used for primitive types, while 2Equal is used for objects or arrays, with a demonstration of using 2Equal resulting in a passing test', "It demonstrates the usage of matchers like 'to equal', 'less than', and 'to contain'. The chapter introduces and demonstrates the usage of important matchers like 'to equal', 'less than', and 'to contain' for testing values and arrays.", 'It covers various testing methods including comparing values, using regular expressions, and working with arrays. The chapter provides a comprehensive overview of testing methods, including value comparison, regular expressions, and array manipulation.', 'The chapter demonstrates the use of promises with axios.get and tests the response data to ensure the correct information is retrieved.', 'The chapter focuses on integrating Axios for making asynchronous data requests to a fake REST API and testing the response to ensure the data is retrieved correctly.', 'The chapter emphasizes the use of expect.assertions to ensure a certain number of assertions are called, particularly in testing asynchronous code, thus providing clarity and reliability in the testing process.', 'Refactoring the code to use async/await syntax for improved readability and simplicity', 'The chapter covers creating and testing JavaScript functions for chunking arrays and checking for anagrams, with examples of test cases and their expected outcomes.', 'The array chunking algorithm involves splitting an array into chunks of a specified length and handling the remaining elements, as demonstrated using the example of splitting the array 1 through 7 into chunks of 3.', 'An example test case involves chunking an array of 10 values with a length of 2, with an expected outcome of an array of chunks.', "The process involves creating a new file for the function, defining the function, exporting it, and writing test cases to validate the function's correctness.", 'Demonstration of converting text to lowercase, splitting it into an array, reversing the array, and joining it back into a string.', 'The before and after methods are specifically utilized to initialize and close the database before or after each test, and before or after all tests, ensuring proper execution of these actions within the testing environment.', "The test watch mode allows tests to run continuously and automatically on file changes, enhancing developers' productivity and efficiency.", 'Illustrates executing a name check function before specific tests.', 'The chapter confirms that all tests have passed, indicating the successful implementation of the before and after methods for initializing and closing the database.', "Demonstrates how to set up a 'test watch' script in the package.json file with the '--watch all' flag to enable continuous testing using Jest.", 'Highlights the flexibility of before each, before all, and describe functions for customization.', 'All of the tests have passed, demonstrating successful implementation of the before and after methods.', 'Explains how modifying a file triggers automatic test runs, providing options to run only fail tests or tests related to changed files, which enhances the development process.', 'The chapter provides a practical demonstration of using before and after methods for initializing and closing a database before or after each test, and before or after all tests, in a JavaScript testing environment.', 'Running a name check function before specific tests inside the describe block is showcased.']}