Cypress plugin
@ng-apimock/cypress-plugin is the cypress plugin for @ng-apimock/core.
This plugin connects to @ng-apimock/core middelware and makes the all its features available in the tests.
Requirements
see Ng-apimock requirements
Installing using npm / yarn
npm install @ng-apimock/cypress-plugin --save-dev
or
yarn add @ng-apimock/cypress-plugin --dev
Usage
Once the plugin has been installed, enable this plugin in your supports file
require('@ng-apimock/cypress-plugin').load();
Plugin configuration
Add environment variables to cypress.json
configuration file
{
"env": {
"NG_API_MOCK_BASE_IDENTIFIER": "my-identifier", // optional: defaults to apimockId (the cookie identifier)
"NG_API_MOCK_BASE_URL": "http://localhost:3000",
"NG_API_MOCK_BASE_PATH": "myapimock", // optional: defaults to ngapimock (path on which ngapimock listens)
"NG_API_MOCK_ENABLE_LOGS": "false"
}
}
Using in tests
Now you can use it.
describe('Some test', () => {
it('does something', () =>
cy.selectScenario('my-mock-name', 'some-scenario'));
});
API
See API