test(language-service): move existing tests to legacy directory (#39594)

In preparation for in-memory testing infrastructure, the existing Ivy
language service tests are moved to a `legacy` directory. These existing
tests rely on a single integration project in `test/project/app`, which
presents a number of challenges:

 * adding extra fields/properties to the integration project for one test
   can cause others to fail/flake.
 * it's especially difficult to test any cases that require introducing
   intentional errors, as those tend to break other tests.
 * tests load files from disk, which is slower.
 * tests rely on the real built versions of @angular/core and
   @angular/common, which makes them both slow to build and require rebuilds
   on every compiler change.
 * tests share a single tsconfig.json, making it extremely difficult to test
   how the language service handles different configuration scenarios (e.g.
   different type-checking flags).

PR Close #39594
This commit is contained in:
Alex Rickabaugh 2020-11-04 12:28:37 -08:00 committed by atscott
parent c243ff3b6b
commit a7155bc2fa
12 changed files with 13 additions and 13 deletions

View File

@ -1,7 +1,7 @@
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")
ts_library(
name = "test_lib",
name = "legacy_lib",
testonly = True,
srcs = glob(["*.ts"]),
deps = [
@ -12,7 +12,7 @@ ts_library(
)
jasmine_node_test(
name = "test",
name = "legacy",
data = [
# Note that we used to depend on the npm_package of common, core, and
# forms, but this is no longer the case. We did it for View Engine
@ -28,6 +28,6 @@ jasmine_node_test(
"ivy-only",
],
deps = [
":test_lib",
":legacy_lib",
],
)

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {LanguageService} from '../language_service';
import {LanguageService} from '../../language_service';
import {APP_COMPONENT, MockService, setup} from './mock_host';
import {humanizeDefinitionInfo} from './test_utils';

View File

@ -8,7 +8,7 @@
import * as ts from 'typescript/lib/tsserverlibrary';
import {LanguageService} from '../language_service';
import {LanguageService} from '../../language_service';
import {APP_COMPONENT, MockService, setup, TEST_TEMPLATE} from './mock_host';

View File

@ -8,7 +8,7 @@
import * as ts from 'typescript/lib/tsserverlibrary';
import {LanguageServiceAdapter} from '../language_service_adapter';
import {LanguageServiceAdapter} from '../../language_service_adapter';
import {MockService, setup, TEST_TEMPLATE} from './mock_host';

View File

@ -8,7 +8,7 @@
import * as ts from 'typescript/lib/tsserverlibrary';
import {LanguageService, parseNgCompilerOptions} from '../language_service';
import {LanguageService, parseNgCompilerOptions} from '../../language_service';
import {MockService, setup, TEST_TEMPLATE} from './mock_host';

View File

@ -9,7 +9,7 @@
import {join} from 'path';
import * as ts from 'typescript/lib/tsserverlibrary';
import {isTypeScriptFile} from '../utils';
import {isTypeScriptFile} from '../../utils';
const logger: ts.server.Logger = {
close(): void{},
@ -147,7 +147,7 @@ export class MockService {
return this.overwriteScriptInfo(scriptInfo, text);
}
reset() {
reset(): void {
if (this.overwritten.size === 0) {
return;
}

View File

@ -8,7 +8,7 @@
import * as ts from 'typescript/lib/tsserverlibrary';
import {LanguageService} from '../language_service';
import {LanguageService} from '../../language_service';
import {APP_COMPONENT, MockService, setup, TEST_TEMPLATE} from './mock_host';

View File

@ -10,8 +10,8 @@ import {ParseError, parseTemplate} from '@angular/compiler';
import * as e from '@angular/compiler/src/expression_parser/ast'; // e for expression AST
import * as t from '@angular/compiler/src/render3/r3_ast'; // t for template AST
import {getTargetAtPosition} from '../template_target';
import {isExpressionNode, isTemplateNode} from '../utils';
import {getTargetAtPosition} from '../../template_target';
import {isExpressionNode, isTemplateNode} from '../../utils';
interface ParseResult {
nodes: t.Node[];

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {LanguageService} from '../language_service';
import {LanguageService} from '../../language_service';
import {APP_COMPONENT, MockService, setup} from './mock_host';
import {HumanizedDefinitionInfo, humanizeDefinitionInfo} from './test_utils';