forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_bed_common.ts
More file actions
126 lines (112 loc) · 4.03 KB
/
test_bed_common.ts
File metadata and controls
126 lines (112 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {
InjectionToken,
SchemaMetadata,
ɵDeferBlockBehavior as DeferBlockBehavior,
} from '@angular/core';
/** Whether test modules should be torn down by default. */
export const TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT = true;
/** Whether unknown elements in templates should throw by default. */
export const THROW_ON_UNKNOWN_ELEMENTS_DEFAULT = false;
/** Whether unknown properties in templates should throw by default. */
export const THROW_ON_UNKNOWN_PROPERTIES_DEFAULT = false;
/** Whether defer blocks should use manual triggering or play through normally. */
export const DEFER_BLOCK_DEFAULT_BEHAVIOR = DeferBlockBehavior.Playthrough;
/**
* An abstract class for inserting the root test component element in a platform independent way.
*
* @publicApi
*/
export class TestComponentRenderer {
insertRootElement(rootElementId: string) {}
removeAllRootElements?() {}
}
/**
* @publicApi
*/
export const ComponentFixtureAutoDetect = new InjectionToken<boolean>('ComponentFixtureAutoDetect');
/**
* @publicApi
*/
export const ComponentFixtureNoNgZone = new InjectionToken<boolean>('ComponentFixtureNoNgZone');
/**
* @publicApi
*/
export interface TestModuleMetadata {
providers?: any[];
declarations?: any[];
imports?: any[];
schemas?: Array<SchemaMetadata | any[]>;
teardown?: ModuleTeardownOptions;
/**
* Whether NG0304 runtime errors should be thrown when unknown elements are present in component's
* template. Defaults to `false`, where the error is simply logged. If set to `true`, the error is
* thrown.
* @see [NG8001](/errors/NG8001) for the description of the problem and how to fix it
*/
errorOnUnknownElements?: boolean;
/**
* Whether errors should be thrown when unknown properties are present in component's template.
* Defaults to `false`, where the error is simply logged.
* If set to `true`, the error is thrown.
* @see [NG8002](/errors/NG8002) for the description of the error and how to fix it
*/
errorOnUnknownProperties?: boolean;
/**
* Whether errors that happen during application change detection should be rethrown.
*
* When `true`, errors that are caught during application change detection will
* be reported to the `ErrorHandler` and rethrown to prevent them from going
* unnoticed in tests.
*
* When `false`, errors are only forwarded to the `ErrorHandler`, which by default
* simply logs them to the console.
*
* Defaults to `true`.
*/
rethrowApplicationErrors?: boolean;
/**
* Whether defer blocks should behave with manual triggering or play through normally.
* Defaults to `manual`.
*/
deferBlockBehavior?: DeferBlockBehavior;
}
/**
* @publicApi
*/
export interface TestEnvironmentOptions {
/**
* Configures the test module teardown behavior in `TestBed`.
*/
teardown?: ModuleTeardownOptions;
/**
* Whether errors should be thrown when unknown elements are present in component's template.
* Defaults to `false`, where the error is simply logged.
* If set to `true`, the error is thrown.
* @see [NG8001](/errors/NG8001) for the description of the error and how to fix it
*/
errorOnUnknownElements?: boolean;
/**
* Whether errors should be thrown when unknown properties are present in component's template.
* Defaults to `false`, where the error is simply logged.
* If set to `true`, the error is thrown.
* @see [NG8002](/errors/NG8002) for the description of the error and how to fix it
*/
errorOnUnknownProperties?: boolean;
}
/**
* Configures the test module teardown behavior in `TestBed`.
* @publicApi
*/
export interface ModuleTeardownOptions {
/** Whether the test module should be destroyed after every test. Defaults to `true`. */
destroyAfterEach: boolean;
/** Whether errors during test module destruction should be re-thrown. Defaults to `true`. */
rethrowErrors?: boolean;
}