2

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
0

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:

jasmine-reporters

jasmine-console-reporter

0

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 () {
    jasmine.addMatchers({
        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 agree to our terms of service, privacy policy and cookie policy

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