test(language-service): add new mock host for testing ivy (#36879)

This commit adds a new mock host for testing the ivy language service.

Unlike the existing mock_host which mocks the LanguageServiceHost, the
Ivy mock host mocks just the filesystem interface, aka ts.ServerHost.

This is because Ivy language service requires an actual Project to
perform operations like adding synthetic typecheck files to the project,
and by extension, to the ts.Program. These requirements make the existing
mock host unsuitable to be reused.

This new testing structure also improves test performance, because the
old mock host copies (it actually creates symlinks, but still that's
relatively expensive due to the sheer number of files involved) all
@angular/* packages along with the typescript package to a temporary
node_modules directory. This is done every time setup() is called.
Instead, this new mock host just loads them from a pre-determined path
in Bazel runfiles.

PR Close #36879
This commit is contained in:
Keen Yee Liau
2020-04-30 15:48:20 -07:00
committed by Alex Rickabaugh
parent 6046e86506
commit 58ea040570
4 changed files with 160 additions and 2 deletions

View File

@ -1,12 +1,18 @@
{
"//00": "This file is used for IDE only, actual compilation options is in MockTypescriptHost in test_utils.ts",
"//00": "This file is used for both IDE and the actual Project creation in Ivy language service for testing purpose",
"compilerOptions": {
"lib": ["es2015"],
"lib": ["es2015", "dom"],
"strict": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"target": "es2015",
"baseUrl": "../../../..",
"paths": {
"@angular/*": ["packages/*"]
}
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}