'TypeError: Cannot set property scrollHeight of [object Element] which has only a getter

I am using PrimeNg v11.x element. Application is working fine with scrollHeight value set from a variable but the jasmine test is failing with error:

TypeError: Cannot set property scrollHeight of [object Element] which has only a getter

    <p-tree
        #tree
        [value]="nodes"
        selectionMode="checkbox"
        [scrollHeight]="scrollHeight"
        virtualScroll="true"
        virtualNodeHeight="33"
    ></p-tree>

The test succeeds if i hard code the height value.

Can anyone help how to fix this issue?

Thanks



Solution 1:[1]

Try this it may help you. import the module that you are using like TreeModule.

beforeEach(
    waitForAsync(() => {
      TestBed.configureTestingModule({
        imports: [TreeModule],
        declarations: [Componentsdeclaration],
        schemas: [NO_ERRORS_SCHEMA],
      }).compileComponents();
    })
  );

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sunny