All Projects → dbalatero → cypress-plugin-stripe-elements

dbalatero / cypress-plugin-stripe-elements

Licence: MIT License
A small Cypress plugin that assists you in filling in Stripe Elements inputs

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to cypress-plugin-stripe-elements

Cypress
Fast, easy and reliable testing for anything that runs in a browser.
Stars: ✭ 35,145 (+159650%)
Mutual labels:  testing-tools, cypress, e2e-testing
cypress-browserify-preprocessor
Cypress preprocessor for bundling JavaScript via browserify
Stars: ✭ 23 (+4.55%)
Mutual labels:  cypress, cypress-plugin
cypress-upload-file-post-form
Solution for two Cypress testing use-cases I came across with: perform a direct http FORM request to the server containing a file and other parameters and upload a file into a form before submission
Stars: ✭ 59 (+168.18%)
Mutual labels:  cypress, e2e-testing
Recorder
A browser extension that generates Cypress, Playwright and Puppeteer test scripts from your interactions 🖱 ⌨
Stars: ✭ 277 (+1159.09%)
Mutual labels:  testing-tools, cypress
main
Mocks Server monorepo
Stars: ✭ 109 (+395.45%)
Mutual labels:  testing-tools, cypress
odoo-cypress
Odoo Framework E2E Testing using Cypress
Stars: ✭ 19 (-13.64%)
Mutual labels:  cypress, e2e-testing
cypress-get-it
Get elements by data attribute by creating a Cy command on the fly
Stars: ✭ 23 (+4.55%)
Mutual labels:  cypress, cypress-plugin
ember-stripe-elements
A simple Ember wrapper for Stripe Elements.
Stars: ✭ 64 (+190.91%)
Mutual labels:  stripe, stripe-elements
three-musketeers
A simple module to introspect, debug and test any THREE.js application.
Stars: ✭ 30 (+36.36%)
Mutual labels:  testing-tools, e2e-testing
cypress-browser-permissions
A Cypress plugin to set launched browser preferences including permissions like Geolocation, Notifications, Microphone, etc.
Stars: ✭ 40 (+81.82%)
Mutual labels:  cypress, cypress-plugin
cypress-watch-and-reload
Reloads Cypress when one of the watched files changes
Stars: ✭ 46 (+109.09%)
Mutual labels:  cypress, cypress-plugin
commercejs-chopchop-demo
A Commerce.js starter kit for Next.js. A beautifully designed elegantly developed, end to end commerce experience for developers and agencies. Pre-integrated with Stripe. One-click deploy to Vercel.
Stars: ✭ 129 (+486.36%)
Mutual labels:  stripe, stripe-elements
cypress-xpath
Adds XPath command to Cypress test runner
Stars: ✭ 145 (+559.09%)
Mutual labels:  cypress, cypress-plugin
quasar-testing
Testing Harness App Extensions for the Quasar Framework 1.0+
Stars: ✭ 142 (+545.45%)
Mutual labels:  cypress, e2e-testing
react-stripe-script-loader
A React Component that loads Stripe script if necessary and shows React Stripe Elements
Stars: ✭ 22 (+0%)
Mutual labels:  stripe, stripe-elements
payment-form-modal
How to implement Stripe Elements within a modal dialog.
Stars: ✭ 108 (+390.91%)
Mutual labels:  stripe, stripe-elements
cypress-auto-stub-example
Example project to demonstrate how to record/replay API with Cypress.
Stars: ✭ 52 (+136.36%)
Mutual labels:  cypress, e2e-testing
Penny-Seed
PennySeed is an alternative crowdfunding platform where the funding goal is divided by the number of pledgers
Stars: ✭ 18 (-18.18%)
Mutual labels:  stripe, stripe-elements
software-testing-resource-pack
Various files useful for manual testing and test automation etc.
Stars: ✭ 38 (+72.73%)
Mutual labels:  testing-tools, e2e-testing
nuxt-stripejs
💳 NuxtJS module for Stripe.js which loads only when required and w/ retry mechanism
Stars: ✭ 17 (-22.73%)
Mutual labels:  stripe, stripe-elements

cypress-plugin-stripe-elements

Github Stars

This plugin provides a fillElementsInput that makes it easy to fill out Stripe Elements inputs without cy.wait() hacks or anything else.

cy.fillElementsInput('cardNumber', '4242424242424242');

Installation

npm install --save-dev cypress-plugin-stripe-elements
# or
yarn add --dev cypress-plugin-stripe-elements

Set { "chromeWebSecurity": false } in your cypress.json file, or the plugin will not work.

Import the plugin in your cypress/support/index.js file:

// cypress/support/index.js

import 'cypress-plugin-stripe-elements';

TypeScript

Make sure to include the following types in your tsconfig.json file:

{
  "compilerOptions": {
    "types": ["cypress", "cypress-plugin-stripe-elements"]
  }
}

Usage

This package provides a cy.fillElementsInput(name, value) command.

The name parameter can be one of:

  • cardNumber - credit card number field
  • cardExpiry - credit card MM/YY expiry field
  • cardCvc - credit card 3-digit CVC field
  • postalCode - postal/ZIP code

or any string value matching the data-elements-stable-field-name attribute of the Elements <input> you want to target. Use the DevTools/inspector to figure out the stable field name.

The value is whatever string you want to fill the field with.

describe('payment form', () => {
  it('allows for a successful payment', () => {
    cy.visit(`http://localhost:4000`);

    // It's recommended to scope `fillElementsInput` to a specific container
    // in case you have multiple Stripe Elements on the page.
    cy.get('#card-element').within(() => {
      cy.fillElementsInput('cardNumber', '4242424242424242');
      cy.fillElementsInput('cardExpiry', '1025'); // MMYY
      cy.fillElementsInput('cardCvc', '123');
      cy.fillElementsInput('postalCode', '90210');
    });

    // Click your Pay button (yours is different)
    // cy.get('#pay-button').click();

    // TODO: Assert some success state
  })
})

Development

To modify this plugin, git clone the repo and run yarn install. You can run the tests with yarn test after setting the environment variables CYPRESS_TEST_APP_PORT and STRIPE_PUBLISHABLE_KEY:

CYPRESS_TEST_APP_PORT=4000 STRIPE_PUBLISHABLE_KEY=your_key_here yarn test

Examples

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].