Protractor is the end to end test case runner for AngularJS. These end to end test cases can be repurposed to record performance metrics when the scenario is being run. This is a sample repository with an example of how this can be done.
Install all dependencies using npm install
Protractor currently supports only synchronous configurations. Here is the issue asking for support of asynchronous configurations. Till this feature is added, you would need to generate a temporary configuration that would have the browser parameters required for performance analysis. Run to following command to generate conf.js.tmp
.
node index.js --config conf.js
Once the configration file is generated, run protractor against this using
node_modules/.bin/protractor conf.js.tmp
This will run the example spec and also record the performance metrics. Note the calls to perfRunner in lines 4 8 and 16 that initialize, start and stop the performance metrics.
To start using it in your projects,
- Add browser-perf to your project
- Copy index.js and use it in your test case to mark the start and stop of the scenario.
- Ensure that in your build, you generate the configuration, live done in Step 1 above.
Thanks for sharing this Parashuram!!! It works like a charm!!!
premkh9, in your case, considering the folder structure displayed in the stack trace, the relative path of index.js mentioned in the spec is wrong. It will work if you change that line to
var PerfRunner = require('../../../../../../../../index.js')
if the index.js file is in the project root.OR
Just simply place that index.js file in the same directory containing the spec file