I’m currently working on a React project and when we upgraded to higher version of Sweet Alert 2, all of a sudden we cannot run our unit test due to an error like this,“Cannot assign to read only property ‘iterator’ of function ‘function Symbol() { [native code]}’”. Further investigation, and I found out that there’s a piece of code that Sweet Alert 2 has added to polyfill WeakMap object on older Android device. The polyfill code currently breaks and stops running all our unit tests that invoke Sweet Alert 2. Awesome! These are those lines of code, sweetalert2.all.js#L1124 - L1153.
Lines L1124 to L1153, needs to be somehow bypassed inorder to run the unit test without error. So my solution is to include weakmap-polyfill on our bootstrap unit test file.
const enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');
...more code here
// this is the fix
require('weakmap-polyfill');
enzyme.configure({ adapter: new Adapter() });
Voila, unit test runs again.