Right way to do End to End tests with Jenkins - javascript

I have an app using PHP and ReactJS for the frontend. I have unit tests for the PHP project and e2e for the frontend project. I deploy my project using Jenkins and Docker for the app.
When a developer push on a branch, I'd like to run the tests (unit, e2e) in the CI. If everything is OK, we can deploy the project. I'd like to know the right way to do that ?
Today I am doing these steps :
one dev pushes the code, the job "test-app" is triggered in jenkins
the job build the docker image in a "dev" environment, with the dev dependencies in PHP
the app is started, let's say the url is "tests-app.com"
the tests are executed (unit, e2e using Selenium and tests-app.com)
the tests are OK, a job "app-deploy" is triggered and "tests-app.com" is shut down
the job app-deploy build the docker image in a "prod" environment, without the dev dependencies in PHP
the app is started the url is now "app.com"
Is that the right way to do that ? From the push by the developer and the end of the Jenkins builds it can take 5-10 minutes.

Related

nuxt.js - build ssr with missing pages

I have a problem with nuxt build with ssr and missing pages on my website. Due to our deployment process, the same steps are executed on different instances, resulting in unexplained errors. The instances are built identically and the same code is being pulled before the build is started. However, in some cases, there are different builds.
instance1 - server section
instance2 - server section
it seems as if the pages don't exist at all, which is why the users of the page only get an error page. The server-built pages are missing, although they seem to be available for the client.
instance1 - client section
By repeating the deployment process only for the "broken" instance, a correct result can be achieved. I am using Node v14.17.0, Yarn v1.22.4, Webpack v4.46.0, Nuxt v2.15.4 and have not found anything causing similar problems. and I have no idea where to start.
ps. the same procedure works in my development environment and for our staging server. the structure of the staging and production server are identical, also the same packages are used.
deployment steps:
connect to server
checkout master, git pull
stop service with current yarn start
run yarn install (package.json could be updated from git pull)
run yarn build
start service where yarn start will be executed

How do I open a terminal tab with an NPM script?

I would like to automate the testing sequence of my Cordova app.
I know I can run nom scripts in sequence by specifying a script name, and then specifying a series of scripts separated by semicolons. This is working perfectly for other parts of my dev environment.
For the UI tests, I'm using Webdriver and Appium. This is the series of scripts I would like to automate, but I can't seem to find out what the commands are to get the specific sequence running (specifically regarding the Appium server):
1) Run jest unit tests (this is not a problem)
2) If jest tests do not fail, start the Appium server in a new terminal tab
3) Either wait for a successful signal (not sure what this would be) that the Appium server has started or set a reasonable timeout
4) Run the UI tests with WebDriver/Mocha (this is also not a problem running by itself).
5) Kill the Appium server
Part 3 is my hurdle, specifically how to get the Appium started in a separate terminal tab. Chaining these together would be great.
The goal here is to automate the entire testing series in something like npm run allTheTests so I can leave and get a sandwich, send a text, read a Medium article (etc.) while the tests complete.
Many thanks =)

Deploy a standalone node.js server from WebStorm express project

Total rookie question, however in my hours searching have not found a proper solution:
I have made a Node.js/express server using WebStorm IDE, tested it and run it successfully, however now that it is complete, I would like to be able to run it manually as a standalone project.
I have tried just running the www js file, which does start the server, however some functionality is lost, such as being unable to find and run a python script (not found).
My question is how do I fully transfer all the functionality incorporated in the WebStorm project so that server can be run outside of the IDE?
ADD: Currently only python scripts in the /bin directory will be found (server terminal run location)

Difficulty in deploying Node.JS + Grunt based web application from terminal

I have a website which is developed based on Node.JS and uses grunt to be run.
I want to deploy it on my aws server. So, i installed node.js and all its dependencies and modules, configured database etc, and i am able to run it from terminal.
First i used
grunt build
and then
grunt
and website is running and up without any problem.
My question is that how should i deploy these kind of websites, so it always is running and listening to the port? That is because whenever i close the terminal (Putty), it will stop working.
I tried using these commands to run it in the background but didn't work :
grunt &
alnd also
(grunt &)
but whenever i exit the terminal (putty) , web server stops working.
Can anybody please help me with that? How can i make grunt running even after closing the terminal?
And how node js + grunt websites will be deployed on the server in general?

How to execute server and client tests in one command/process?

as I'm developing a web application using AngularJS in the front-end and Node.js in the server. For now I'm writing tests for the node server (based on Express) using Mocha (+ Chai + Supertest), and client side tests using Mocha and Testacular as a test runner, since Testacular is the tool of choice with Angular.
Note that the Angular app is "embedded" in the node app, as it's located in the template files.
My testing process : for server tests, I just npm test, i.e. mocha <my-test-folder> <my-test-options> ; for client tests, I launch a Testacular server that watches changes in the desired files. But I don't like this parallel and disconnected process and I'm sure there's a better, unified automated way.
Could help me refine the process ?
In my travels I haven't seen a precident for this, but you should be able to achieve it using grunt. You can make a grunt target that calls both.
I have a github project that should help show how to use testacular on an angular project using grunt which will at least help with the client part; will help get you part of the way there.

Categories

Resources