Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to log value in karma

Hi I’m trying to console log / console error from karma tests – but there is no any logs in terminal!

 it('should not delete card on deleteCard method if user cancels', async(() => {
    const eventMock = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
    const testCard = testCards[1];
    cardsServiceSpy.deleteCard.calls.reset();
    actionSheetDismissService.canDismiss.and.returnValue(Promise.resolve(false));
    console.log(testCard);
    component.deleteCard(eventMock, testCard).then((dataOnDelete) => {
      console.log(dataOnDelete);
      expect(dataOnDelete).toBe(testCard.id);
      expect(cardsServiceSpy.deleteCard).not.toHaveBeenCalled();
      expect(component.cards.length).toBe(3);
    });
  }));

What I’m missing???

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

module.exports = function (config) {
 config.set({
 basePath: '',
 frameworks: ['jasmine', '@angular-devkit/build-angular'],
 plugins: [
   require('karma-jasmine'),
   require('karma-chrome-launcher'),
   require('karma-jasmine-html-reporter'),
   require('karma-coverage'),
   require('@angular-devkit/build-angular/plugins/karma')
 ],
 client: {
   jasmine: {
    // you can add configuration options for Jasmine here
    // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
    // for example, you can disable the random execution with `random: false`
    // or set a specific seed with `seed: 4321`
   },
   clearContext: false, // leave Jasmine Spec Runner output visible in browser
   captureConsole: true,    
 },
  // ...........
  // ...........
});
};

Set captureConsole flag to true, in karma.conf.js file.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading