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

1.5k views Asked by At

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

1

There are 1 answers

0
Sunny On

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();
    })
  );