Mock the Session Cookie for Testing in a Next.js Application

Overview

This article provides guidance on how to generate a mock appSession cookie for testing purposes in a Next.js application. This method allows for the complete isolation of automated tests from Auth0.

Applies To

  • Next.js
  • Session Cookie

Solution

The appSession cookie is used by the Next.js Software Development Kit (SDK) to establish a local session and avoid unnecessary calls to Auth0 endpoints.

To mock the session cookie, use the following resources:

  • Refer to the testing utility for generating session cookies for End-to-End (E2E) tests using the generateSessionCookie helper function.

  • Refer to general testing advice for the Next.js SDK: Testing helpers.

Recommended content

No recommended content found...