Skip to content

Commit

Permalink
0.2.2 Pass options to visit commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam Defty committed Apr 9, 2020
1 parent 4414dd6 commit b9157a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ const commands = {
cy.exec(`node_modules/.bin/wp-cypress wp "plugin deactivate ${name}"`);
},

visitAdmin() {
cy.visit('/wp-admin/index.php');
visitAdmin(options = {}) {
cy.visit('/wp-admin/index.php', options);
},

// Posts
editPost(id) {
cy.visit(`/wp-admin/post.php?post=${id}&action=edit`);
editPost(id, options = {}) {
cy.visit(`/wp-admin/post.php?post=${id}&action=edit`, options);
},

saveCurrentPost() {
Expand Down
8 changes: 6 additions & 2 deletions lib/hooks.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/* eslint-disable no-param-reassign */
const unfetch = require('unfetch');
let fetchPolyfill;

before(() => {
cy.resetDB();
cy.readFile('./node_modules/@bigbite/wp-cypress/node_modules/unfetch/dist/unfetch.umd.js').then((content) => {
fetchPolyfill = content;
});
});

beforeEach(() => {
Expand All @@ -13,5 +16,6 @@ Cypress.on('uncaught:exception', () => false);

Cypress.on('window:before:load', (win) => {
delete win.fetch;
win.fetch = unfetch;
win.eval(fetchPolyfill);
win.fetch = win.unfetch;
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bigbite/wp-cypress",
"version": "0.2.1",
"version": "0.2.2",
"description": "WordPress end to end testing with Cypress.io",
"main": "lib/index.js",
"repository": "https://github.com/bigbite/wp-cypress",
Expand Down

0 comments on commit b9157a8

Please sign in to comment.