0

When i run my tests, i get this error in my windows test client

CypressError: cy.exec('npm run -s command') failed because the command exited with a non-zero code.

Pass {failOnNonZeroExit: false} to ignore exit code failures.

Information about the failure: Code: 1

Stderr: C:\Users\Administrator.jenkins\workspace\cypress-execution\node_modules\ssh2\lib\client.js:146 throw new Error('Cannot parse privateKey: ' + privKeyInfo.message);

Deeps
  • 1
  • 1
  • `ssh-exec` hasn't been updated in about 4 years and thus its dependency semver ranges are no longer pulling in newer versions of dependency libraries (especially `ssh2`) that contain important fixes and new features. If I had to guess the reason for the error: it's because the ssh key is in the "new" OpenSSH key file format, which the much older versions of `ssh2` (actually `ssh2-streams`) do not support. – mscdex Apr 23 '20 at 16:56
  • @mscdex Thanks for your input. Do you find any workaround to get it working? Where i am facing this issue is in a VM (in all three my VMs) but at the same time it is working in my laptop which is also windows. – Deeps Apr 24 '20 at 06:14
  • I resolved this issue. it is strange. I created a new user and executed same script with ssh-exec and it started working. earlier i was trying with Administrator account and looks like it is blocking something from execution. Issue is resolved by creating a new user account. Thanks !! – Deeps Apr 24 '20 at 09:04

1 Answers1

0

wrap your code with try... catch block

try {
   throw 'myException'; // your code goes here
}
catch (e) {
   console.log(e);
}
Sergej
  • 2,030
  • 1
  • 18
  • 28
  • I get this error when i used ssh-exec@2.0.0 package to run my ssh cli commands. Not an issue with code. the error is thrown by ssh package – Deeps Apr 23 '20 at 08:14
  • Regarding to the error message, you are missing something like private key. – Sergej Apr 23 '20 at 08:16