test: add interm fix for test that rely on an index.d.ts file (#28884)
At the moment, certain tests relies on resolving the module with an index.d.ts, this root cause might be some implementations are missing from the mocks.
Similar to: 58b4045359
PR Close #28884
This commit is contained in:
parent
b3ffdf92c5
commit
b012ab210b
|
@ -122,8 +122,15 @@ export function setupBazelTo(tmpDirPath: string) {
|
||||||
fs.mkdirSync(nodeModulesPath);
|
fs.mkdirSync(nodeModulesPath);
|
||||||
fs.mkdirSync(angularDirectory);
|
fs.mkdirSync(angularDirectory);
|
||||||
|
|
||||||
getAngularPackagesFromRunfiles().forEach(
|
getAngularPackagesFromRunfiles().forEach(({pkgPath, name}) => {
|
||||||
({pkgPath, name}) => { fs.symlinkSync(pkgPath, path.join(angularDirectory, name), 'dir'); });
|
fs.symlinkSync(pkgPath, path.join(angularDirectory, name), 'dir');
|
||||||
|
|
||||||
|
// todo: check why we always need an index.d.ts
|
||||||
|
if (!fs.existsSync(path.join(angularDirectory, name, 'index.d.ts'))) {
|
||||||
|
fs.symlinkSync(
|
||||||
|
path.join(pkgPath, `${name}.d.ts`), path.join(angularDirectory, name, 'index.d.ts'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Link typescript
|
// Link typescript
|
||||||
const typeScriptSource = resolveNpmTreeArtifact('npm/node_modules/typescript');
|
const typeScriptSource = resolveNpmTreeArtifact('npm/node_modules/typescript');
|
||||||
|
|
|
@ -591,6 +591,11 @@ function readBazelWrittenFilesFrom(
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
processDirectory(bazelPackageRoot, path.join('/node_modules/@angular', packageName));
|
processDirectory(bazelPackageRoot, path.join('/node_modules/@angular', packageName));
|
||||||
|
// todo: check why we always need an index.d.ts
|
||||||
|
if (fs.existsSync(path.join(bazelPackageRoot, `${packageName}.d.ts`))) {
|
||||||
|
const content = fs.readFileSync(path.join(bazelPackageRoot, `${packageName}.d.ts`), 'utf8');
|
||||||
|
map.set(path.join('/node_modules/@angular', packageName, 'index.d.ts'), content);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(
|
console.error(
|
||||||
`Consider adding //packages/${packageName} as a data dependency in the BUILD.bazel rule for the failing test`);
|
`Consider adding //packages/${packageName} as a data dependency in the BUILD.bazel rule for the failing test`);
|
||||||
|
|
Loading…
Reference in New Issue