Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onderceylan/cypress-plugin

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onderceylan/cypress-plugin

Cypress plugin for ng-apimock

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

ng-apimock/cypress-plugin CircleCI dependency Status devDependency Status

The cypress plugin for ng-apimock.

Usage

This plugin connects to ng-apimock and makes the plugin functions available within the tests.

  1. Enable this plugin in your supports file:
require('@ng-apimock/cypress-plugin').load();
  1. Add environment variables to cypress.json configuration file

Use NG_API_MOCK_ENABLE_LOGS with a string value of "true" or "false". Default: "true". Use NG_API_MOCK_BASE_URL with a string value of base url of your ng-apimock server

{
  "env": {
    "NG_API_MOCK_BASE_URL": "http://localhost:3000",
    "NG_API_MOCK_ENABLE_LOGS": "false"
  }
}
  1. After registering the plugin and adding environment variables to Cypress config, you can use it in your tests by calling it like this:
describe('Some test', () => {
    it('does something', () => 
        cy.selectScenario('my-mock-name', 'some-scenario'));
});

Available plugin functions

The following functions are available. Each plugin function returns a promise.

selectScenario(name: string, scenario: string): Promise;

Selects the given scenario (when calling this function without a scenario or with 'passThrough' as scenario name, the call will be passed through to the actual backend).

delayResponse(mockName: string, delay: number): Promise;

Sets the delay time in milliseconds for the mock. This makes sure the response is delayed. The delay set here overrides the delay defined in the response mock.

echoRequest(name: string, echo: boolean): Promise;

Sets the indicator which enables / disables the request logging.

setVariable(key: string, value: any): Promise;

Adds or updates the global variable.

setVariables(variables: {[key: string]: any;}): Promise;

Adds or updates the global variables ie. {'some':'value', 'another': 'value'}.

deleteVariable(key: string): Promise;

Deletes the global variable.

resetMocksToDefault(): Promise;

Resets all the mocks to the default state.

setMocksToPassThrough(): Promise;

Sets all the mocks to pass through.

setPreset(name: string): Promise;

Sets the mocks and variables in the selected state.

Keywords

FAQs

Package last updated on 04 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc