Example web application with MySQL database to verify the user phone number
This example was used in the following blog posts
- How To Verify Phone Number During Tests Part 1 shows how to use a test phone prefix
- How To Verify Phone Number During Tests Part 2 shows how to query MySQL database from the test
$ npm install
# should install the web application dependencies
# then switch to the "api" folder and install its dependencies
# if this does not happen, run yourself:
$ cd api
$ npm install
Note that the api folder has its own package.json file with its own dependencies, including the mysql
module that allows Cypress here to connect and query the MySQL database.
You can start the API and the web application using two terminals:
# starts the web application
$ npm run dev
# from another terminal start the API
$ npm run dev:api
Note: to connect to the database, the API requires certain environment variable or .env
file, see the API README.
Then from the third terminal open Cypress
$ npm run cy:open
Alternatively, you can start the application, the api, and open Cypress using a single command that uses start-server-and-test utility.
$ npm run cy
If everything starts correctly, you should see Cypress Desktop GUI window.
Find the end-to-end tests in the folder cypress/integration. Read the blog posts linked above for details.
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2021
License: MIT - do anything with the code, but don't blame me if it does not work.
Support: if you find any problems with this module, email / tweet / open issue on Github
Copyright (c) 2021 Gleb Bahmutov <gleb.bahmutov@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.