Skip to content

Commit

Permalink
feat: deprecate detectChanges in favor of detectChangesOnRender (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver authored Dec 10, 2022
1 parent 65cccbe commit 63c27e2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions projects/testing-library/src/lib/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,25 @@ export interface RenderComponentOptions<ComponentType, Q extends Queries = typeo
* const component = await render(AppComponent, {
* detectChanges: false
* })
*
* @deprecated
* Use `detectChangesOnRender` instead
*/
detectChanges?: boolean;
/**
* @description
* Invokes `detectChanges` after the component is rendered
*
* @default
* true
*
* @example
* const component = await render(AppComponent, {
* detectChangesOnRender: false
* })
*/
detectChangesOnRender?: boolean;

/**
* @description
* A collection of components, directives and pipes needed to render the component, for example, nested components of the component.
Expand Down
5 changes: 4 additions & 1 deletion projects/testing-library/src/lib/testing-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export async function render<SutType, WrapperType = SutType>(
): Promise<RenderResult<SutType>> {
const { dom: domConfig, ...globalConfig } = getConfig();
const {
detectChanges: detectChangesOnRender = true,
detectChanges: detectChangesDeprecated = true,
detectChangesOnRender: detectChangesOnRenderInput,
declarations = [],
imports = [],
providers = [],
Expand All @@ -63,6 +64,8 @@ export async function render<SutType, WrapperType = SutType>(
defaultImports = [],
} = { ...globalConfig, ...renderOptions };

const detectChangesOnRender =
detectChangesOnRenderInput === undefined ? detectChangesDeprecated : detectChangesOnRenderInput;
dtlConfigure({
eventWrapper: (cb) => {
const result = cb();
Expand Down

0 comments on commit 63c27e2

Please sign in to comment.