4

I'm trying to create a end-to-end test for a sign-up page that I already implemented. This logic creates an HTTP request to my API, but, to make the test independent, I'm trying to create a Mock of my AuthProvider class, the one that's made the HTTP request.

So, following the Proctator documentation, I've this simple example:

browser.addMockModule('modName', function() {
  angular.module('modName', []).value('foo', 'bar');
});

But, if put this in my test code, I got the following error:

e2e/sign-up.e2e-spec.ts (23,9): Cannot find name 'angular'

Which makes sense, because the angular variable never been defined. My question is: how correctly define it? Why I have to defined? And there is other alternative to create a mock?

Thanks in advance!

Rodrigo Chaves
  • 1,094
  • 8
  • 23

1 Answers1

0

I ran into the same problem and resolved it by following this post .

package.json under devDependencies:

"@types/angular": "^1.6.34"

spec.ts added the import:

import * as angular from "angular";
HaC
  • 902
  • 12
  • 24