Although the PublishTestResults task mentions JUnit, you must ensure that karma is producing JUnit reports. The excerpt from karma.conf.js you provided is insufficient to validate this.
install karma-junit-reporter npm package
npm install karma-junit-reporter --save-dev
add karma-junit-reporter in karma.conf.js plugins array
add junit in karma.conf.js reporters array
reporters: ['progress', 'kjhtml', 'junit'],
Then make sure the PublishTestResults task has the correct pattern. Mine looks like this because I don't specify any junitReporter settings, which you show in your example.
If you are interested in learning DevOps from scratch then checkout Edureka's DevOps Training Course.