I wrote this test app to help me write and practice cypress tests.All cypress.io tests are in cypress/integration/organic-app-tests folder.
This NodeJs-Express app uses the
following dependencies:
- bcrypt: to hash passwords and never store clear text passwords in databae
- chance: to generate random integers and strings while testing
- ejs: Ejs template engine to render views to the user
- passport: To handle Authentication and authorization
- rethinkdbdash: Handles connections to and from RethinkDb database
- socket.io: Takes care of asyncroneous communications sent by changefeeds from RethinkDb ( Admin page )
- Download and Install RethinkDb from here
- Create a shortcut wherever you like to point to RethinkDB executable with the following path value and arguments: C:\RethinkDB\rethinkdb.exe -d c:\RethinkDB\data\ --bind all
- Click on the shortcut to start RethinkDB Server
- Clone this app to a folder of your choice: git clone https://github.com/jinan-kordab/nodejs-rethinkdb-app.git
- cd organicapp
- npm install>
- cd organicapp/bin (Inside bin folder you will find two files: 1- create-data.js 2- delete-data.js)
- node create-data.js (this will populate your RethinkDB instance with test data. The other file, deletes all test data that was added via file accordingly)
- cd ..
- npm start (this will start the appp)
- navigate to http://localhost:3000 , you should see the landing page:
- now open another terminal (bash or powershell
- cd organicapp
- npx cypress open (this will start cypress, and you can write and run cypress tests)
My choice for back end settled for RethinkDb, because of its feature called "changefeeds" which sends notifications via sockt.io to the client once any change happens within its tables. The cypress test for socket.io and changefeeds is in cypress folder "admin.spec.js"
I wrote more about this app on my blog here: my blog post including discussion on unit and integration QA testing in Cypress