FCin FCin - 11 months ago 42
AngularJS Question

Get file names of executed spec files

How do I get a file name of currently executed spec?
For example:
I run:

protractor conf.js --specs ./spec/first_spec.js,./spec/second_spec.js

so I want to retrieve array
, because I want to show it in a
. Is this a good way of thinking or is there a built-in function for file names in the latest run? I'm new to protractor and angular, and I found only a way to extract individual
which doesn't really help me. I write this on top of

Answer Source

This is one way of doing it. Read the array of test cases passed from CLI arguments and use it as per your convenience

onPrepare: function() {
var testCaseArr
    for (i = 0; i < process.argv.length; i++) {
        argument = process.argv[i];
        // if "specs" are found we know that the immediate following object is the array of test scenarios
        if (argument.indexOf('specs')>0) {
            specIndex = i + 1;
            testCaseArr = process.argv[i+1];
    // This will output - ['first_spec','second_spec']