This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

cypress-helper-history
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

cypress-helper-history

A Cypress command for navigating via the History API during tests; an alternative to cy.visit for manually navigating within single page applications.

Uses window.history.pushState by default, but you can make the helper use a history instance as well.

npm version npm downloads

Setup

1. Install package

npm install --save-dev cypress-helper-history

2. Import Cypress command

// E.g. in cypress/support/index.js
import 'cypress-helper-history';

3. Expose your history (optional)

// E.g. in src/history.js
 
// Create your history instance, for example like this:
import { createBrowserHistory as createHistory } from 'history';
 
const history = createHistory();
export default history;
 
// Then expose it to the helper like this:
if ('Cypress' in window) {
  window.__chh__history__ = history;
}

Usage

describe('cypress-helper-navigate', () => {
  before(() => {
    cy.visit('/');
  });
 
  it('can do client-side navigation', () => {
    cy.location('pathname').should('equal', '/');
    cy.navigate('/example');
    cy.location('pathname').should('equal', '/example');
  });
 
  it('supports log option', () => {
    cy.navigate('/not-logged', undefined, { log: false });
  });
 
  it('supports passing in state', () => {
    cy.navigate('/with-state', { foo: 'bar' });
  });
});

Package Sidebar

Install

npm i cypress-helper-history

Weekly Downloads

4

Version

1.0.2

License

MIT

Unpacked Size

5.62 kB

Total Files

8

Last publish

Collaborators

  • svish