We need the ability to run a dynamic set of spec files.
// Would be ideal, but not working
exports.config = {
specs: () => {
/* Load list of tests to bu run from API or from CSV file
},
......
}
Any ideas would be appreciated.
We need the ability to run a dynamic set of spec files.
// Would be ideal, but not working
exports.config = {
specs: () => {
/* Load list of tests to bu run from API or from CSV file
},
......
}
Any ideas would be appreciated.
I'll answer this for JavaScript, not TS, but it'll give you an idea about your options
If you're looking to use test suites predefined somewhere, then 2 ways:
In your config, do something like this
exports.config = {
// ...
specs: function (option) {
let suites = require("./suites.json");
return suites[option]
}(process.env.SUITE)
// ...
};
Then have your suites.json
{
"providers": [
"tests/providers/*.spec.js"
],
"users": [
"tests/users/*.spec.js"
],
"production": [
"tests/*/expected-configs.spec.js",
"tests/*/environment-configuration.spec.js",
"tests/*/last-claim-filter.spec.js",
"tests/*/diagnosis-bh-filter.spec.js"
],
"sanity": [
"tests/*/expected-configs.spec.js",
"tests/*/environment-configuration.spec.js",
"tests/*/info-panel.spec.js",
"tests/*/robohelp.spec.js"
]
}
And then start protractor like this SUITE="production" protractor protractor.conf.js
(maybe different for Windows)
Unfortunately, you can't use CSV with this approach, and it doesn't even sound feasible. By the way, I also didn't understand what you mean about starting protractor from API
This is a difficult set up, so I can't give you ready-to-use answer, but this sounds like thats what you need
Grunt is a task runner. What you'd need to do is to configure a task which will be:
This might be tricky, but you can try to use getMultiCapabilities
configuration method:
https://github.com/angular/protractor/blob/master/lib/config.ts#L383
Idea is - your capabilities object can have specs
property:
specs?: string[];
It will add specs to your specs in config, but it can be used to dynamically set them. Also you might use exclude?: string[];
to dynamically exclude some test files from run.
so code might look something like this:
exports.config = {
specs: [] // just empty, we will override it in capabilities
// If getMultiCapabilities is specified, both capabilities and multiCapabilities will be ignored
getMultiCapabilities: async function () {
// For example reading specs from HTTP response
const request = require('request-promise-native')
const specsFromAPI = await request.get('http://some.api/specs')
// should return array of Capabilities objects
return [{
browserName: 'chrome',
specs: specsFromAPI
}]
}
}