karma-ng-html2js-preprocessor icon indicating copy to clipboard operation
karma-ng-html2js-preprocessor copied to clipboard

Issue with angular 2 RC6

Open combmag-zz opened this issue 8 years ago • 4 comments

HI i have the following issue after i upgraded to rc6

previously the configuration was like the one below:

// karma-test-shim.js
...
System.import('angular2/testing').then(function(testing) {
  return System.import('angular2/platform/testing/browser').then(function(providers) {
    testing.setBaseTestProviders(
      providers.TEST_BROWSER_PLATFORM_PROVIDERS,
      [providers.TEST_BROWSER_APPLICATION_PROVIDERS, providers.CACHED_TEMPLATE_PROVIDER]);
  });
}).then(function() {
...

now when i upgraded to rc6 and changed to:

import { TestBed } from "@angular/core/testing";
import {
    BrowserDynamicTestingModule,
    platformBrowserDynamicTesting
} from "@angular/platform-browser-dynamic/testing";
import {
    RESOURCE_CACHE_PROVIDER
} from "@angular/platform-browser-dynamic";
`
TestBed.initTestEnvironment(
    BrowserDynamicTestingModule,
    platformBrowserDynamicTesting(RESOURCE_CACHE_PROVIDER)
);

i got an error that the html is not found and when i tried to debug it seems taht resource cache provider is never called..

am i missing something?

combmag-zz avatar Sep 10 '16 09:09 combmag-zz

They've broken so many things with this RC6 (and 2.0.0) it's a real nightmare! I'am still not able to run my unit tests... my karma conf is broken...

jcamus avatar Oct 05 '16 16:10 jcamus

@combmag i know....it is really old issue....but have you found a solution how to configure RESOURCE_CACHE_PROVIDER on init phase? Thanks

meriturva avatar Jun 14 '17 10:06 meriturva

@meriturva afaik RESOURCE_CACHE_PROVIDER should be provided to TestBed.configureCompiler and not to initTestEnvironment that's what fixed the issue.

combmag-zz avatar Jun 20 '17 11:06 combmag-zz

Anyway i have developed a simple karma pre-processor to fix template and avoid RESOURCE_CACHE_PROVIDER (so no change needed on our tests)

see: https://stackoverflow.com/questions/44539485/angular2-tests-and-resource-cache-provider-global

so thanks @combmag

meriturva avatar Jun 20 '17 12:06 meriturva