jszip
jszip copied to clipboard
Work around a jest/nodejs issue where instanceof ArrayBuffer fails
Work around a jest/nodejs issue where instanceof ArrayBuffer fails due to a nodes sandbox issue See https://github.com/nodejs/node/issues/20978, marked as fixed, but seems to resurface with node 10.15.3 and jest 24.7.1
The use of instanceof ArrayBuffer
is also problematic in Safari. Checking instanceof
of an ArrayBuffer in the window context will return false for ArrayBuffers created in a different context, e.g. an iframe. I think this should fix it 👍
See: https://github.com/feross/buffer/issues/166
The test environment is that of the Karma test runner, which uses an iframe to isolate test code from the runner's code. As a result, the ArrayBuffer constructor object in the code's context is not referentially equivalent to the ArrayBuffer constructor object in the main window context.
There was a similar fix in this repo for the Blob
https://github.com/Stuk/jszip/pull/350