This package, `drupal-test-session-cypress` (current version 1.1.66), provides Cypress commands that streamline interaction with Drupal's Test Session module. Its primary function is to extend the Cypress API with `cy.drupalSession()`, enabling testers to easily manage Drupal user sessions and state directly within their end-to-end tests. This abstraction simplifies common testing scenarios like logging in users, asserting permissions, and resetting session data, which otherwise would require complex custom commands or direct API calls to the Drupal backend. The package is typically installed as a development dependency and integrates by requiring it within Cypress's `support/index.js` (or `.ts`) file, making its commands globally available to Cypress tests. It offers a focused solution for projects leveraging Drupal and Cypress, differentiating itself by tightly coupling with the specific Drupal module. The Drupal Test Session module itself is marked as 'minimally maintained' and 'feature-complete' on Drupal.org, and this Cypress wrapper aligns with that stability.
npm install drupal-test-session-cypressVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to include the package in the Cypress support file and provides runnable Cypress tests for logging in and logging out Drupal users using `cy.drupalSession()`.
Ensure the 'Test Session' module is enabled and accessible at the `/test-session` endpoint on your Drupal site. Consult the Drupal Test Session module documentation for setup instructions.
Set `DRUPAL_BASE_URL` in your `cypress.config.ts` or `cypress.env.json` file, or as a system environment variable prefixed with `CYPRESS_` (e.g., `CYPRESS_DRUPAL_BASE_URL=https://my-drupal.com`).
Add `require('drupal-test-session-cypress');` to your primary Cypress support file (e.g., `cypress/support/e2e.ts`).Include `cy.visit(Cypress.env('DRUPAL_BASE_URL'))` or a specific Drupal page in your `beforeEach` hook before making `cy.drupalSession()` calls.Add `require('drupal-test-session-cypress');` to your `cypress/support/index.js` or `cypress/support/e2e.ts` file.Define `DRUPAL_BASE_URL` in your `cypress.config.ts/js` (e.g., `env: { DRUPAL_BASE_URL: 'http://my-drupal.local' }`), `cypress.env.json`, or as a system environment variable prefixed with `CYPRESS_` (e.g., `CYPRESS_DRUPAL_BASE_URL=http://my-site.com`).Verify that the Drupal Test Session module is installed and enabled on your Drupal site. Double-check the `DRUPAL_BASE_URL` in your Cypress configuration to ensure it points to the correct Drupal instance.