Protractor-Perf
Just like Protractor is the end to end test case runner for AngularJS to check for functional regressions, this project is a way check for performance regressions while reusing the same test cases.
Usage
Install protractor-perf using npm install -g protractor-perf
.
Protractor test cases are re-used to run scenarios where performance needs to be measured. Protractor-perf can be used just like protractor, just that the test-cases need to be instrumented to indicated when to start and stop measuring performance.
Protractor is usually invoked using $ protractor conf.js
. Use $ protractor-perf conf.js
instead to start measuring performance.
The config file is the same configuration file used for protractor tests.
Note: If you run selenium using protractor's webdriver-manager
, you would need to specify seleniumPort
and selenium
keys in the config file, to explicitly specify the port on which the selenium server will run. This port will also be picked up by protractor-perf
. See ./test/conf.js
as an example.
When the instrumented test cases are run using protractor, the code related to performance is a no-op. This way, adding instrumentation does not break your ability to run protractor to just test for functionality.
Instrumenting the test cases
The test case need to specify when to start and stop measuring performance metrics for a certain scenario. The following code is an example of a test case, with perf code snippets added.
var PerfRunner = ;;
The four statements to note are
- Initialize the Perf monitor using
new ProtractorPerf(protractor, browser)
- To start measuring the perf, use
perf.start()
- Once the scenario that you would like to perf test completes, use
perf.stop()
- Finally, use
perf.getStats('statName')
inexpect
statements to ensure that all the performance metrics are within the acceptable range.
The perf.isEnabled
is needed to ensure that perf metrics are not tested when the test case is run using protractor
directly.
Metrics measured
protractor-perf
is based on browser-perf. browser-perf
measures the metrics that can be tested for regressions. Look at browser-perf's wiki page for more information about the project.
Grunt Integration
Invoke protractor-perf
from a GruntFile as below
module { var protractorperf = ; grunt; grunt;};