I have a project that I am setting up through teamcity for CI.
The project itself is a nodejs application and it includes test written in mocha, which we cover through jscoverage. In the build configuration I'm setting up I have 3 build steps
which occur on checkin.
call jscoverage.exe against the folders in my project that I'm
covering.
call mocha to run the test against the jscovered files from step 1
and output to the html-cov reporter
move the generated coverage.html report into a public web directory
to browse later.
The build currently fails on step 2:
mocha" is not present in directory C:\NodeJS\MeasuresAPI
I've made sure to include mocha and all my node packages in the system environment paths and I am able to access them in the command prompt, but TeamCity doesnt appear to see them.
for the jscoverage.exe, I had to include the full path. With mocha, I tried including the path to my node global installation where mocha installed to but it gives me an error:
"..\node_modules\mocha\bin\mocha" (in directory "C:\NodeJS\MeasuresAPI"): CreateProcess error=193, %1 is not a valid Win32 application
Anyone had any experience with Teamcity and Mocha and how to get them to play nice?
or any ideas for continuous integration with a nodejs, mocha stack?
Yes , this happened to me too, when I was setting up TeamCity to run mocha on Windows Server. The solution was to call mocha by specifying path to the mocha.cmd bat file. For example , if you have folder C:\mocha and you have executed
npm install mocha
in that directory , than path to the bat file will be
C:\mocha\node_modules.bin\mocha.cmd
And you can tell Teamcity to execute mocha command by giving it next instruction :
C:\mocha\node_modules.bin\mocha --ui tdd --reporter html-cov test\measureDBTests.js > coverage.html
Related
I have the following directory structure for working with Cypress:
cypress-automation
cypress
fixtures
integration
apps
pulse
smhw-prod
smhw-qa
folder-a
sample-spec.js
examples
plugins
screenshots
support
videos
node_modules
cypress.json // this is where the file currently is
package-lock.json
package.json
Expectation
What I want to do is run all the tests inside the smhw-qa folder (there are a number of spec files in there) .. and be able to pass this using the --project command using CLI.
Currently if I just run `--run`` without any other arguments all the spec files, from all folders will start to run which is not desirable, since there are multiple applications "projects" (smhw-qa, smhw-prod etc) within this structure. This will allow me to only run the spec files from a single folder as desired.
I am also aware of using the --run command to "run" a specific folder, but I want to use "projects" instead to organise these tests so it's easier to identify them later.
I have had a look at the docs which show the use of the --project command however I need to help to understand what else I need to setup in order to make this work. By this, I am referring to the package.json file.
What I tried so far
I tried to follow the example provided for testing "nested folders" from here:
https://github.com/cypress-io/cypress-test-nested-projects
package.json: added the following script:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"smhw-qa": "cypress run --project ./cypress/integration/apps/smhw-qa"
},
When I run this via the terminal like so:
➜ cypress-automation npx cypress run --project ./cypress/integration/apps/smhw-qa
I get an error:
Can't run because no spec files were found.
We searched for any files inside of this folder:
/Users/jaswindersingh/Documents/cypress-automation/cypress/integration/apps/smhw-qa/cypress/integration
Am I missing something? Should my cypress.json file be located elsewhere?
I'd like to be able to set each of the folders inside "apps" to be projects, and then be able to run these projects using the cypress run --project command.
This will also make it easier to run specific folders of tests when I hookup our CI so that only specific projects (and their spec files) run when I choose.
I think you're looking for --spec path/to/folder/*.js
You can run all the tests in a folder, or even in all subfolders of a folder,
ex/ npx cypress run --spec cypress/integration/subsetA/**/*-spec.js
would run all .js specs in all folders under the "subsetA" folder in cypress/integration.
So in your case: npx cypress run --spec cypress/integration/apps/smhw-qa/**/*-spec.js should do the trick.
https://docs.cypress.io/guides/guides/command-line.html#How-to-run-commands
In my case I have angular workspace with multiple projects in it and I moved the cypress folder and cypress.json file in this sub project eg ./projects/app1.
Then add "integrationFolder": "e2e/cypress/integration", in the configuration file to specify tests directory.
Add these scripts to package.json
cypress open --project ./projects/app1
cypress run --project ./projects/app1
And only tests from e2e/cypress/integration directory are executed or opened.
I had a problem with running all tests files from one directory with
"cypress run --headed --no-exit --spec 'cypress/integration/sometests/*'"
Cypress was running only the first test file and stoppeded.
I've tried all combinations with *.js, *-spec.js etc and the problem was with the --no-exit flag. Removing --no-exit solved my problem.
Also, I've noticed that the path should be in quotes according to cypress docs https://docs.cypress.io/guides/guides/command-line#How-to-run-commands
Meteor application has built with 'meteor build' command and then deployed. After deployment application runs using plain node command 'node bundle/main.js'.
Running nyc using command 'nyc node main.js' only give the partial results from the meteor generate files.
Code coverage result
Is there anyway to get the full code coverage results? I am only interested to get result about javascript files.
I finished developing an application ,and I have a ready test.js files for the client side and for server side. The tests are in Mocha ,Chai and Sinon. I don't know how to connect the application files with the test files and how should I run them.
I appreciate any help/guidelines.
My suggestion is to have a tests folders in root directory(where your main js file is) and put test.js in there. Then just execute: mocha tests --recursive
This command will run all the tests.
I am trying to run my protractor test case in Bamboo CI but it throws an installation error.
I am able to install node modules using npm task but somehow I am not able to install and run protractor in my bamboo plan. Is there a different way of doing it or I am doing something wrong.
Please find attach the snapshot from my bamboo plan :
Npm install
Protractor Task
And my error log is as follow
/tmp/RDMPDEV-MAP-JOB1-91-ScriptBuildTask-6009702493071779000.sh: line 1: protractor: command not found
Please advice
You did not mention commands for protractor and web-driver installation. Do following:
Write below commands into Command* text filed under npm configurations section. Either put all commands separate by a comma or add one more configuration section if you could see any such option. or check in advanced options
Commands:
install -g protractor
webdriver-manager update
Write 'webdriver-manger start' as first line in script body and then write 'protractor conf.js'
You should mention all test spec in conf.js file and run conf.js file from script body.
Script body looks like:
1. webdriver-manager start
2. protractor conf.js
You can also trigger protractor tests in bamboo via angular cli command e2e.
Definition of e2e in package.json
"e2e": "ng e2e --no-serve --base-href"
Please refer below screenshot showing this configuration in bamboo.
Remember to add commandline parameter to e2e command in bamboo as required like --base-href
I am new to nodeJS and Jake but in my company they are using it to run unit tests.This is how they are running unit tests through ant
<exec executable="cmd" dir="${nodeJsTests.basedir}/../nodejs/">
<arg value="/C"/>
<arg value="start cmd /C "npm install & .\node_modules\.bin\jake local dir=${basedir} --trace & pause"" />
</exec>
From what I understood is they are doing the following things in this piece of code, do correct me if I am wrong
Going to nodejs driectory.
Installing jake at a particular location (.\node_modules.bin\jake)
Run unit tests
I want to achieve the same(run the tests), without using ant.I think I am able to do first two steps but stuck in the third step.I tried running command - Jake local from various directories but no success
If anyone can help me on this?
It's easier to see what's happening if you parse the string in the second arg value:
npm install & .\node_modules\.bin\jake local dir=${basedir} --trace & pause
This is a shorthand way of essentially running these 3 commands in order:
npm install
.\node_modules\.bin\jake local dir=${basedir} --trace
pause
The first command installs all the dependencies defined in your package.json file (which presumably includes jake).
The second command runs the local version of jake (the one that is installed inside the node_modules folder after running the previous step).
The third command is simply a cmd util to pause execution.
As long as you have installed the dependencies you should have no problem running jake without ANT (simply run the 2nd command above, replacing the ${basedir} value, and make sure you run it in the same directory that your package.json is located in).