1

I have an Angular project run with Electron. My code compiles and works nicely, and now I've come to test it. Before I even start writing tests, all the 'shouldCreate' tests are failing with the message "TypeError: window.require is not a function".

I have seen this post and this post, as well as a few others on the matter, but none of them address what to do if it only fails in tests.

How can I get my tests to succeed, even with my code having things like window.require('fs') and the like? Again, the code compiles and runs (at least in the dev environment) but my tests fail before I have written them

TIA

EDIT: My code is based off of this github project

PMO1948
  • 2,210
  • 11
  • 34

1 Answers1

0

So it seems like those errors appeared because I opened the browser to the port where karma was running, and as a result, those errors appeared. (Chrome really does not have access to the window etc, so it makes sense.)

When I ran the tests from the CMD w/o opening the browser, everything succeeded and all's well that ends well

PMO1948
  • 2,210
  • 11
  • 34