lundi 26 mars 2018

Mocking Browser Environment in a Typescript Test

I have a set of typescript files that are being compiled and running a browser window.

I'd then like to write a set of tests in Typescript that would run in the Node environment, which would require mocking out any window APIs.

I can't find a clean way to do this with Typescript, often ending up with

Cannot find name 'location'.

I tried to define the location, but still had no joy as I declaring the interface and not an instance (which I'd like to stub in each test).

'location' only refers to a type, but is being used as a value here.

6 if (location.origin ===

Any ideas of how this could / should be done?

Aucun commentaire:

Enregistrer un commentaire