Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rproenza86/nodejs_intermediate_testing_and_code_quality
Explored how to gauge quality, implement testing, and measure code coverage in your Node.js apps.
https://github.com/rproenza86/nodejs_intermediate_testing_and_code_quality
chai chai-http eslint express-js mocha node-js nyc sinon
Last synced: 10 days ago
JSON representation
Explored how to gauge quality, implement testing, and measure code coverage in your Node.js apps.
- Host: GitHub
- URL: https://github.com/rproenza86/nodejs_intermediate_testing_and_code_quality
- Owner: rproenza86
- Created: 2019-07-22T13:02:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-22T13:03:34.000Z (over 5 years ago)
- Last Synced: 2024-11-06T03:48:26.980Z (about 2 months ago)
- Topics: chai, chai-http, eslint, express-js, mocha, node-js, nyc, sinon
- Language: CSS
- Size: 8.38 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-official.md
Awesome Lists containing this project
README
# Nadia’s Garden Restaurant
This is a Node.js and Express website that accepts and lists restaurant reservations. Improve it with the lynda.com course, "Node.js: Testing and Code Quality" by Jon Peck.
The backend contains intentional mistakes, like weak validation on email addresses. Inconsistencies in coding style are also intentional.
## Getting Started
```bash
npm install
npm start
```The server runs on port 3000.
There are three routes:
- http://localhost:3000/ - homepage
- http://localhost:3000/reservations - submit a reservation booking request
- http://localhost:3000/admin - view all booking requests; basic auth login/password `admin`The server persists using a SQLite3 database named `database.sqlite` in the site root.
## Development
This project uses EditorConfig to standardize text editor configuration.
Visit http://editorconfig.org for details.This project uses ESLint to detect suspicious code in JavaScript files.
Visit http://eslint.org for details.### Testing
This project uses Mocha and Chai for testing.
Visit http://mochajs.org and http://chaijs.com for details.To execute tests:
```bash
npm test
```Code coverage generated by http://istanbul.js.org
To calculate coverage:
```bash
npm run -s coverage
```### Debugging
This project uses https://www.npmjs.com/package/debug for development logging. To start `nodemon` and enable logging:
```bash
npm run debug
```## FAQ
- Q: Why didn't you store the time submitted?
- A: I wanted to reduce the number of fields and simplify testing.
- Q: Wouldn't it be easier if the form submitted a datetime string instead of building and parsing one?
- A: Yes, it would, but the form logic is simpler. Either way, someone has to do the work.
- Q: Why did you mix a callback and a Promise in `lib/reservations.js`?
- A: `Joi` doesn't support Promises, but it does support callbacks. I wanted to show how to test both kinds of asynchronous code.
- Q: How'd you handle cross-platform support?
- A: Avoided relative directories, used `cross-env` to transform environmental variables.## Credits
This is an adaptation of a WordPress site hosted at http://587672.youcanlearnit.net/
The conversion:
- Archive original with wget
- Strip out unrelated functionality
- Reorganize JavaScript and Stylesheets into logical directories
- Converted HTML into Jade / Pug templates using http://html2jade.org/The front end should be mostly unchanged from the original.