Cypress command-line tool not honoring arguments - javascript

I'm not using npm, so I've downloaded Cypress directly. I'm able to open the Cypress binary directly from the command line, but I can't make it run tests from the command line. Running Cypress run just opens the UI. Cypress run --project /path/to/my/project does open the project in the UI, but doesn't run it. Bizarrely, Cypress version doesn't display the version, it just opens the UI. Even Cypress this-is-not-a-command opens the UI without any errors.

You should use the cypress NPM package to run Cypress from the command line. The binary itself is not designed to be executed for anything other than global open mode. The cypress NPM package contains a command-line utility that makes cypress run, cypress open, and cypress version work like you expect.
If you really really really don't want to use the CLI supplied with the cypress NPM package, you can reference how the CLI translates your command line arguments:
in open mode: https://github.com/cypress-io/cypress/blob/develop/cli/lib/exec/open.js
in run mode: https://github.com/cypress-io/cypress/blob/develop/cli/lib/exec/run.js
Note that these APIs are internal and may change at any time.
So, to do cypress run --project /path/to/project directly on the binary, it would look like this:
cypress-binary --run-project /path/to/project

Related

Different jest results when running via npm/package.json

Can anyone help me to understand that behaviour:
when I ran in terminal jest command: all my tests passed
I have also defined package.json script where I do exactly the same command jest and when i run npm run tests jest command is executed and all my tests passed.
BUT:
I run it on dockerimage. I have copy all project files to Docker, install all depend. and run tests.
npm run tests - failed
jest - passed
I am on the build docker image, in terminal run both commands. I see that they are giving different results. I know that it different OS. maybe different libraries, but npm, node and jest versions are identical.
Looks like running npm run tests behave differently. I'm stuck, don't know what to check, and how to debug it. Where the problem might be?

bash / zsh protractor: auto run protractor's CLI commands in --elementExplorer mode

how it possible to write a bash script that run Protractor and send some init commands to it, like :
"prx.sh"
protractor --elementExplorer
browser.get('http://www.angularjs.org');
look simple, but Protractor block the second command by it internal loop
we can do:
protractor --elementExplorer &
but then we need some way to send the next command to protractor SDIN
e.g
I know I can use :
protractor --baseUrl 'http://www.angularjs.org' --elementExplorer
to solve above example, but I'm interested in general how to run environement command for init some variables, so it will be more easy to play with them in the interactive mode
I thinks it is general qustions about bash\zsh

Protractor local and global installations behaving differently

This is a rough one. Two fellow developers and I have been working for nearly 24 hours on this. I have a conf.js that I can navigate to in Terminal and then run protractor conf.js (using the globally installed copy) and it runs perfectly. One at a time, each green dot appears after each successful test, and it takes about 80 seconds. Here's where it gets tricky.
If I force the local installation of Protractor to run by executing (path of project)/node_modules/protractor/bin/protractor conf.js then it fires up, shows me several green dots all at once, then throws an error about not being able to hook into angular. This is causing trouble with integrating with our build, since grunt looks for and uses the local copy of Protractor.
To further complicate matters, one of the two other developers can pull down my repo and run the local protractor installation on my conf.js no problem. It works 100%.
Error while waiting for Protractor to sync with the page: "window.angular is
undefined. This could be either because this is a non-angular page or because your
test involves client-side navigation, which can interfere with Protractor's
bootstrapping. See http://git.io/v4gXM for details"
We've checked all of the following:
Both local and global installations of Protractor are the same version, installed with npm.
Richards-MacBook-Pro:protractor richardpressler$ npm ls protractor
wear-test-web-framework#0.0.1
/path_to_project/wear-test-track0
└── protractor#3.1.1
Richards-MacBook-Pro:protractor richardpressler$ npm ls -g protractor
/usr/local/lib
└── protractor#3.1.1
Selenium is up-to date. We have run both (path to project)/node_modules/protractor/bin/webdriver-manager update as well as webdriver-manager update to update both local and global selenium server installations
I've tried firing up Selenium separately and then pointing Protractor to it so that I can see the output and it looks great when I run the conf.js using the global protractor (protractor conf.js), showing several [Executing] statements each followed by a [Done] statement. However, when I run the local protractor binary with (path to project)/node_modules/protractor/bin/protractor conf.js, I see that Protractor was able to connect to the Selenium instance, but didn't do much afterword:
When the protractor output looks like this:
Richards-MacBook-Pro:protractor richardpressler$ ../../node_modules/protractor/bin/protractor conf.js
Using the selenium server at http://127.0.0.1:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Started
.......................
The Selenium server only outputs this:
10:35:47.612 INFO - Selenium Server is up and running
10:35:49.479 INFO - Executing: [new session: Capabilities [{count=1, browserName=chrome}]])
10:35:49.487 INFO - Creating a new session for Capabilities [{count=1, browserName=chrome}]
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 34848
Only local connections are allowed.
10:35:50.516 INFO - Done: [new session: Capabilities [{count=1, browserName=chrome}]]
10:35:50.532 INFO - Executing: [set script timeout: 11000])
10:35:50.537 INFO - Done: [set script timeout: 11000]
Has anyone had similar misbehavior by Protractor when comparing the global, command-line version and the locally installed version in the project?
Thanks
Turns out all of the dependencies for protractor, grunt, selenium, etc. were in devDependencies so when I initially ran npm install it simply didn't install all of the sub-dependencies for those packages. If I move them into dependencies in the package.json, then re-run npm install, it works like a charm. Alternatively, running npm install --dev with those dependencies in devDependencies works fine too.
More info on the differences between dependencies, devDependencies, and peerDependencies can be found here: What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?

Automate Protractor / Selenium / Webdriver command

How can i start my localhost server with node app.js, run webdriver-manager start, and protractor conf.js in one command.
Each of these commands take place in a different folder.
I want to streamline this process.
I have a written an alias that executes each command in their respective folders.
Problem is, each of these commands launch a server, and the terminal enters non-canonical mode which causes an issue.
I have tried adding & to the end of each command, but this did not work.
Solve it via a task management tool like grunt or gulp.
Here is the list of plugins that might be useful in your case:
grunt-protractor-runner
grunt-contrib-connect
grunt-contrib-watch
See also:
Testing With AngularJS Part 5: Protractor and Grunt
Integrating Protractor with Yeoman via Grunt

Grunt grunt-contrib-jasmine

I have recently started to use grunt for JS project.
I have got a plugin called 'grunt-contrib-jasmine' that I'm using for Jasmine testing. I works great but I'm not able to run tests by specrunner in browser. Can I achieve this by using this plugin or do I need to install something else.
Also when a plugin is not required anymore, is it best to just comment it out or is there any command to uninstall, eg: npm uninstall grunt-contrib-jasmine --save-dev
Just for clarification, you can load the _SpecRunner.html file manually in the browser, but the grunt plugin will only run the tests in PhantomJS.
You can specify the keepRunner:true option in your gruntfile to keep the _SpecRunner.html file around after the tests run.
Then you can start a static web server (grunt-contrib-connect, and node-static both work fine for me) to the root of your project, and you should be able to manually open that _SpecRunner.html in a browser and run your tests there.
EDIT: I ended up giving Testem a try, which can launch your tests in PhantomJS and real browsers. It's still early, but I think I'll be setting aside grunt-contrib-jasmine in favor of Testem and grunt-contrib-testem.
grunt-contrib-jasmine is only for headless browser (phantomjs) so I afraid you will not be able to run this in browser. You will need to set up that manually.
In order to uninstall a plugin, use the command you mentioned:
It will remove the entry from package.json and it'll also uninstall the package too.

Categories

Resources