DEV Community

loading...

Discussion on: Test-Driven Development with Nodejs, Express, Mongoose & Jest

Collapse
thxv3n0lvl profile image
thxv3n0lvl

Hey first of all thanks for the series and effort you put writing this out for us.

Noticed a couple things by just skimming and trying almost directly the code (not a good practice though) but hope this can be improved in this section of your articles.

1- It is mentioned that at some point jest configuration will be validated with the test itself.. I've noticed it's never configured... if someone is just copying/pasting (like me)... the sample wont work as the test script is not using Jest... npm's package.json by default states

 "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
Enter fullscreen mode Exit fullscreen mode

I think as a minimum it should be edited to something like

"scripts": {
    "test": "jest"
Enter fullscreen mode Exit fullscreen mode

any other argument needed should be there.

2- I suggest to put commands like mkdir test && cd test and so on, as sometimes when this kind of details are just mixed with all the other text, it can be missed like I just did.
3- There are one or two typos, I recommend to check this out before posting the article to keep a higher quality.

Keep up the good work !

Collapse
eaetukudo profile image
Emmanuel Etukudo Author

Thank you once again for your feedback, I forgot to update the package.json to;

{
  "name": "tdd-with-nodejs",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "jest",
    "start": "nodemon index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "express": "^4.17.1",
    "jest": "^26.6.3",
    "mongoose": "^5.11.9"
  },
  "dependencies": {
    "body-parser": "^1.19.0",
    "dotenv": "^8.2.0",
    "nodemon": "^2.0.6"
  }
}
Enter fullscreen mode Exit fullscreen mode

The article has been updated accordingly.