From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Jest testing for access token

Jest testing for access token

All right guys, so we're gonna kind of take an aside I guess you could call this from the the project code and we're gonna write some unit tests now in this video We're specifically gonna write one test to test the last function. We wrote which was the PayPal Generate access token, right? So we created this it's gonna reach out to the the PayPal API with our secret and client ID It's gonna get the response and I want to see if that response is correct. So Let's go ahead and write a short unit test that will actually run the function, see what we get, make sure it's a string, and so on. All right, now we're going to be using Jest, which is a testing library, and it's pretty easy to use. We're not doing anything difficult. The tests we're going to write are very, very simple. So to install Jest, we want to run npm install dash uppercase D for dev dependencies, and we want to do Jest. And since we're using TypeScript, we want to do tsgest and tsnode, so we can run TypeScript files from…

Contents