This project serves as a new test framework for Uyuni, migrating web interaction tests from Capybara+Selenium (Ruby) to Playwright (TypeScript) with CucumberJS as the test runner.
- Node.js: Ensure Node.js is installed on your system.
-
Install Dependencies: Install the necessary libraries using npm:
npm install
-
Configure Environment Variables: Before running any tests, you must edit the
.envfile to configure your environment variables.
testsuite/features/: Contains the Gherkin feature files, which define the high-level test scenarios.testsuite/step_definitions/: Implements the actual test steps in TypeScript, linking them to the feature files.testsuite/helpers/: Provides various utility functions and modules used across the tests, including API clients, configuration, and common actions.config/: Holds configuration files, such ascucumber.cjsfor Cucumber settings.
To execute the tests, use the following commands in your terminal:
npm run cucumber:corenpm run cucumber:init_clientsnpm run cucumber:proxy
These scripts are defined in the scripts section of package.json and provide a convenient way to execute tests for
specific profiles:
npm run cucumber:core: Runs tests defined in thecoreprofile.npm run cucumber:reposync: Runs tests defined in thereposyncprofile.npm run cucumber:init_clients: Runs tests defined in theinit_clientsprofile.npm run cucumber:proxy: Runs tests defined in theproxyprofile.
Each of these commands internally calls npm run cucumber with the --profile flag, specifying which Cucumber profile
to use.
The config/cucumber.cjs file defines various profiles that allow you to run specific subsets of feature files. Each
profile specifies a paths array, which lists the feature files to be executed. The order in which these feature files
are listed in the paths array determines their execution order.
For example, to run the core features, you would use:
npm run cucumber:coreThis command executes the feature files defined in the core profile within config/cucumber.cjs in the order they are
listed.
To customize the test execution order or run a different subset of tests:
-
Modify an existing profile: Edit the
pathsarray within a profile inconfig/cucumber.cjsto change the included feature files or their execution order. -
Create a new profile: Add a new entry to
module.exportsinconfig/cucumber.cjswith a unique name and apathsarray specifying your desired feature files and their order.Example of a new profile:
// A profile for specific sanity checks sanity_checks: { paths: [ "testsuite/features/sanity/a.feature", "testsuite/features/sanity/b.feature", ] // ... other configurations (can inherit from default or other profiles) }
After creating a new profile, you would need to add a corresponding script to
package.jsonto easily run it:
"scripts": {
"cucumber:sanity_checks": "cucumber-js --profile sanity_checks"
}
Then you can run it with:
```bash
npm run cucumber:sanity_checks
```
This approach provides flexibility to define various test stages, which can be integrated into CI/CD pipelines like Jenkins stages.
To add reporting, update the cucumber.cjs configuration file with the format option.
module.exports = {
default: {
// ... other configurations
format: [
"json:reports/cucumber-report.json",
"html:reports/cucumber-report.html"
]
}
};This will generate both JSON and HTML reports, providing a detailed view of your test results.