feat(core): add NO_ERRORS_SCHEMA that allows any properties to be set on any element (#10956)
Often it is useful to test a component without rendering certain directives/components in its template because these directives require some complicated setup. You can do that by using NO_ERRORS_SCHEMA. TestBed.configureTestingModule({ schemas: [NO_ERRORS_SCHEMA] }); This would disable all schema checks in your tests.
This commit is contained in:
@ -21,7 +21,7 @@ import {TypeDecorator, makeDecorator, makeParamDecorator, makePropDecorator} fro
|
||||
export {ANALYZE_FOR_ENTRY_COMPONENTS, AttributeMetadata, ContentChildMetadata, ContentChildrenMetadata, QueryMetadata, ViewChildMetadata, ViewChildrenMetadata, ViewQueryMetadata} from './metadata/di';
|
||||
export {ComponentMetadata, ComponentMetadataType, DirectiveMetadata, DirectiveMetadataType, HostBindingMetadata, HostListenerMetadata, InputMetadata, OutputMetadata, PipeMetadata, PipeMetadataType} from './metadata/directives';
|
||||
export {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnDestroy, OnInit} from './metadata/lifecycle_hooks';
|
||||
export {CUSTOM_ELEMENTS_SCHEMA, ModuleWithProviders, NgModuleMetadata, NgModuleMetadataType, SchemaMetadata} from './metadata/ng_module';
|
||||
export {CUSTOM_ELEMENTS_SCHEMA, ModuleWithProviders, NO_ERRORS_SCHEMA, NgModuleMetadata, NgModuleMetadataType, SchemaMetadata} from './metadata/ng_module';
|
||||
export {ViewEncapsulation} from './metadata/view';
|
||||
|
||||
|
||||
|
@ -36,6 +36,15 @@ export const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata = {
|
||||
name: 'custom-elements'
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines a schema that will allow any property on any element.
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
export const NO_ERRORS_SCHEMA: SchemaMetadata = {
|
||||
name: 'no-errors-schema'
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface for creating {@link NgModuleMetadata}
|
||||
* @experimental
|
||||
|
Reference in New Issue
Block a user