Reputation: 25533
According to Angular's documentation
Add a pause() statement inside of an end-to-end test and rerun it. You'll see the runner pause; this gives you the opportunity to explore the state of your application while it is displayed in the browser. The app is live! You can change the search query to prove it. Notice how useful this is for troubleshooting end-to-end tests.
I use this quite a bit in my end to end testing, but I've hit a bit of a snag. I have my dev environment set up with grunt to behave like so:
grunt.registerTask('test:watch', [
'clean:server',
'concurrent:server',
'autoprefixer',
'connect:livereload',
'karma:unit',
'open',
'karma:e2e',
'watch'
]);
The interesting bits here are how karma is set up and how watch is set up with karma, so check these out:
karma: {
options: {
configFile: 'karma.conf.js',
},
e2e: {
singleRun: false,
background: true,
configFile: 'karma-e2e.conf.js',
},
unit: {
singleRun: false,
background: true
}
}
and the watch looks like this
watch: {
karma: {
files: ['test/**/*.js'],
tasks: ['karma:unit:run', 'karma:e2e:run']
}
}
So, when I run
grunt test:watch
I get my server spun up so I can play with it, and every time I change a file my unit tests run, followed by my end to end tests. It works quite nicely. The problem is, when I use pause in my end to end tests, the console stops at the pause and I don't know how to tell it to resume without just having to kill the command and start over again.
In case you are wondering, I have the Scenario Runner running on a separate browser which is where the pause() comes in handy. On that side, everything is working fine, and I can resume it on the browser and everything is great.
But the question remains, how can I get the watch to continue "evaluating" the end to end tests through bash console once it hits the pause()?
Upvotes: 3
Views: 3810
Reputation:
This won't be a popular answer but at this point you are yak-shaving:
A less useful activity done to consciously or unconsciously procrastinate about a larger but more useful task.
Your goal is to test the behaviour of the site in the browser or to test the behaviour of the code against tests. There is no need to do both at the same time.
If you're really nervous about accidentally committing something that doesn't pass the unit tests or e2e tests you can always add a pre-commit hook to git or whatever version control system you're using to make sure that all tests are passing.
At this point I'm surprised you aren't also getting your grunt task to commit the code, tag it and push it to production! ;)
Upvotes: 1