Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

199
Vistas
How to create file on SFTP server in Cypress test

When I call the createFile() function in my Cypress test, I am trying to create a file on a hosted SFTP server.

Currently, when I call it, I get the following error message:

The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (C:\Dev\SFTP_POC\cypress\plugins\index.js)

Error: put: Internal server error. sftp://myHost.com@sftp.next.rec-test.com:2022/reports/ at fmtError (C:\Dev\SFTP_POC\node_modules\ssh2-sftp-client\src\utils.js:55:18) at WriteStream. (C:\Dev\SFTP_POC\node_modules\ssh2-sftp-client\src\index.js:728:18) at Object.onceWrapper (events.js:418:26) at WriteStream.emit (events.js:323:22) at Object.cb (C:\Dev\SFTP_POC\node_modules\ssh2\lib\protocol\SFTP.js:3629:12) at 101 (C:\Dev\SFTP_POC\node_modules\ssh2\lib\protocol\SFTP.js:2622:11) at SFTP.push (C:\Dev\SFTP_POC\node_modules\ssh2\lib\protocol\SFTP.js:278:11) at CHANNEL_DATA (C:\Dev\SFTP_POC\node_modules\ssh2\lib\client.js:525:23) at 94 (C:\Dev\SFTP_POC\node_modules\ssh2\lib\protocol\handlers.misc.js:859:16) at Protocol.onPayload (C:\Dev\SFTP_POC\node_modules\ssh2\lib\protocol\Protocol.js:2025:10) at AESGCMDecipherNative.decrypt (C:\Dev\SFTP_POC\node_modules\ssh2\lib\protocol\crypto.js:987:26) at Protocol.parsePacket [as _parse] (C:\Dev\SFTP_POC\node_modules\ssh2\lib\protocol\Protocol.js:1994:25) at Protocol.parse (C:\Dev\SFTP_POC\node_modules\ssh2\lib\protocol\Protocol.js:293:16) at Socket. (C:\Dev\SFTP_POC\node_modules\ssh2\lib\client.js:713:21) at Socket.emit (events.js:311:20) at addChunk (_stream_readable.js:294:12) at readableAddChunk (_stream_readable.js:275:11) at Socket.Readable.push (_stream_readable.js:209:10) at TCP.onStreamRead (internal/stream_base_commons.js:186:23)

Below is my current index.js code:

module.exports = (on, config) => {
  on('task', {
    createFile() {
      const fs = require('fs');
      let data = fs.createReadStream('C:/Dev/SFTP_POC/cypress/fixtures/example.json');
      let remote = 'sftp://myHost.com:2022/reports/'; 
      let Client = require('ssh2-sftp-client');
      let sftp = new Client();
      const config = {
        host: 'myHost.com',
        port: '2022',
        username: 'myUsername',
        password: 'myPassword'
      };

      sftp.connect(config).then(() => {
        sftp.put(data, remote);        
      })
        .then(data => {
          console.log('Success');
        })
        .then(() => {
          sftp.end();
        })
        .catch(err => {
          console.log(err);
        })
      return null;
    }
  })
}

My remote variable is a folder that exists on the server. However, after the test, a new file isn't being added.

Can someone please tell me what I'm doing wrong here, & how to resolve it

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda