lathonez / clicker

Ionic 2 + @angular/cli Seed Project : Angular2 + Typescript + Karma + Protractor + Travis
http://lathonez.com/2018/ionic-2-unit-testing/
MIT License
430 stars 137 forks source link

Ionic2 unit testing & Code Coverage - facing issues with services calls from controller functions #214

Closed Asiq closed 7 years ago

Asiq commented 7 years ago

Hi, I am facing the issues in cover coverage for service calls . the problem is by calling the service functions from controllers functions.( any thing) for example:

public register() { // this.submitAttempt = true; this._message = ""; this.sharedService.SetSettings(this.configSettings.value).then(() => {

  this._showMessage = true;
  this._message = "Successfully Saved !";
  setTimeout(() => {
    this._showMessage = false;
  }, this._TOAST_MESSAGE_TIMEOUT);
}, (error) => {
  this._message = "An error occured.";
  setTimeout(() => {
    this._showMessage = false;
  }, this._TOAST_MESSAGE_TIMEOUT);
});

Here register is the functions which we called from view(html) a button click and then we called the service of SetSettings().

In Code Coverage it is not passing from then (() => line to cover..

Could you please guide me on this to make it work.

lathonez commented 7 years ago

Hi,

Firstly, I don't understand your question at all. Secondly, I don't write or maintain the code coverage tool.

Please direct your question to:

IMO this is best directed at Stack Overflow (from what I can understand of the question).