Igniteui-angular: IgxSelectItemComponent throws an error when testing with Jest

Created on 3 Dec 2019  路  2Comments  路  Source: IgniteUI/igniteui-angular

Description

When trying to set the value of an igx-select component in Jest tests, an error is thrown :

TypeError: Cannot read property 'trim' of undefined

Steps to reproduce

See repro repo at https://github.com/jdpearce/nx-igx-select-test

Run ng test to see the failing test.

It seems to be due to this method : https://github.com/IgniteUI/igniteui-angular/blob/c268bcb9e8315aaaf559af7b3c6dc8d1f4665309/projects/igniteui-angular/src/lib/select/select-item.component.ts#L35-L41

bug tests select high resolved 8.1.x 8.2.x 9.0.x

Most helpful comment

This error is due to a Jest limitation regarding the use of innerText property under default jsdom testEnvironment. It does not seem likely for this to be fixed soon. The primary issue is the fact that innerText leans on the layout engine for guidance, and jsdom has no layout engine. As an alternative "full" browser support, it may be an option to use puppeteer.

We will consider addressing this in the product.

All 2 comments

This error is due to a Jest limitation regarding the use of innerText property under default jsdom testEnvironment. It does not seem likely for this to be fixed soon. The primary issue is the fact that innerText leans on the layout engine for guidance, and jsdom has no layout engine. As an alternative "full" browser support, it may be an option to use puppeteer.

We will consider addressing this in the product.

While verifying this issue on the "master" branch, an exception that "PointerEvent is not defined" was thrown when executing the tests. This is related to this issue in "jsdom" - https://github.com/jsdom/jsdom/issues/2527
More info here - https://github.com/kulshekhar/ts-jest/issues/1035

Was this page helpful?
0 / 5 - 0 ratings