From b867066396e11254c135822fadb12362496af67b Mon Sep 17 00:00:00 2001 From: Santosh Mahto Date: Sun, 6 Jun 2021 13:33:41 +0530 Subject: [PATCH] fix(@schematics/angular): added webWorkerTsConfig into test option (cherry picked from commit 052b8fa4db63bf0c08aa95ca727bd18420f19f6e) --- packages/schematics/angular/web-worker/index.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/schematics/angular/web-worker/index.ts b/packages/schematics/angular/web-worker/index.ts index 8283ab9e72f5..e1437ecc17c9 100644 --- a/packages/schematics/angular/web-worker/index.ts +++ b/packages/schematics/angular/web-worker/index.ts @@ -105,7 +105,6 @@ function addSnippet(options: WebWorkerOptions): Rule { export default function (options: WebWorkerOptions): Rule { return async (host: Tree) => { const workspace = await getWorkspace(host); - if (!options.project) { throw new SchematicsException('Option "project" is required.'); } @@ -142,6 +141,18 @@ export default function (options: WebWorkerOptions): Rule { projectTargetOptions.webWorkerTsConfig = workerConfigPath; } + const projectTestTarget = project.targets.get('test'); + if (projectTestTarget) { + const projectTestTargetOptions = ((projectTestTarget.options || + {}) as unknown) as BrowserBuilderOptions; + + const needWebWorkerConfig = !projectTestTargetOptions.webWorkerTsConfig; + if (needWebWorkerConfig) { + const workerConfigPath = join(normalize(root), 'tsconfig.worker.json'); + projectTestTargetOptions.webWorkerTsConfig = workerConfigPath; + } + } + const templateSource = apply(url('./files/worker'), [ applyTemplates({ ...options, ...strings }), move(parsedPath.path),