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!
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";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.