Askish
Askish

Reputation: 87

Is there any way to read protractor.conf suites names into txt file?

I have a protractor.conf file which includes suites, for example:

suites: {
  login: '..PATH',
  register: '..PATH',
  logout: '..PATH'
}

I want to somehow get the names of the suites and make some use of them, for example putting them in txt file. So the result should be:

test-names.txt

login
register
logout

How can I do it? Thanks.

Upvotes: 0

Views: 39

Answers (1)

Yevhen Laichenkov
Yevhen Laichenkov

Reputation: 8652

It can be easily done with nodejs.

For example, you have the protractor.conf.js file:

exports.config = {
  ...
  suites: {
    login: '..PATH',
    register: '..PATH',
    logout: '..PATH'
  },
  ...
}

Create a new javascript file(e.g. writeSuiteNames.js) or wrap this snippet of code in function and put it somewhere and invoke where you need it:

const fs = require('fs');
const { config: { suites } } = require('./protractor.conf.js')

fs.writeFile("./test-names.txt", `Suites: ${Object.keys(suites)}`, err => {
  if(err) return console.log(err);

  console.log("The file was saved!");
}); 

Then run the node writeSuiteNames.js command.

The test-names.txt file was successfully created and containing the suite names:

Suites: login,register,logout

Upvotes: 2

Related Questions