Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Using cy.exec to run a npm command using nvm shows the following output #15103

Closed
ghost opened this issue Feb 16, 2021 · 1 comment
Closed

Using cy.exec to run a npm command using nvm shows the following output #15103

ghost opened this issue Feb 16, 2021 · 1 comment
Labels
type: duplicate This issue or pull request already exists

Comments

@ghost
Copy link

ghost commented Feb 16, 2021

Current behavior

When the npm command is run in a cy.exec, npm not found is shown as the output. But on refreshing it the command is run without any errors.
Error: CypressError: cy.exec('npm run removeDB')` failed because the command exited with a non-zero code.

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

Information about the failure:
Code: 127

Stderr:
zsh:1: command not found: npm

Because this error occurred during a before all hook we are skipping the remaining tests in the current suite: Test Cases - __AD...
at http://localhost:3000/__cypress/runner/cypress_runner.js:157481:26
From previous event:
at Context.exec (http://localhost:3000/__cypress/runner/cypress_runner.js:157454:105)
From Your Spec Code:
at Context.eval (http://localhost:3000/__cypress/tests?p=cypress/support/index.js:290:6)`

Desired behavior

Like in after the refresh the user should be able to get the npm run command on the first try rather than to refresh the runner.

Test code to reproduce

require("dotenv").config();
const url = process.env.DB_CONFIG;

// create a client to mongodb
const MongoClient = require("mongodb").MongoClient;

// make client connect to mongo service
MongoClient.connect(url, function(err, db) {
	if (err) throw err;
	console.log("Connected to Database!");
	// delete the database
	var dbo = db.db(`${process.env.PROJECT_KEY}`);
	// print database name
	console.log("db object points to the database : " + dbo.databaseName);
	dbo.dropDatabase(function(err, result) {
		console.log("Error : " + err);
		if (err) throw err;
		console.log("Operation Success ? " + result);
		// after all the operations with db, close it.
		db.close();
	});
}); 

Versions

Cypress package version: 6.5.0
Cypress binary version: 6.5.0
Electron version: 11.2.3
Bundled Node version: 12.18.3
CI not used

@jennifer-shehane
Copy link
Member

Duplicate of #6081

@jennifer-shehane jennifer-shehane marked this as a duplicate of #6081 Feb 19, 2021
@jennifer-shehane jennifer-shehane added the type: duplicate This issue or pull request already exists label Feb 19, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

1 participant