Jasmine spyOn fails after moving to Webpack4


Jasmine spyOn fails after moving to Webpack4



Recently I'm migrating a project from webpack 3 -> 4. There's an issue wit karma/jasmine tests. In my test I want to import a TypeScript namespace object and mock it.


webpack


karma/jasmine


spyOn(AlertDialogModule, 'createAlertDialog')
.and.returnValue(
Promise.resolve(alertDialogMock)
);



But I have an error



Error: : createAlertDialog is not declared writable or has no
setter



I think, the reason is in how WP4 handles harmony exports


/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift