4.1.0 • Published 7 months ago

cypress-sftp-client v4.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

cypress-sftp-client

Wrapped ssh2-sftp-client to cypress framework tasks.

Adding to project

Add following lines to your commands.ts:

/// <reference types="Cypress plugin for SFTP client" />

import "cypress-sftp-client/commands";

Add following lines to your plugins/index.ts:

// plugins file

import sftpClient from "cypress-sftp-client/plugin";

function register(on: Cypress.PluginEvents): void {
    sftpClient(on);
}

export = register;

Example

describe("SFTP client", () => {
    const debug = true;
    const rootDir = "sftp_client_test";
    const connectionSettings: ISftpConnectionSettings = {
        host: "127.0.0.1",
        port: 22,
        userName: "user",
        password: "password",
        protocol: "IPv4", // "IPv6"
        dir: rootDir,
    };

    const dirInput = "input";
    const fileName = dirInput + "/test.txt";

    it("walk around SFTP tasks", () => {
        cy.sftpCreateDirectory({
            debug,
            connectionSettings,
            directoryName: [dirInput],
        }).then((r) => {
            cy.log("sftpCreateDirectory result", r);
        });

        cy.sftpUpload({
            debug,
            connectionSettings,
            content: "content",
            fileName,
        }).then((r) => {
            cy.log("sftpUpload result", r);
        });

        cy.sftpExists({
            debug,
            connectionSettings,
            fileName,
        }).then((r) => {
            cy.log("sftpExists result", r);
            expect(r.isExisting).is.be.true;
        });

        cy.sftpList({
            debug,
            directory: dirInput,
            connectionSettings,
        }).then((r) => {
            cy.log("sftpList result" + r.files.map((f) => `${f.fileName} - ${f.modifiedDate}`), r);
        });

        cy.sftpDownload({
            debug,
            connectionSettings,
            fileName: fileName,
        }).then((r) => {
            cy.log("sftpDownload result" + r.fileContent, r);
        });

        cy.sftpDelete({
            debug,
            connectionSettings,
            fileNames: [fileName],
        }).then((r) => {
            cy.log("sftpDelete result", r);
        });
    });
});

How to Develop

To build plugin run webpack with specific config:

npx webpack --config webpack.config.plugin.ts -w

and then run cypress:

npx cypress open

How to run example

In root folder run:

npx tsc
node sftpClient
4.1.0

7 months ago

3.0.2

1 year ago

4.0.0

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.0

2 years ago

1.0.0

2 years ago

0.1.0

2 years ago

0.1.1

2 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.6

2 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago