I will tackle this question specifically for JavaScript, rather than TypeScript. This should give you a good understanding of the options available to you.
If you are interested in using pre-defined test suites, there are two main approaches:
1. Protractor
To set this up, modify your configuration file as shown below:
exports.config = {
// ...
specs: function (option) {
let suites = require("./suites.json");
return suites[option]
}(process.env.SUITE)
// ...
};
You will also need to create a suites.json
file with the following structure:
{
"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"
]
}
To run Protractor with a specific suite, use the command
SUITE="production" protractor protractor.conf.js
(may be different on Windows).
Unfortunately, CSV files cannot be used with this method, and it may not be practical. Additionally, I am unsure about starting Protractor from an API, as you mentioned.
2. Grunt
Setting this up can be complex, so there is no one-size-fits-all solution. However, it seems like this could meet your needs.
Grunt is a task runner. You would need to configure a task that involves:
- Accepting parameters from the command line;
- Cleaning up temporary files;
- Converting CSV files into JSON in a temporary folder;
- Generating additional files based on parameters, such as config files;
- Finding the desired test suite based on the provided parameter and passing it to Protractor before execution begins;
- Initiating Protractor.