Skip to content

Commit 8ead19f

Browse files
devversionthePunderWoman
authored andcommitted
build: migrate all ts_library in packages/core/test (angular#61472)
This commit migrates all `ts_library` in `package/core/test` to `ts_project`, and fixes deep module, or relative imports inside. PR Close angular#61472
1 parent 3a106a3 commit 8ead19f

File tree

65 files changed

+316
-218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+316
-218
lines changed

packages/core/test/BUILD.bazel

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
load("//tools:defaults.bzl", "jasmine_node_test", "karma_web_test_suite", "ts_library")
1+
load("//tools:defaults.bzl", "jasmine_node_test", "karma_web_test_suite")
2+
load("//tools:defaults2.bzl", "ts_project")
23

34
package(default_visibility = ["//visibility:public"])
45

@@ -23,17 +24,19 @@ UTILS = [
2324
"linker/source_map_util.ts",
2425
]
2526

26-
ts_library(
27+
ts_project(
2728
name = "test_utils",
2829
testonly = True,
2930
srcs = UTILS,
30-
deps = [
31+
interop_deps = [
3132
"//packages/compiler",
32-
"@npm//source-map",
33+
],
34+
deps = [
35+
"//:node_modules/source-map",
3336
],
3437
)
3538

36-
ts_library(
39+
ts_project(
3740
name = "test_lib",
3841
testonly = True,
3942
srcs = glob(
@@ -43,10 +46,7 @@ ts_library(
4346
"reflection/es2015_inheritance_fixture.ts",
4447
],
4548
),
46-
# Visible to //:saucelabs_unit_tests_poc target
47-
visibility = ["//:__pkg__"],
48-
deps = [
49-
":test_utils",
49+
interop_deps = [
5050
"//packages/animations",
5151
"//packages/animations/browser",
5252
"//packages/animations/browser/testing",
@@ -69,20 +69,23 @@ ts_library(
6969
"//packages/router",
7070
"//packages/router/testing",
7171
"//packages/zone.js/lib:zone_d_ts",
72-
"@npm//rxjs",
72+
],
73+
# Visible to //:saucelabs_unit_tests_poc target
74+
visibility = ["//:__pkg__"],
75+
deps = [
76+
":test_utils_rjs",
77+
"//:node_modules/rxjs",
7378
],
7479
)
7580

76-
ts_library(
81+
ts_project(
7782
name = "test_node_only_lib",
7883
testonly = True,
7984
srcs = glob(
8085
["**/*_node_only_spec.ts"],
8186
exclude = UTILS,
8287
),
83-
deps = [
84-
":test_lib",
85-
":test_utils",
88+
interop_deps = [
8689
"//packages/compiler",
8790
"//packages/core",
8891
"//packages/core/src/compiler",
@@ -91,6 +94,10 @@ ts_library(
9194
"//packages/platform-server/testing",
9295
"//packages/private/testing",
9396
],
97+
deps = [
98+
":test_lib_rjs",
99+
":test_utils_rjs",
100+
],
94101
)
95102

96103
jasmine_node_test(

packages/core/test/acceptance/BUILD.bazel

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
load("//tools:defaults.bzl", "jasmine_node_test", "karma_web_test_suite", "ng_module", "ts_library")
1+
load("//tools:defaults.bzl", "jasmine_node_test", "karma_web_test_suite", "ng_module")
2+
load("//tools:defaults2.bzl", "ts_project")
23

34
package(default_visibility = ["//visibility:private"])
45

56
SPEC_FILES_WITH_FORWARD_REFS = [
67
"di_forward_ref_spec.ts",
78
]
89

9-
ts_library(
10+
ts_project(
1011
name = "acceptance_lib",
1112
testonly = True,
1213
srcs = glob(
1314
["**/*.ts"],
1415
exclude = SPEC_FILES_WITH_FORWARD_REFS,
1516
),
16-
# Visible to //:saucelabs_unit_tests
17-
visibility = ["//:__pkg__"],
18-
deps = [
17+
interop_deps = [
1918
"//packages/animations",
2019
"//packages/animations/browser",
2120
"//packages/animations/browser/testing",
@@ -38,7 +37,11 @@ ts_library(
3837
"//packages/private/testing",
3938
"//packages/router",
4039
"//packages/zone.js/lib:zone_d_ts",
41-
"@npm//rxjs",
40+
],
41+
# Visible to //:saucelabs_unit_tests
42+
visibility = ["//:__pkg__"],
43+
deps = [
44+
"//:node_modules/rxjs",
4245
],
4346
)
4447

packages/core/test/acceptance/after_render_hook_spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {PLATFORM_BROWSER_ID, PLATFORM_SERVER_ID} from '@angular/common/src/platform_id';
9+
import {
10+
ɵPLATFORM_BROWSER_ID as PLATFORM_BROWSER_ID,
11+
ɵPLATFORM_SERVER_ID as PLATFORM_SERVER_ID,
12+
} from '@angular/common';
1013
import {
1114
AfterRenderRef,
1215
ApplicationRef,

packages/core/test/acceptance/authoring/BUILD.bazel

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
load("//tools:defaults.bzl", "jasmine_node_test", "karma_web_test_suite", "ng_module", "nodejs_binary", "npm_package_bin", "ts_library")
1+
load("//tools:defaults.bzl", "jasmine_node_test", "karma_web_test_suite", "ng_module", "nodejs_binary", "npm_package_bin")
2+
load("//tools:defaults2.bzl", "ts_project")
23

34
package(default_visibility = ["//visibility:private"])
45

@@ -13,20 +14,21 @@ TEST_DEPS = [
1314
"//packages/core/testing",
1415
"//packages/platform-browser",
1516
"//packages/core/primitives/signals",
16-
"@npm//rxjs",
1717
]
1818

19-
ts_library(
19+
ts_project(
2020
name = "test_compiler_lib",
2121
testonly = True,
2222
srcs = ["authoring_test_compiler.ts"],
23-
deps = [
23+
interop_deps = [
2424
"//packages/compiler-cli",
2525
"//packages/compiler-cli/src/ngtsc/imports",
2626
"//packages/compiler-cli/src/ngtsc/partial_evaluator",
2727
"//packages/compiler-cli/src/ngtsc/reflection",
2828
"//packages/compiler-cli/src/ngtsc/transform/jit",
29-
"@npm//typescript",
29+
],
30+
deps = [
31+
"//:node_modules/typescript",
3032
],
3133
)
3234

@@ -37,7 +39,7 @@ nodejs_binary(
3739
":test_compiler_lib",
3840
"//packages:package_json",
3941
],
40-
entry_point = ":authoring_test_compiler.ts",
42+
entry_point = ":authoring_test_compiler.js",
4143
)
4244

4345
npm_package_bin(
@@ -49,18 +51,25 @@ npm_package_bin(
4951
tool = ":test_compiler",
5052
)
5153

52-
ts_library(
54+
ts_project(
5355
name = "test_jit_lib",
5456
testonly = True,
5557
srcs = ["transformed_%s" % file for file in TEST_FILES],
56-
deps = TEST_DEPS,
58+
interop_deps = TEST_DEPS,
59+
deps = [
60+
# TODO: Only rely on `TEST_DEPS`. This should be removed during `rules_js` migration.
61+
"//:node_modules/rxjs",
62+
],
5763
)
5864

5965
ng_module(
6066
name = "test_lib",
6167
testonly = True,
6268
srcs = TEST_FILES,
63-
deps = TEST_DEPS,
69+
deps = TEST_DEPS + [
70+
# TODO: Only rely on `TEST_DEPS`. This should be removed during `rules_js` migration.
71+
"@npm//rxjs",
72+
],
6473
)
6574

6675
jasmine_node_test(

packages/core/test/acceptance/change_detection_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {CommonModule} from '@angular/common';
10-
import {expect} from '@angular/platform-browser/testing/src/matchers';
10+
import {expect} from '@angular/private/testing/matchers';
1111
import {BehaviorSubject} from 'rxjs';
1212
import {
1313
ApplicationRef,

packages/core/test/acceptance/change_detection_transplanted_view_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ import {
2828
ViewChild,
2929
ViewContainerRef,
3030
} from '../../src/core';
31-
import {provideCheckNoChangesConfig} from '@angular/core/src/change_detection/provide_check_no_changes_config';
31+
import {provideCheckNoChangesConfig} from '../../src/change_detection/provide_check_no_changes_config';
3232
import {ComponentFixture, TestBed} from '../../testing';
33-
import {expect} from '@angular/platform-browser/testing/src/matchers';
33+
import {expect} from '@angular/private/testing/matchers';
3434
import {of} from 'rxjs';
3535

3636
describe('change detection for transplanted views', () => {

packages/core/test/acceptance/component_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
ɵɵdefineComponent,
3434
} from '../../src/core';
3535
import {TestBed} from '../../testing';
36-
import {expect} from '@angular/platform-browser/testing/src/matchers';
36+
import {expect} from '@angular/private/testing/matchers';
3737

3838
import {global} from '../../src/util/global';
3939

packages/core/test/acceptance/content_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
} from '../../src/core';
2323
import {TestBed} from '../../testing';
2424
import {By} from '@angular/platform-browser';
25-
import {expect} from '@angular/platform-browser/testing/src/matchers';
25+
import {expect} from '@angular/private/testing/matchers';
2626

2727
describe('projection', () => {
2828
function getElementHtml(element: HTMLElement) {

packages/core/test/acceptance/defer_spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ import {getInjectorResolutionPath} from '../../src/render3/util/injector_discove
4141
import {ActivatedRoute, provideRouter, Router, RouterOutlet} from '@angular/router';
4242
import {ChainedInjector} from '../../src/render3/chained_injector';
4343
import {global} from '../../src/util/global';
44-
import {TimerScheduler} from '@angular/core/src/defer/timer_scheduler';
44+
import {TimerScheduler} from '../../src/defer/timer_scheduler';
4545
import {Console} from '../../src/console';
4646
import {formatRuntimeErrorCode, RuntimeErrorCode} from '../../src/errors';
4747
import {provideNgReflectAttributes} from '../../src/ng_reflect';
48+
import {isBrowser} from '@angular/private/testing';
4849

4950
/**
5051
* Clears all associated directive defs from a given component class.

packages/core/test/acceptance/hmr_spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {clearTranslations, loadTranslations} from '@angular/localize';
3838
import {computeMsgId} from '@angular/compiler';
3939
import {EVENT_MANAGER_PLUGINS} from '@angular/platform-browser';
4040
import {ComponentType} from '../../src/render3';
41+
import {isNode} from '@angular/private/testing';
4142

4243
describe('hot module replacement', () => {
4344
it('should recreate a single usage of a basic component', () => {

0 commit comments

Comments
 (0)