Code Monkey home page Code Monkey logo

cypress-file-upload's Introduction

cypress-file-upload

GitHub license npm version CircleCI Status Contributors

Simple custom Cypress command to ease file upload testing.

Table of Contents

Installation

This module is distributed via npm which is bundled with uglify-es and should be installed as one of your project's devDependencies:

npm install --save-dev cypress-file-upload

Usage

cypress-file-upload extends Cypress' cy command. Add this line to your project's cypress/support/commands.js:

import 'cypress-file-upload';

Here is a simple example:

cy.fixture('data.json', 'base64').then(fileContent => {
  cy.get('[data-cy="dropzone"]').upload(
    { fileContent, fileName: 'data.png', mimeType: 'application/json' },
    { subjectType: 'drag-n-drop' },
  );
});

Please see full version in example.

API

Exposed command in a nutshell:

cySubject.upload(fileOrArray, processingOpts);

fileOrArray is an object (or an array of those) that represents file information and contains following properties:

  • {String} fileContent – raw file content
  • {String} fileName – file name with extension
  • {String} mimeType – file mime type

processingOpts contains following properties:

  • {String} subjectType – target (aka subject) element kind: 'drag-n-drop' component or plain HTML 'input' element. Defaults to 'input'.

Contributors

Thanks goes to these wonderful people (emoji key):

James Hollowell
James Hollowell

💻
Oliver O'Donnell
Oliver O'Donnell

💻
Peter Colapietro
Peter Colapietro

📖
km333
km333

🐛
Kevin Mui
Kevin Mui

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT

cypress-file-upload's People

Contributors

abramenal avatar allcontributors[bot] avatar allout58 avatar benwurth avatar kmui2 avatar ollie-o avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.