i want to print custom message with passed passed, Thanks in advance

  • which jasmine reporter package you are calling for reporting? – Vishal Aggarwal Jul 12 '18 at 1:09

Jasmine documentation explains how to create a custom reporter: https://jasmine.github.io/tutorials/custom_reporter

However, maybe there is already some that you can use (or modify) to fit your needs. See the following:




You may use Jasmine Custom Matchers

We can override the default messaging in the Jasmine reporter by defining the custom matcher in the global scope and overriding the default message variable as follows:

beforeEach(function () {
        toReport: function () {
            return {
                compare: function (actual, expected, msg) {
                    var result = {pass: actual == expected};
                    result.message = msg;
                    return result;

And it can be used in expect statements like below inside err function block:

expect(true).toReport(true, "Perform operation X succesfully because of " + customSuccessMessage); 

expect(false).toReport(true, "Unable to perform required operation because of " + err.message); 

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.