In Sublime 3, go to `tools > build system > new build system` and paste the below into the file:
{
"working_dir": "${project_path:${folder:${file_path}}}",
"cmd": ["npm", "test"]
}
Now you will have a build system that will run the NPM test command in your current project directory.