Skip to content

Instantly share code, notes, and snippets.

@farhad-taran
Created April 26, 2021 13:54
Show Gist options
  • Save farhad-taran/3b12b11f51a2c9cf35658a4c1cfbaf69 to your computer and use it in GitHub Desktop.
Save farhad-taran/3b12b11f51a2c9cf35658a4c1cfbaf69 to your computer and use it in GitHub Desktop.
Testing a single file in NPM

sometimes we only want to test a single file or debug it selectively and running the whole test suit can be very time consuming in these scenarios. the following script can be added to the package.json of an application and ease this process:

"test-file": "read -p 'input test file: ' name && npm test -- $name"

the above script will ask for the filename to be input and then it will pass it on to the appropriate test runner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment