Using npm script hooks
At this point, we could add a pre script to our existing build script in package.json, in order to execute our test suite before building the application using Parcel. With that in place, we'll not only be sure that our code compiles, but our confidence will be increased because our application will only be built if the whole test suite passes. Here's an example script that we could use: "prebuild": "npm run test".
This works because npm supports script hooks.
When npm finds a script with the same name as another, but with the pre prefix, then it executes that script before the other one. It is also possible to define a script that will be automatically executed after another one using the post prefix. You can learn ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access