a simple mock api server...
- root
- api
- api/mock
- api/mock/auto
- api/mock/color
- api/mock/gt
- api/mock/slug
- api/mock/ssns
- api/mock/vins
- api/mock/uuid
yarn install
yarn dev
- uses nodemon, see below
➜ mock-api git:(master) yarn dev
yarn run v1.17.3
$ nodemon server
[nodemon] 1.19.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): *.*
[nodemon] starting `node server.js`
Magic happens here -- https://localhost:8180
mock apis -- https://localhost:8180/api/mock
sample api -- https://localhost:8180/api/mock/auto
--
if you prefer, you can run this in docker.
yarn build
- docker-compose buildyarn up
- docker-compose upyarn down
- docker-compose down
➜ mock-api git:(master) ✗ yarn up
yarn run v1.17.3
$ docker-compose up
Creating network "mock-api_default" with the default driver
Creating mock-api_web_1 ... done
Attaching to mock-api_web_1
web_1 | yarn run v1.15.2
web_1 | $ node server
web_1 | Magic happens here -- https://localhost:8180
web_1 | mock apis -- https://localhost:8180/api/mock
web_1 | sample api -- https://localhost:8180/api/mock/auto
web_1 | --
yarn test
- run tests, single passyarn ct
- run tests, continuouslyyarn coverage
- run coverage report
--------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
--------------|----------|----------|----------|----------|-------------------|
All files | 100 | 100 | 100 | 100 | |
api | 100 | 100 | 100 | 100 | |
utils.js | 100 | 100 | 100 | 100 | |
api/data | 100 | 100 | 100 | 100 | |
colors.js | 100 | 100 | 100 | 100 | |
gtSports.js | 100 | 100 | 100 | 100 | |
api/sample | 100 | 100 | 100 | 100 | |
mock.js | 100 | 100 | 100 | 100 | |
router.js | 100 | 100 | 100 | 100 | |
--------------|----------|----------|----------|----------|-------------------|
✨ Done in 1.44s.
- Chai - a BDD / TDD assertion library
- Chai-HTTP - HTTP integration testing with Chai assertions.
- Chance - a minimalist generator of random stuff
- Docker Desktop for OSX
- Docker Desktop for Windows
- Istanbul - JavaScript test coverage made simple
- Mocha - a JavaScript test framework
- nodemon - reload, automatically
- nyc - the Istanbul command line interface
- Sinon - test spies, stubs and mocks
- vin-generator
- Richard Hess
- https://eswat2.github.io