I am trying to run test cases and deploy React-js app with Jenkins.
I am able run react-js app locally after git push command, but after that second command mocha (command to run test cases) is never executed.
I want to deploy react-app to production if all test cases passes.
Below is my simple build script
cd naviaget/to/package.json/file
npm start
mocha
Any help is appreciated.
Well if npm start is starting the development server, you shouldn't call it before running the scripts, because the server won't finish execution until it's closed. That's the reason mocha is never executed.
Normally in CI you first run your tests, and then if everything goes fine you deploy, run a server, whatever. These are normally two different steps: integration (running your test) and deployment (spinning up your server).
I'm not familiar with Jenkins but I'm pretty sure it should be easy to set it up like that:
Run the tests with mocha
If everything is fine, re-reploy
Related
I have been trying to set up server-side testing for my application but have run into an issue with bamboo recognizing more than one test type. In the past, it worked just fine using only karma as the unit test, but I need to add server-side testing which works much better with jest.
The main problem I am running into is that when both are run as shown below the coverage report is only created for the karma(unit) tests.
test-unit=npm run test:unit && npm run test:server
I have also tried running jest under bamboos test-e2e and test-contract-test but when I do this nothing is reported. So is there a way to set up server-side testing separately in the .bamboorc file
So, I found an answer!
In the .bamboorc file move the test-unit = npm run test:unit to the end of the file and for the first test use
test-contract-consumer=npm run test:server -- --collect-coverage
This should then collect the coverage for the server tests in bamboo under the contract tests consumer artifacts, and the karma unit test should still show up under the unit test coverage artifacts.
My projects uses a /server folder for my backend code and /react-ui for my client side code. There's a package.json in each folder. I can run test separately in the cmd line, but I would like to run both at the same time. I know about the multi projects feature of jest, but it doesn't seem to work with create-react-app. I'm trying to setup jest with babel as if I was not using create-react-app, but it seems like the wrong approach considering jest is already setup in CRA.
My current setup runs from the /server jest installation. With projects: ['<rootDir>', '<rootDir>/../react-ui']. The jest documentation isn't clear how I could direct it to run npm test in /react-ui
My only goal is to be able to watch both at the same time and I would like to not eject from CRA.
You can have (gulp) scripts on the main level that run each tests separately, but using same configs.
I've made a GitLab CE and Jenkins integration in a local server. I would like to know how I can integrate Jenkins with Jest for generate reports or logs about the test results. If any of the tests failed, Jenkins should not continue and should notify me. I've already integrated Slack for the notifications and placed some commands in Jenkins like: npm install, npm run test, but still Jenkins doesn’t know if there’s tests or not.
Jenkins configuration:
The flow should be the following:
I make a change in the master repository
Gitlab runs the webhook that invokes Jenkins
Jenkins brings the new changes, build and run tests
If some of the tests failed should send a Slack notification otherwise, should create a docker image
Any suggestion or correction is welcome
I have an extensive MochaJS test suite for my ExpressJS / NodeJS API. The test suite includes creation of objects and removal of those same objects from the database.
Currently, all of my regression tests are passing in my development environment. We'd like to be able to run the same test on the staging environment that has data objects that were migrated and not created after the new code was deployed.
How do we run our mocha tests from the server?
Currently, I use the following command to run my tests, locally:
foreman run node node_modules/mocha/bin/mocha
Thanks in advance for any help!
You can probably leverage the package.json scripts:
https://docs.npmjs.com/misc/scripts
If heroku uses a simple npm install to install your package, you can define a prepublish script which runs mocha. It's as simple as defining this in your package.json:
"scripts": {
"prepublish": "mocha"
}
Don't worry about mocha not being installed globally, npm install will add the node_modules/.bin folder to the PATH environment variable during installation.
Our team decided to go the route of using continuous integration as the mechanism for running server side tests. Two birds with one stone!
We're using CircleCI to make that happen.
We're now passing the supertest library the app module rather than a URL. This allows the endpoints to be called at the HTTP layer by supertest.
Hope this helps anyone else looking at similar alternatives!
How can I run AngularJS end to end tests on Jenkins? As far as I understand, e2e tests require a web server.
I can run e2e tests locally with karma while node.js web server script is running.
Would also say, get grunt running inside jenkins using https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
it's awesome