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 - Next.js Tutorial
From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Download courses and learn on the go
Watch courses on your mobile device without an internet connection. Download courses using your iOS or Android LinkedIn Learning app.
Contents
-
-
(Locked)
Section intro1m 59s
-
(Locked)
Create Next app and assets7m 47s
-
(Locked)
ShadCN UI setup4m 44s
-
(Locked)
Root layout and constants10m 4s
-
(Locked)
Header and footer components9m 33s
-
(Locked)
Theme mode toggle13m 29s
-
(Locked)
Loading and not found pages8m 51s
-
(Locked)
Responsive sheet menu8m 11s
-
(Locked)
Sample products and product list9m 34s
-
(Locked)
Product card component6m 42s
-
(Locked)
Product price component4m 58s
-
(Locked)
-
-
(Locked)
Section intro2m 36s
-
(Locked)
PostgreSQL and Prisma setup4m 14s
-
(Locked)
Prisma models and migrations9m 9s
-
(Locked)
Seed sample data4m 4s
-
(Locked)
Load products from database10m 15s
-
(Locked)
Zod validation and type inference16m 51s
-
(Locked)
Serverless environment config8m 9s
-
(Locked)
Product details page14m 49s
-
(Locked)
Product images component7m 59s
-
(Locked)
Initial deployment4m 56s
-
(Locked)
A note on ESLint errors2m 26s
-
(Locked)
-
-
(Locked)
Section intro2m 57s
-
(Locked)
Prisma user-related models9m 45s
-
(Locked)
Seed user data7m
-
(Locked)
NextAuth setup17m 31s
-
(Locked)
NextAuth catch all API route4m 12s
-
(Locked)
Sign-in and sign-out server actions8m 27s
-
(Locked)
Auth layout and sign-in page6m 58s
-
(Locked)
Credentials sign-in form6m 39s
-
(Locked)
Hook up sign-in form9m 28s
-
(Locked)
Callback URL redirect4m 26s
-
(Locked)
User button and sign-out11m 48s
-
(Locked)
Signup Zod schema and action8m 15s
-
(Locked)
Sign-up page and form7m 35s
-
(Locked)
Sign-up error handling12m 40s
-
(Locked)
Customize token with JWT callback8m 19s
-
(Locked)
-
-
(Locked)
Section intro1m 9s
-
(Locked)
Cart Zod schema and Prisma model13m 1s
-
(Locked)
Add to cart component12m 1s
-
(Locked)
Session cart ID8m 28s
-
(Locked)
Get item for cart13m 14s
-
(Locked)
Price calc for cart15m 38s
-
(Locked)
Handle quantity and multiple products11m 45s
-
(Locked)
Remove cart action8m 1s
-
(Locked)
Dynamic cart button8m 1s
-
(Locked)
Smooth UI with useTransition5m 57s
-
(Locked)
-
-
(Locked)
Section intro1m 22s
-
(Locked)
Cart page8m 23s
-
(Locked)
ShadCN UI table10m 52s
-
(Locked)
Subtotal cart8m 7s
-
(Locked)
Shipping address Zod schema and page9m 30s
-
(Locked)
Shipping address form20m 7s
-
(Locked)
Update user address8m 21s
-
(Locked)
Checkout steps component7m 1s
-
(Locked)
Persist session cart5m 30s
-
(Locked)
Protecting paths5m 47s
-
(Locked)
-
-
(Locked)
Section intro1m 31s
-
(Locked)
Payment method and Zod schemas9m 27s
-
(Locked)
Payment method page8m 1s
-
(Locked)
Payment method form and update13m 9s
-
(Locked)
Order and OrderItem Prisma models11m 7s
-
(Locked)
Order Zod schemas and types8m 16s
-
(Locked)
Place order page18m 5s
-
(Locked)
Create order action14m 15s
-
(Locked)
Place order form7m 37s
-
(Locked)
Order page and action8m 27s
-
(Locked)
Format utility functions8m 20s
-
(Locked)
Order details table14m 5s
-
(Locked)
-
-
(Locked)
Section intro1m 13s
-
(Locked)
PayPal sandbox setup3m 32s
-
(Locked)
Generate access token9m 9s
-
(Locked)
Jest testing for access token7m 42s
-
(Locked)
Create order and capture API requests8m 45s
-
(Locked)
Jest testing for order and payment8m 7s
-
(Locked)
Create PayPal order action7m 57s
-
(Locked)
Approve and update order15m 30s
-
(Locked)
Implement PayPal button12m 4s
-
(Locked)
-
-
(Locked)
Section intro55s
-
(Locked)
Admin layout and menu8m 6s
-
(Locked)
Get order summary10m 21s
-
(Locked)
Admin overview data display16m 47s
-
(Locked)
Monthly sales chart8m 24s
-
(Locked)
Admin orders page and action11m 31s
-
(Locked)
Delete orders15m 53s
-
(Locked)
Update order actions (COD)5m 40s
-
(Locked)
Update order buttons (COD)13m 2s
-
(Locked)
-
-
(Locked)
Section intro1m 11s
-
(Locked)
Get products for admin page8m 24s
-
(Locked)
Display products7m 55s
-
(Locked)
Delete products4m 16s
-
(Locked)
Create and update actions8m 30s
-
(Locked)
Create product page and form9m 35s
-
(Locked)
Form fields and slugify13m 27s
-
(Locked)
Create product form submission6m 23s
-
(Locked)
Uploadthing configuration8m 9s
-
(Locked)
Add image upload12m 56s
-
(Locked)
Product cleanup7m 57s
-
(Locked)
Is featured banner8m 55s
-
(Locked)
Product update form9m 57s
-
(Locked)
-
-
(Locked)
Section intro1m 8s
-
(Locked)
Get and display users12m 57s
-
(Locked)
Delete users3m 12s
-
(Locked)
User edit page9m 14s
-
(Locked)
Update user form14m 16s
-
(Locked)
Update user action6m 48s
-
(Locked)
Admin search form11m 4s
-
(Locked)
Admin orders search5m 41s
-
(Locked)
Admin users search3m 15s
-
(Locked)
-
-
(Locked)
Section intro1m 19s
-
(Locked)
Category drawer8m 43s
-
(Locked)
Featured product carousel13m 32s
-
(Locked)
Search component8m 38s
-
(Locked)
Search page12m 52s
-
(Locked)
Search filters10m 55s
-
(Locked)
Get filter URL function6m 37s
-
(Locked)
Category and price UI filters9m 51s
-
(Locked)
Rating filter and filter display10m 1s
-
(Locked)
Sorting products5m 50s
-
(Locked)
Dynamic metadata7m 46s
-
(Locked)
-
-
(Locked)
Section intro59s
-
(Locked)
Review Prisma model, Zod, and type10m 32s
-
(Locked)
Review list component9m 26s
-
(Locked)
Review form dialog15m 30s
-
(Locked)
Create and update review action11m 50s
-
(Locked)
Connect review form to action7m 2s
-
(Locked)
Get reviews action3m 48s
-
(Locked)
Display reviews12m
-
(Locked)
Update and reload reviews3m 58s
-
(Locked)