English 中文(简体)
Jasmine - how to test HttpLoaderFactory from @ngx-translate
原标题:Jasmine - how to test HttpLoaderFactory from @ngx-translate
问题回答

We can create a separate describe block, which is just plain jasmine unit testing for this function, to cover this function, we can use the below code.

首先,我们进口整个包件<代码>@ngx-translate/http-loader,作为translateA,然后我们使用<代码>spyOnProperty到间谍 在<代码>TranslateHttpLoader上,最后,如果我们发出呼吁,那就足以涵盖这一法典!

import * as translateApi from  @ngx-translate/http-loader ;
...

...
describe( should cover HttpLoaderFactory , () => {
  it( should initialize TranslateHttpLoader with params , () => {
    const spy = spyOnProperty<any>(
      translateApi,
       TranslateHttpLoader 
    ).and.callThrough();
    HttpLoaderFactory({} as any);
    expect(spy).toHaveBeenCalled();
  });
});

>>>>>>>>>>>>>>>> Stackblitz Demo





相关问题
State based testing(state charts) & transition sequences

I am really stuck with some state based testing concepts... I am trying to calculate some checking sequences that will cover all transitions from each state and i have the answers but i dont ...

Running genhtml using cygwin Perl.exe in Windows

I m trying to run genhtml using perl.exe from Cygwin in Windows. I have installed cygwin and placed genhtml in the bin directory of cygwin. I went to that directory and used the command line in ...

Highlight text from Visual Studio 2008 add-in

I m writing another code coverage tool for .NET with Visual Studio 2008 integration. Everything goes well except one thing: I can t find a way to highlight some code chunks. I need it to inform user ...

Cobertura ant script is missing Log4J classes

I tried to get Cobertura running inside my ant script, but I m stuck right at the beginning. When I try to insert the cobertura taskdef I m missing the Log4J libraries. Ant properties & ...

How to omit using python coverage lib?

I would like to omit some module that are in some particular directory : eggs and bin coverage -r -i --omit=/usr/lib/,/usr/share/,eggs,bin Name ...

Code coverage with nUnit? [closed]

Is there a way to see the code coverage when using nUnit? I know there s such a feature in Visual Studio, but can you use it with nUnit or only with the built-in vs unit tests?

run unit tests and coverage in certain python structure

I have some funny noob problem. I try to run unit tests from commandline: H:PROpyEstimator>python src estpython est_power_estimator.py Traceback (most recent call last): File "src est...

热门标签