npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cypress-upload-file

v1.0.6

Published

easy upload any file using cypress

Downloads

249

Readme

Cypress Upload File

GitHub license npm version

Upload any file quickly and easily with cypress! You only need two lines of code to upload it! This library works with cypress in version 5.5.0 and also with higher and lower versions!

How to install

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

How to use

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

import uploadFile from "cypress-upload-file";
describe("Upload the file", () => {
  it("Upload the file and assert the name of the file uploaded", () => {
    cy.visit("https://the-internet.herokuapp.com/upload");

    // Name of the file in your directory cypress/fixture
    // If yout file is inside another folder you must put the path
    // example 'folderName/blank.pdf'
    const fileName = "blank.pdf";
    // The type extension for this file like: image/png, image/jpeg, video/mp4, application/pdf, text/plain, application/json
    const fileType = "image/png";
    // Selector path to find the input element in UI that we want to upload a file, in our example the element
    // has an id name "file-upload" so we can use here "#file-upload"
    const selector = "#file-upload";

    uploadFile(selector, fileName, fileType);
    cy.get("#file-submit").click();
    cy.get("#uploaded-files").contains("blank");
  });
});

Documentation

This function help cypress to upload a file to a file upload input
using any type of file extension: png, jpg, jpeg, gif, pdf, svg, mp4, mp3, docx.
You need to have your file stored in fixtures cypress directory
Call this function with some selector element, with file name, and file type.
File extension types must be input like:
- image/png
- image/jpeg
- image/jpg
- video/mp4
- application/pdf
- application/json
- text/plain
- image/gif
- text/html
- audio/mpeg
- audio/ogg
- audio/mp3

- @param {String} selectorElement Some selector information to find the file upload input element
- @param {String} fileName Name of the file with with its extension, exampĺe image.png
- @param {String} fileType The file type extension like: image/png, image/jpeg, video/mp4, image/gif, application/pdf, text/plain, application/json, audio/mpeg
- @return {VoidFunction} This function don't returned anything

Feature Request

If you have any feature request just open an issue describing your request or feel free with your feature! Any pull pull request are welcome!

Found an issue?

Register the issue here and wait for us to solve it as soon as possible. In addition, any contribution is welcome, so feel free to make a pull request if you want to solve any problem :happy:

License

MIT