CircleCI : $ npm test failing - node.js

I'm trying to use CircleCI for one of my node.js application. I'm trying to learn the way circleci works.
My app and test cases are running fine locally. I'm using jasmine-node for test.
But when I'm trying to build my app on circleci I'm getting below error. Below is a screenshot from circleci:
Please let me know anyone has any idea on this!

CircleCi is saying that jasmine-node isn't installed.
Add the following code to your circle.yml file.
dependencies:
post:
- sudo npm install jasmine-node -g

Related

Rim raf / jenkins- syntaxError : Unexepected token . in ignore-enonent.js

Hi on Monday all of our jenkins builds started failing on npm install on the rim raf ignore.enonent.js file
I can see that rim raf did publish a new version 7days ago but the ignore-enonent.js file has always been like this.
Anyone else seeing this issue?
`Server\DPAWebUI\Verint.DPA.FrontEnd\node_modules\rimraf\dist\cjs\src\ignore-enoent.js:15
if (er?.code !== 'ENOENT') {
^
SyntaxError: Unexpected token .'`
Note this issue only started after the weekend. I tried running npm install without jenkins and no issues. The issue only seems to occur when run from jenkins
I got this too - only in jenkins as well :D
Found in the end that it was related to the recent rimraf release 4.1.2 https://www.npmjs.com/package/rimraf?activeTab=versions.
I have grunt (v3) defined in my package json so local build works fine. But in Jenkins i have a pipeline script which was explicitly installing the latest version of grunt, which then brought in this incompatible dependency and broke stuff...
So in your Jenkins pipeline make sure you are not installing grunt (or whatever is using rimraf - check using npm ls rimraf) and make sure the version of rimraf/parent of rimraf is the same on Jenkins. Can add npm ls rimraf in your Jenkins pipeline script as a debug line to figure out if its using a different version.

Exercism exercise: jasmine-node . - command not found

I'm trying to run the first exercise in Exercism. I have followed the readme instructions and installed Homebrew, and then installed the CLI. Everything went fine.
I then typed in the command line to download the first test - Hello World. Again, this worked fine.
The next instruction was
Execute the tests with:
jasmine-node .
I assume this is to be typed into Terminal? This is what I've tried and it says 'command not found'. There is no other instructions. I've never even come across Jasmine before. I downloaded jasmine-node separately via npm,
npm install jasmine-node -g
...but this has still made no difference.
Can anyone suggest where I am going wrong? Thanks.
I think you are looking for this link
http://exercism.io/languages/javascript/installing
It details all the dependencies you need to install
the command that did it for me was
npm install jasmine-node -g

How to run Jest tests on Jenkins Server

I'm attempting to run my Jest Test during Jenkins deployment. If I ssh into the server, I can sudo into the Jenkins user and successfully run the tests from the workspace. However, I get an error when I attempt to build the project from the GUI. Here is my project setup:
I have installed the nodejs plugin, which in turn installs gulp, jest-cli and babel globally.
Then in build steps:
The test fails with this error:
TypeError: Cannot read property 'getResourceByPath' of null
at Loader.getDependenciesFromPath (/var/lib/jenkins/workspace/PHPStaging/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:570:39)
at /var/lib/jenkins/workspace/PHPStaging/node_modules/jest-cli/src/TestRunner.js:250:22
at process._tickCallback (node.js:368:9)
Running 6 test suites...
FAIL resources/__tests__/myTest.js
It appears that Node is having trouble requiring modules from the tests, but I'm not totally sure. Any help or direction would be appreciated.

Continuous integration and deployment of Node.js application on Bamboo

The application I want to implement continuous deployment on Bamboo has node modules and bower component dependencies. On the bamboo server nodejs, npm have been installed.
There are only three tasks on default job:
Source Code Checkout
Build dependencies:
npm install
bower install
Deploy to the staging server
The problem is on the second task, bamboo fails with the message "No failed tests found, a possible compilation error occurred." I don't even run any tests.
The log file is not explanatory at all:
Starting task 'Build dependencies' of type 'com.atlassian.bamboo.plugins.scripttask:task.builder.script'
Failing task since return code of [/bin/sh /home/ubuntu/bamboo-installation/temp/WEB-WEB-JOB1-8-ScriptBuildTask-4430338079602360707.sh] was 1 while expected 0
Ok, I solved the problem. The issue was the wrong node (which obviously messed things up) was installed on the bamboo server. Uninstalled the wrong one and everything worked as expected.
Good to see you solved it.
There is a setup I use and which could prevent further problems with CI:
export npm_config_prefix=.npm/
export PATH=.npm/bin:$PATH
export CI=true
npm install -g bower
bower install
npm install
This installs bower (and others like grunt-cli if you want) in your project folder so you can e.g. have a specific version, sets CI=true as advised in bower docs, and then installs all dependencies.
Bamboo AMI originally have npm version 1.4.28 installed and you are probably using a more recent version on you development environment. I had the same issue and resolved it by creating a script task to update npm version on the very beginning of my build process. Here is the script:
# update npm
curl -O -L https://npmjs.org/install.sh
chmod +x install.sh
sudo PATH=$PATH:/opt/node-0.10/bin ./install.sh

NodeJS/Testacular on Jenkins CI

I'm using Testacular which is a Node.js test runner for Angular/Jasmine. I can run it fine from the command line, but every time I try to run it from Jenkins build steps, it bombs out with all sorts of errors regarding environment variables. I tried the Nodejs plugin for Jenkins, but that's just to run node code snippets. Anyone know of a way to have node apps (eg. Testacular) running test under Jenkins?
You will need to:
have "testacular" as a dependency in your package.json file.
install your dependencies with npm install (do this as a build step)
call it as ./node_modules/.bin/testacular start --single-run
Assuming you have configured testacular to use PhantomJs browsers = ['PhantomJS'];, you just need to have the phantomjs binary in your path or tell testacular where it is located with an environment variable set in your shell:
export PHANTOMJS_BIN=$HOME/local/bin/phantomjs
good news!
" I tried the Nodejs plugin for Jenkins, but that's just to run node code snippets. "
nope!
install the nodejs plugin see instructions here -> NodeJS jenkins plugin broken?
then tick "Provide Node/npm bin folder to PATH" and when running a "execute shell" build task, you can use nodejs, here's a example using grui
npm update
grunt
grunt --force reporting

Resources