Skip to content

Instantly share code, notes, and snippets.

@saconnolly
saconnolly / NgUpgradeUnitTestingComponents.md
Last active May 28, 2020 14:51
NgUpgrade unit tests for components

Unit tests for services

Upgrading the services themselves has been a very straightforward experience using ngUpgrade. The issue that arose was when we had angularJs services that were injecting services that we had converted to Angular. Pete Bacon Darwin’s PR got me going in the right direction and after a few discussions with him (he was extremely helpful), this is where I landed (since I originally did this work, Pete's MR has been merged and can be seen here: https://angular.io/api/upgrade/static/testing/createAngularJSTestingModule):

const { angular } = window as any;  
const $INJECTOR = '$injector';  
const INJECTOR_KEY = '$$angularInjector';
export class TestHelpers {  
private static createAngularJSTestingModule(angularModules: any[]) {