Giter Club home page Giter Club logo

cypress-wordpress-session's Introduction

cypress-wordpress-session

This module can be used to restore a Wordpress session in Cypress by automatically saving Wordpress login cookies to a file.

By default, it'll save the cookies to an invisible JSON file with path .wordpress-login-cookies.json. Only relevant cookie data will be saved. If you're using git, it'd probably be a good idea to add this path to your .gitignore file for security reasons!

If the file exists, this module will access it to restore your session. If the file doesn't exist or the cookie is invalid, it will attempt to login from scratch.

If you've already configured your Cypress project to navigate to Wordpress, you just need to import this module, supply login credentials and it'll handle the rest for you.

Multiple users and domains are supported! Provided the login cookies are still valid, you can use this module to switch users between tests (or even within the same test) without going back to the login screen.

For example:

import "cypress-wordpress-session";

const username = "admin";
const password = "123";

const options = {};

describe("Admin: article", () => {
  beforeEach(() => {
    cy.wordpressSession(username, password, options);
  });

  it("does something in wordpress", () => {
    // test code here
  });
});

The only required parameters are username and password.

Parameters

Name Type Default value Description
username string undefined Wordpress username
password string undefined Wordpress password
options object see table below Various options, see table below

Options

Name Type Default value Description
cookiesFilepath string .wordpress-login-cookies.json The location at which the cookies are saved & restored
verboseLogging boolean false Enable verbose logging
landingPage string /wp-admin The page to land on once logged in or once the session has been restored. Can be set to a falsy value to prevent this.
obscurePassword boolean true Hide the password from the session parameters, thus preventing it from being easily viewable in the Cypress GUI
sessionOptions object { cacheAcrossSpecs: true } Cypress session options (see Cypress docs)

cypress-wordpress-session's People

Contributors

benchesh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.