onsenui fails unit test

Asked 1 years ago, Updated 1 years ago, 71 views

I am creating a hybrid app using onsenui.

I'd like to do a unit test using Karma and jasmin.
The following error occurs when running the test:

Error: isWebView() method is available after dom contents loaded.

Onsenui is DI with angularJS.

var appModule=angular.module('app', ['onsen']);

If you know how to avoid it, please let me know.

onsen-ui jasmine

2022-09-30 15:36

1 Answers

Spy ons.isWebView() to always return true.

describe('Test OnsenUI', function(){
  beforeEach(function(){
    spyOn(ons, 'isWebView').and.returnValue(true);
  });
  it('test sample', function(){
    // write a test here
  });
});


2022-09-30 15:36

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.