Git Pre-Commit with Newman Testing

Is there a way that I can trigger Newman to run prior git commit thus if collection runner test failed, git will not commit? Thank you very much.

Would some one help me please? Thank you very much.

I know this thing exists?

I remember a dev talking about an NPM module that ran his unit tests before every commit and if the tests failed, the commit wouldn’t merge.

I assume this is the NPM module he was talking about.
Again, I assume you can just give it another command to run prior to your commit. So you could effectively run your API tests via Newman prior to a commit.

Thank you sir very much for your help. With pre-commit, when I run git commit, it does run newman test as I expected. However in my newman I have 8 failed but git commit does not know about the newman test failures and complete git commit. Below is my nodejs code for newman test:


/* eslint-disable func-names */
‘use strict’;

const newman = require(‘newman’);
collection: require(’…/postman/1.0.1/req_collection.json’),
environment: require(’…/postman/1.0.1/dev_environment.json’),
globals: require(’…/postman/1.0.1/global-variables.json’),
reporters: ‘cli’
function (err) {
if (err) {
console.log(‘Postman Collection Run Error’, err);

console.log('Postman collection test complete!');