cypress-placeholder-replacer-command

A cypress command to replace placeholders within json object or string

Usage no npm install needed!

<script type="module">
  import cypressPlaceholderReplacerCommand from 'https://cdn.skypack.dev/cypress-placeholder-replacer-command';
</script>

README

cypress-placeholder-replacer-command

Build Status dependencies Status devDependencies Status Known Vulnerabilities

Npm version Npm downloads Npm download size Last Commit Contributors

A collection of two cypress commands :

  • replacePlaceholders : provides the ability to replace placeholders within json object or string
  • expectDeepEquals : provides the ability to expect two json objects (or string) to be tested as being "deeply" equal while optionally replacing placeholders within the "expected" item if a map with placeholders / values is provided

The replacePlaceholders can be (optionally) chained as child command of e.g. a fixture command Internally it is using the simple-placeholder-replacer

Installation

To install with npm:

npm i cypress-placeholder-replacer-command --save

Usage

Usage within Cypress:

import 'cypress-placeholder-replacer-command'

cy.replacePlaceholders("My name is {{myName}}", {myName: "Benoit Wauthier"})
cy.fixture("myfixutres/mynamefixture.json).replacePlaceholders({myName: "Benoit Wauthier"})
cy.expectDeepEquals(actual, expected)
cy.expectDeepEquals(actual, expected, {myName: "Benoit Wauthier"})

Release

npm version major / minor / patch
git push origin ${tagName}

License

This is licensed under an MIT License. See details