Loading ngMock only in testing context when using Protractor
I loop through all of our E2E tags of our angular drawer app ngMock
so that we can mock our / http resource calls. However, I cannot find the recommended loading method ngMock
in this scenario.
I don't want to include the script itself in my live app, but I don't see a clear method using a protractor to inject an additional element script
or load it dynamically.
source to share
You can use grunt-targethtml or gupl-targethtml , so in index.html
you can add conditions to add script or not:
<!--(if target mock || e2e)><!-->
<script src="dev-mocks/mock-utils.js"></script>
<script src="dev-mocks/modules/authentication-service-mock.js"></script>
<!--<!(endif)-->
First, set up a grunt task to do the task targethtml
with target
e2e
/mock
grunt.registerTask(
'e2e',
'Automated tests',
function(target) {
var tasks = [
'clean:server',
'targethtml:e2e',
'concurrent:server',
'autoprefixer',
'connect:e2e'
];
return grunt.task.run(tasks);
});
Here is a working template with all the tasks, packages and logic needed to implement Protractor + CucumberJS + sugar-step (to make it easier to do sync-async steps) and also modulate modulated modules dynamically using @Around method for CucumberJS
source to share