small medium large xlarge

Generic-user-small
12 Dec 2016, 11:37
Adewole Mayowa (6 posts)

In the CustomerSearchComponent.spec.js
var td = require(“testdouble”); window = td.object([“alert”]);

All tests for features were passed except tests with alert from td

1) CustomerSearchComponent search A search for ‘pat’, three or more characters A search that fails on the back-end sets the keywords to be ‘pat’ Message: ReferenceError: alert is not defined Stacktrace: ReferenceError: alert is not defined 2) CustomerSearchComponent search A search for ‘pat’, three or more characters A search that fails on the back-end leaves customers as null Message: ReferenceError: alert is not defined 3) CustomerSearchComponent search A search for ‘pat’, three or more characters A search that fails on the back-end alerts the user with the response message Message: ReferenceError: alert is not defined

Tests with alert were not passed.

How can we fix this?

Dmfcb_pragsmall
12 Dec 2016, 15:13
David Copeland (433 posts)

I think this is an issue with the current beta that’s been fixed in later versions.

In your production code in webpack/CustomerSearchComponent.js you need to change the call to alert() to window.alert()

In your unit test, you should have mocked window so that should make the test pass.

If that doesn’t work, can you post your project to GitHub and I can take a look?

Generic-user-small
27 Dec 2016, 03:06
Aaron Nagucki (3 posts)

I have the same issue. Using window.alert() and mocking window. It still has ** ReferenceError: alert is not defined** In my tests. Here is my repo… https://github.com/MrNagoo/prag-prog-shine Thanks!

Generic-user-small
02 Jan 2017, 22:14
Aaron Nagucki (3 posts)

Ahh, thanks. I didn’t realize that that code had to change as well. Maybe this should be addressed, or maybe I missed it. Been waiting to figure that out so I can continue the book.

Dmfcb_pragsmall
03 Jan 2017, 18:17
David Copeland (433 posts)

It should be fixed in the final beta/final release of the book.

You must be logged in to comment