JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q47020F
  • License MIT

Cypress plugin for Spring Contract Stubs

Package Exports

  • cypress-contract-stubs
  • cypress-contract-stubs/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cypress-contract-stubs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Cypress Contract Stubs

Npm Github Action Jest Codecov

The cypress-contract-stubs adds support for using Spring Cloud Contract Stub entries when testing with Cypress. This plugin is able to download artifacts form nexus and nexus3 artifact repository and cache the stubs in local for better runtime performance.

Get started

Installation

Install the plugin by running:

npm install --save-dev cypress-contract-stubs

Cypress Configuration

Add it to your plugin file:

cypress/plugins/index.js

const { contractStubsPlugin } = require('cypress-contract-stubs');

module.exports = async (on, config) => {
  await contractStubsPlugin(on, config);
  
  return config;
}

Add configuration for remote and local stubs to your Cypress configuration.

The default mode is remote and the default type is nexus3

cypress.json

{
  "env": {
    "stubs": [
      {
        "mode": "remote",
        "id": "internal.contracts:artifact-name:+:stubs",
        "type": "nexus3",
        "server": "http://nexus3.proxy.internal",
        "repository": "maven-releases"
      },
      {
        "mode": "remote",
        "id": "internal.contracts:artifact-name:+:stubs",
        "type": "nexus",
        "server": "http://nexus.proxy.internal",
        "repository": "releases"
      },
      {
        "mode": "local",
        "file": "artifact-name-1.318-SNAPSHOT-stubs.jar"
      },
      {
        "mode": "local",
        "file": "artifact-name-stubs.jar",
        "path": "cypress/fixtures"
      }
    ]
  }
}

Use cy commands

Add it to your support file:

cypress/support/index.js

import 'cypress-contract-stubs/commands';

In your test files, will be available the following commands:

  • cy.contractStubs Get all available stub entries
  • cy.contractStub Get stub entry by options (if more stubs match the criteria will be returned the first occurrence)
cy.contractStubs().then((stubs) => console.log(stubs));
cy.contractStub({ name: 'stubName' }).then((stub) => console.log(stub));

License

cypress-contract-stubs is MIT licensed.