Both of these directives use canvas to measure the effective width of the current input.
This fails in environments that use an incomplete implementation of DOM, which affects users of jest with jsdom.
Currently, testing components that use nx-word or nxAutoResize requires either mocking nx-word, canvas, or installing a package like node-canvas.
This probably also affects server side rendering with Angular Universal, although I did not test that yet.
🎯 Goals
Make usage of nx-word and nxAutoResize less frustrating by handling the width calculation in a type safe manner.
I.e. check if the context returned from canvas.getContext('2d') is null instead of asserting it as non-nullable, and act accordingly to prevent runtime errors during width calculation.
nx-word, nxAutoResize
Both of these directives use canvas to measure the effective width of the current input. This fails in environments that use an incomplete implementation of DOM, which affects users of
jest
withjsdom
.Currently, testing components that use
nx-word
ornxAutoResize
requires either mocking nx-word, canvas, or installing a package like node-canvas.This probably also affects server side rendering with Angular Universal, although I did not test that yet.
🎯 Goals
Make usage of nx-word and nxAutoResize less frustrating by handling the width calculation in a type safe manner. I.e. check if the context returned from
canvas.getContext('2d')
is null instead of asserting it as non-nullable, and act accordingly to prevent runtime errors during width calculation.