cypress-magento-rest-client
v0.0.3
Published
Magento 2 REST API Client
Downloads
1
Readme
This repository contains the cypress-magento-rest-client package, which is a Magento 2 REST API client designed for Cypress integration tests.
Installation
To install the cypress-magento-rest-client package, follow these steps:
- Ensure you have Node.js installed on your machine.
- Create a new Cypress project or navigate to your existing project.
- Run the following command in your project directory to install the package:
$ npm install cypress-magento-rest-client --save-dev`
Usage
To use the cypress-magento-rest-client package in your Cypress spec, follow the example below:
const { Magento2Client } = require('cypress-magento-rest-client');
describe('categories tests', () => {
let client;
before(() => {
client = Magento2Client({
url: Cypress.config('baseUrl'),
consumerKey: Cypress.config('consumerKey'),
consumerSecret: Cypress.config('consumerSecret'),
accessToken: Cypress.config('accessToken'),
accessTokenSecret: Cypress.config('accessTokenSecret')
});
});
it('can get category collection', () => {
cy.wrap(client.categories.list())
.then((categories) => {
expect(categories.parent_id).to.equal(1);
});
cy.log('after list categories test');
});
});