Security and ngMockE2E

166 views Asked by At

I have some protractor tests and I would like to mock some calls to a third party service used by my Angular JS app.

I've read about ngMockE2E. My understanding is this requires I add angular-mocks.js to my page.

What are the best practices including angular-mocks.js in a page? Should I use some sort of pre-processor to remove it or is it somehow safe for use in a production environment?

1

There are 1 answers

3
alecxe On

Protractor allows you to add arbitrary mock modules via browser.addMockModule() (which would though still require angular-mocks module to be loaded). Sample usages:

Should I use some sort of pre-processor to remove it or is it somehow safe for use in a production environment?

I would solve it on the application build level (with grunt or gulp, for example). Install angular-mocks package and include in the build only for the dev/test environment.