From ba5b3af0771bd82a86c1365d96cc3b2e645cb7d0 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Thu, 20 Jun 2019 12:50:54 -0700 Subject: [PATCH] build(bazel): update //packages/bazel/test/ngc-wrapped:ngc_test test (#31325) after update to rules_nodejs 0.32.1, @types are no longer automatically discovered by ngc-wrapped (which uses parts of ts_library) so this test needed updating so that the types files it generates is added as an explicit dep PR Close #31325 --- packages/bazel/test/ngc-wrapped/index_test.ts | 14 +++++++------- packages/bazel/test/ngc-wrapped/test_support.ts | 8 +++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/bazel/test/ngc-wrapped/index_test.ts b/packages/bazel/test/ngc-wrapped/index_test.ts index 8c094890c0..5c22cc2d7b 100644 --- a/packages/bazel/test/ngc-wrapped/index_test.ts +++ b/packages/bazel/test/ngc-wrapped/index_test.ts @@ -13,7 +13,7 @@ import {setup} from './test_support'; describe('ngc_wrapped', () => { it('should work', () => { - const {read, write, runOneBuild, writeConfig, shouldExist, basePath} = setup(); + const {read, write, runOneBuild, writeConfig, shouldExist, basePath, typesRoots} = setup(); write('some_project/index.ts', ` import {Component} from '@angular/core'; @@ -21,12 +21,7 @@ describe('ngc_wrapped', () => { console.log('works: ', Component); `); - const tsconfig = writeConfig({ - srcTargetPath: 'some_project', - }); - const typesFile = path.resolve( - tsconfig.compilerOptions.rootDir, tsconfig.compilerOptions.typeRoots[0], 'thing', - 'index.d.ts'); + const typesFile = path.resolve(basePath, typesRoots, 'thing', 'index.d.ts'); write(typesFile, ` declare module "ambient_module" { @@ -34,6 +29,11 @@ describe('ngc_wrapped', () => { } `); + writeConfig({ + srcTargetPath: 'some_project', + depPaths: [path.dirname(typesFile)], + }); + // expect no error expect(runOneBuild()).toBe(true); diff --git a/packages/bazel/test/ngc-wrapped/test_support.ts b/packages/bazel/test/ngc-wrapped/test_support.ts index 2b532f594d..9f0dc054a8 100644 --- a/packages/bazel/test/ngc-wrapped/test_support.ts +++ b/packages/bazel/test/ngc-wrapped/test_support.ts @@ -17,6 +17,7 @@ export interface TestSupport { basePath: string; runfilesPath: string; angularCorePath: string; + typesRoots: string; writeConfig({ srcTargetPath, depPaths, pathMapping, }: { @@ -49,17 +50,22 @@ export function setup( const angularCorePath = path.dirname(require.resolve('angular/packages/core')); const tsConfigJsonPath = path.resolve(basePath, tsconfig); + const emptyTsConfig = ts.readConfigFile( + require.resolve('angular/packages/bazel/test/ngc-wrapped/empty/empty_tsconfig.json'), read); + const typesRoots = (emptyTsConfig as any).config.compilerOptions.typeRoots[0]; + return { basePath, runfilesPath, angularCorePath, + typesRoots, write, read, writeFiles, writeConfig, shouldExist, shouldNotExist, - runOneBuild: runOneBuildImpl + runOneBuild: runOneBuildImpl, }; // -----------------