---
title: "Test a session trait"
slug: "test-a-session-trait"
abstract: "How to test the output of a session trait in Sitecore CDP by running it against a selected guest."
---
# Test a session trait

We recommend that you test a session trait before [activating](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/developer-center/session-traits/activate-a-session-trait.html "Activate a session trait") it in Sitecore CDP to identify any errors and ensure optimal performance. Testing involves previewing the session trait for a single customer. A successful test indicates that the session trait's JavaScript code is correctly configured.

To test a session trait:

1. Open the session trait and click **Test** ![Test icon](https://doc.sitecore.com/api/markdown-image/cdp/en/users/sitecore-cdp/images/Test_icon.png).

    ![Test a session trait by running its logic against a selected guest.](https://doc.sitecore.com/api/markdown-image/cdp/en/users/sitecore-cdp/images/SessionTraitTestJScode.png)

2. In the **Test** dialog, select a guest to test against by doing one of the following:
    - To select a random guest based on guest type, click in the search box and select **Visitor** or **Customer**.
    - To select a specific guest, enter their unique identifier into the search box. You can search for a guest using, for example, an email address, other unique identifier, or browser ID.
    - To select a recently used guest, click the **Recent** option.
    - To select a bookmarked guest, click the **Bookmark** option.

    > [!tip]
    > You can manually edit the data displayed for the selected guest before initiating the test. This lets you test the session trait logic without the need to find or create a specific guest profile with the relevant attributes.

3. Click **Test** to simulate how the session trait would function in production with the selected guest. The latest session that have a type of *Web* and status *Closed* will be used for the test. The test also includes validating the JavaScript and output values. Review any validation messages, make the necessary code updates, and retest when needed.

    The test will display the output of the session trait, including its runtime and any logs, on the **Response** tab.