Skip to content

Instantly share code, notes, and snippets.

@gerardolima
Created December 14, 2020 10:43
Show Gist options
  • Select an option

  • Save gerardolima/d627240793d7394d010030e356996f72 to your computer and use it in GitHub Desktop.

Select an option

Save gerardolima/d627240793d7394d010030e356996f72 to your computer and use it in GitHub Desktop.
npm scripts for TDD

The following npm scripts lint:tdd and test:tdd run the tests and lint for files that are new of differ from their correspondent on the branch develop. These rely on the git utility and uses command line tools usually found on *UX systems.

{
  "scripts": {
    "lint:tdd": "NODE_PATH=./src nodemon --exec 'git diff develop --diff-filter=d --name-only | grep \"ts$\" | tr \"\\n\" \" \" | xargs eslint --ext .ts --fix'",
    "test:tdd": "NODE_PATH=./src nodemon --exec 'git diff develop --diff-filter=d --name-only | grep \"ts$\" | tr \"\\n\" \" \" | xargs lab --sourcemaps'",
  },
  "devDependencies": {
    "@hapi/lab": "^22.0.5",
    "eslint": "^7.5.0",
    "nodemon": "^2.0.4"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment