### Install Qavajs CLI Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/intro.md Initializes a new Node.js project with Qavajs and installs necessary modules. Generates a config file for test execution. ```bash npm init @qavajs@1 ``` -------------------------------- ### Install QavaJS using npm Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/qna.md Installs the QavaJS framework using the npm package manager. This is the primary method for getting started with QavaJS. ```bash npm init @qavajs ``` -------------------------------- ### Service Configuration for Test Execution Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/intro.md Explains how to configure services that execute logic before and after the entire test run. It shows an example of a service with `before` and `after` methods, and how to import external services. It also mentions the default and configurable `serviceTimeout`. ```typescript import externalService from './externalService'; export default { service: [ { options: { data: 42 }, before() { console.log(this.options.data); }, after(result) { if (!result.success) process.exitCode = 1; } }, { options: { data: 42 }, ...externalService } ] } ``` ```typescript export default { serviceTimeout: 1_200_000 } ``` -------------------------------- ### Qavajs Gherkin Test Scenario Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/intro.md Example of a test scenario written in Gherkin, demonstrating interactions with a web page, including using memory variables and locator aliases. ```gherkin Feature: Wikipedia @wikipedia Scenario Outline: Search in wikipedia () Given I open '$wikipediaUrl' url When I type '' to 'Wikipedia > Search Input' And I click 'Wikipedia > Search Button' And I expect text of 'Wikipedia Article > Title' equals '' And I expect text of 'Wikipedia Article > Title' not to contain 'Python' And I expect 'Wikipedia Article > Title' to be visible And I expect 'Wikipedia Article > Title' to be visible Examples: | term | | JavaScript | | Java | ``` -------------------------------- ### Install @qavajs/steps-accessibility-ea Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/accessibility-ea.md Installs the accessibility steps package using npm. This is the initial setup required before configuration. ```bash npm install @qavajs/steps-accessibility-ea ``` -------------------------------- ### Test Execution Hooks: BeforeExecution and AfterExecution Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/intro.md Demonstrates the use of `BeforeExecution` and `AfterExecution` from `@qavajs/core` to define functions that run once before and after the entire test suite execution, respectively. These are useful for global setup and teardown tasks. ```typescript import { BeforeExecution, AfterExecution } from '@qavajs/core'; import { Server } from './server'; const server = new Server(); BeforeExecution(async function () { await server.start(); }); AfterExecution(async function () { await server.stop(); }); ``` -------------------------------- ### Install @qavajs/steps-sql Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/sql.md Installs the @qavajs/steps-sql package version 1 using npm. ```bash npm install @qavajs/steps-sql@1 ``` -------------------------------- ### Run Qavajs Tests Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/intro.md Commands to execute Qavajs tests. Allows specifying a custom config file, a profile within the config, overriding memory values, and sharding tests across multiple machines. ```bash npx qavajs npx qavajs run --config config.ts npx qavajs run --profile npx qavajs run --config config.ts --memory-values '{"url": "https://github.com"}' npx qavajs run --config config.js --shard 1/2 npx qavajs run --config config.js --shard 2/2 ``` -------------------------------- ### Define Fixtures for Test Environment Setup Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/intro.md Demonstrates how to use the `Fixture` function from `@qavajs/core` to set up the test environment before a test and clean up after it. Fixtures can return a cleanup function that executes after the test. ```typescript import { Fixture } from '@qavajs/core'; Fixture('pdp', async function() { await this.playwright.page.goto('https://my-site/pdp'); // fixture may return function that will be executed after test return async function() { await this.playwright.page.request.get('/cleanCart'); } }); ``` -------------------------------- ### Install @qavajs/steps-wdio Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/wdio.md Installs the @qavajs/steps-wdio package version 1 using npm. ```bash npm install @qavajs/steps-wdio@1 ``` -------------------------------- ### Execute Qavajs Tests Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/intro.md Commands to execute Qavajs tests. The first command runs tests with the default configuration, while the subsequent commands allow specifying a custom config file or profile. ```bash npx qavajs ``` ```bash npx qavajs run --config ``` ```bash npx qavajs run --profile ``` -------------------------------- ### Install @qavajs/steps-api v1 Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/api.md Install the @qavajs/steps-api version 1 package using npm. ```bash npm install @qavajs/steps-api@1 ``` -------------------------------- ### Service Configuration with TypeScript Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/intro.md Illustrates how to configure services in Qavajs to execute logic before and after a test run. Services can include custom logic or import external service configurations. ```typescript import externalService from './externalService'; export default { service: [ { options: { data: 42 }, before() { console.log(this.options.data); }, after(result) { if (!result.success) process.exitCode = 1; } }, { options: { data: 42 }, ...externalService } ] } ``` -------------------------------- ### Install @qavajs/steps-lighthouse Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/lighthouse.md Installs the @qavajs/steps-lighthouse library, version 0.1, using npm. ```bash npm install @qavajs/steps-lighthouse@0.1 ``` -------------------------------- ### Install @qavajs/steps-visual-testing Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/visual-testing.md Installs the @qavajs/steps-visual-testing package using npm. ```bash npm install @qavajs/steps-visual-testing ``` -------------------------------- ### Install @qavajs/steps-wdio Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/wdio.md Command to install the @qavajs/steps-wdio package using npm. ```bash npm install @qavajs/steps-wdio ``` -------------------------------- ### Install @qavajs/steps-sql Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/sql.md Installs the @qavajs/steps-sql package using npm. This is the initial step to integrate the library into your project. ```bash npm install @qavajs/steps-sql ``` -------------------------------- ### Install Cypress Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/StandaloneSolutions/cypress.md Installs the Cypress test runner, a prerequisite for using @qavajs/cypress. ```bash npm install cypress ``` -------------------------------- ### Install @qavajs/steps-visual-testing Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/visual-testing.md Installs the QAVajs visual testing step library using npm. It is recommended to install version 1. ```bash npm install @qavajs/steps-visual-testing@1 ``` -------------------------------- ### Start Local Development Server with npm Source: https://github.com/qavajs/qavajs.github.io/blob/main/README.md Starts a local development server for the QavaJS website. Changes are reflected live without needing to restart the server. ```bash npm run start ``` -------------------------------- ### Install @qavajs/steps-memory Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/memory.md Installs the @qavajs/steps-memory package version 1 using npm. ```bash npm install @qavajs/steps-memory@1 ``` -------------------------------- ### Install @qavajs/steps-files Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/files.md Installs the @qavajs/steps-files package using npm. ```bash npm install @qavajs/steps-files ``` -------------------------------- ### Install @qavajs/steps-files Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/files.md Installs the specified version of the @qavajs/steps-files package using npm. ```bash npm install @qavajs/steps-files@1 ``` -------------------------------- ### Install @qavajs/steps-playwright Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/playwright.md Installs the @qavajs/steps-playwright library version 2 using npm. ```bash npm install @qavajs/steps-playwright@2 ``` -------------------------------- ### Install @qavajs/steps-playwright Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/playwright.md Installs version 1 of the @qavajs/steps-playwright package using npm. ```bash npm install @qavajs/steps-playwright@1 ``` -------------------------------- ### Configure Playwright Steps Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/playwright.md Example configuration for Playwright steps, including require paths, browser timeouts, capabilities, and page object instantiation. This setup is essential for initializing the Playwright environment within the QavaJS framework. ```typescript import App from './page_object'; export default { require: [ 'node_modules/@qavajs/steps-playwright/index.js' ], browser: { timeout: { present: 10000, visible: 20000, page: 10000, value: 5000, // expect value timeout valueInterval: 500 //expect value interval }, capabilities: { browserName: 'chromium' } }, pageObject: new App() } ``` -------------------------------- ### Qavajs Soft Assertions Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/intro.md Demonstrates the use of soft assertions in Qavajs by prefixing `expect` with `softly`. This allows test execution to continue even if an assertion fails. ```gherkin Feature: Feature Scenario: verify soft assert # first step fails, but other steps will not be skipped Then I expect '2' to softly equal '1' # pass And I expect '1' to softly equal '1' # fail And I expect '2' to softly equal '1' # skip And I expect '1' to softly equal '1' ``` -------------------------------- ### Execute Qavajs Steps Programmatically Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/intro.md Demonstrates how to use the `executeStep` method within a custom Cucumber step definition to run predefined Qavajs steps, including steps that accept data tables. ```typescript When('I do smth complex', async function() { await this.executeStep(`I type 'username' to 'Username Input'`); await this.executeStep(`I type 'password' to 'Password Input'`); await this.executeStep(`I click 'Login Button'`); await this.executeStep(`I fill following fields`, new DataTable([ [ 'Order', '123' ], [ 'Delivery Location', 'New York' ] ])) }); ``` -------------------------------- ### Install @qavajs/steps-accessibility Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/accessibility.md Installs the @qavajs/steps-accessibility package version 1 using npm. ```bash npm install @qavajs/steps-accessibility@1 ``` -------------------------------- ### Install @qavajs/console-formatter Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Formatters/console-formatter.md Installs the @qavajs/console-formatter package using npm. This is the primary step to integrate the formatter into your project. ```bash npm install @qavajs/console-formatter ``` -------------------------------- ### Install @qavajs/html-formatter Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Formatters/html-formatter.md Installs the @qavajs/html-formatter package using npm. This is the first step to integrate the HTML formatter into your project. ```bash npm install @qavajs/html-formatter ``` -------------------------------- ### Install Qavajs Cypress Packages Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/StandaloneSolutions/cypress.md Installs the core @qavajs/cypress package along with the runner adapter and memory module. ```bash npm install @qavajs/cypress @qavajs/cypress-runner-adapter @qavajs/memory ``` -------------------------------- ### Install @qavajs/steps-lighthouse with npm Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/lighthouse.md Installs the @qavajs/steps-lighthouse package using npm. This is the first step to integrate Lighthouse auditing capabilities into your project. ```bash npm install @qavajs/steps-lighthouse ``` -------------------------------- ### Install @qavs/steps-api using npm Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/api.md Installs the @qavs/steps-api package via npm. This is the primary method for adding the library to a project. ```bash npm install @qavajs/steps-api ``` -------------------------------- ### Install Project Dependencies with npm Source: https://github.com/qavajs/qavajs.github.io/blob/main/README.md Installs all necessary project dependencies using npm. This is a prerequisite for local development and building. ```bash npm install ``` -------------------------------- ### Setting Custom Service Timeout with TypeScript Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/intro.md Shows how to set a custom timeout for service execution in milliseconds by using the `serviceTimeout` property in the configuration. ```typescript export default { serviceTimeout: 1_200_000 } ``` -------------------------------- ### Override Memory Values via CLI Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/intro.md Demonstrates how to override memory variable values at runtime using the `--memory-values` command-line argument. This is useful for running tests with different configurations, such as different URLs. ```bash npx qavajs run --config config.ts --memory-values '{"url": "https://github.com"}' ``` -------------------------------- ### Install @qavajs/steps-gmail Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/gmail.md Installs the @qavajs/steps-gmail package version 1 using npm. This is the initial step to integrate Gmail testing capabilities into a project. ```bash npm install @qavajs/steps-gmail@1 ``` -------------------------------- ### Install @qavajs/steps-memory Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/memory.md Installs the @qavajs/steps-memory package using npm. This is the initial step to include the memory module in your project. ```bash npm install @qavajs/steps-memory ``` -------------------------------- ### Install @qavajs/format-report-portal with npm Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Formatters/report-portal.md This command installs the @qavajs/format-report-portal package using npm, making it available for use in your project. ```bash npm install @qavajs/format-report-portal ``` -------------------------------- ### Install @qavajs/steps-gmail Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/gmail.md Installs the @qavajs/steps-gmail package using npm. This is the first step to integrate Gmail testing capabilities into your project. ```bash npm install @qavajs/steps-gmail ``` -------------------------------- ### Qavajs Memory Value API Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/intro.md Illustrates how to interact with Qavajs memory values within step definitions. The `{value}` parameter type allows reading and setting memory variables. ```typescript When('Read memory {value}', async function(memoryValue) { expect(memoryValue.value()).to.equal('ts'); }); When('Set memory {value} as {string}', async function(memoryKey, value) { memoryKey.set(value); }); ``` -------------------------------- ### Install @qavajs/template Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Modules/template.md Installs the @qavajs/template module using npm. This is the first step to integrate template functionality into your project. ```shell npm install @qavajs/template ``` -------------------------------- ### Jenkinsfile Declarative Pipeline for qavajs Tests Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Guides/cicd.md A complete Jenkinsfile using declarative pipeline syntax to automate the execution of qavajs tests. It defines stages for checkout, dependency installation, environment setup (including Chrome), test execution, and result publishing. This pipeline utilizes Docker for the agent environment. ```groovy pipeline { agent { docker { image 'node:22' args '-v /tmp:/tmp' } } environment { } stages { stage('Checkout') { steps { checkout scm } } stage('Install Dependencies') { steps { script { sh 'npm install' } } } stage('Install Chrome (if needed)') { steps { script { sh ''' apt-get update && apt-get install -y \ wget \ gnupg \ apt-transport-https \ ca-certificates && \ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \ apt-get update && \ apt-get install -y google-chrome-stable ''' } } } stage('Run qavajs Tests') { steps { script { sh 'npm test' } } } stage('Publish Test Results') { steps { script { junit '**/junit-report.xml' } archiveArtifacts artifacts: 'reports/**/*', fingerprint: true } } } post { always { script { echo 'Cleaning up workspace...' } } success { echo 'qavajs tests completed successfully!' } failure { echo 'qavajs tests failed!' } } } ``` -------------------------------- ### Override Step Definition with TypeScript Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/intro.md Demonstrates how to override a step definition using the `Override` function from `@qavajs/core`. This is useful for modifying existing step implementations. ```typescript import { Override } from '@qavajs/core'; When('I do test', async function () {}); Override('I do test', async function () { console.log('I am overridden'); }); ``` -------------------------------- ### Install @qavajs/playwright Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/StandaloneSolutions/playwright.md Installs the @qavajs/playwright package using npm. This is a prerequisite for using qavajs with playwright. ```shell npm init playwright npm install @qavajs/playwright ``` -------------------------------- ### Install @qavajs/soft-assertion Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Modules/soft-assertion.md Installs the soft assertion module for Qavajs using npm. This is the initial step to enable soft assertions in your project. ```bash npm install @qavajs/soft-assertion ``` -------------------------------- ### Qavajs Validation API Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/intro.md Shows how to use the `{validation}` parameter type in Qavajs step definitions for asserting conditions between values. The `validate` function executes the specified check. ```typescript When('I expect {string} {validation} {string}', async function(value1, validate, value2) { validate(value1, value2); }); ``` -------------------------------- ### Install @qavajs/steps-accessibility Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/accessibility.md Installs the @qavajs/steps-accessibility package using npm. This is the initial step to include accessibility testing capabilities in your QAF JS project. ```bash npm install @qavajs/steps-accessibility ``` -------------------------------- ### Gherkin Feature File Example Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/writing-tests.md Example of a Gherkin feature file demonstrating a Wikipedia search scenario. It outlines 'Given', 'When', 'Then', and 'And' steps to interact with a web page and validate results. ```gherkin Feature: Wikipedia Search Functionality As a user I want to search for content on Wikipedia So that I can find information quickly Scenario: Search for JavaScript documentation Given I open '$wikipedia' url When I type 'JavaScript' to 'Search Input' And I click 'Search Button' Then I expect text of 'Title' equals 'JavaScript' And I expect text of 'Content' contains 'JavaScript is a programming language' Scenario: Search with non-existent term Given I open '$wikipedia' url When I type 'NonExistentTerm123XYZ' to 'Search Input' And I click 'Search Button' Then I expect 'No Results Message' to be visible ``` -------------------------------- ### Install @qavajs/xray-formatter Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Formatters/xray-formatter.md Command to install the xray formatter package using npm. This is the initial step before configuring it in your project. ```bash npm install @qavajs/xray-formatter ``` -------------------------------- ### QavaJS Gherkin Feature File Example Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Guides/page-object.mdx An example feature file demonstrating behavior-driven development with QavaJS. It outlines a user scenario for searching products and adding them to the cart, using Gherkin syntax. ```gherkin Feature: E-commerce Website Scenario: Search for and add product to cart Given I open 'https://example-shop.com' url When I type 'wireless headphones' to 'Header > Search Bar' And I click 'Header > Search Button' # Filter results When I click 'Main > Category Filter (Electronics)' And I select 'Price: Low to High' option from 'Main > Sort Dropdown' dropdown # Add second product to cart When I click 'Main > Product Cards > Add To Cart Button (2)' # Go to cart When I click 'Header > Navigation Item (Cart)' Then I expect number of elements in 'Main > Cart Items' collection to equal '1' And I expect text of 'Main > Cart Total' contains '$' # Checkout When I click 'Main > Checkout Button' ``` -------------------------------- ### GitHub Actions Workflow for qavajs Tests Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Guides/cicd.md A GitHub Actions workflow to automate the execution of qavajs tests. It includes steps for checking out code, setting up Node.js, installing dependencies, installing Google Chrome for UI testing, running the tests, and uploading test results. ```yaml name: qavajs E2E Tests on: workflow-dispatch: jobs: run-qavajs-tests: runs-on: ubuntu-latest # Or windows-latest, macos-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: '22' # Use your preferred Node.js version - name: Install dependencies run: npm install - name: Install Google Chrome (for UI tests) run: | sudo apt-get update sudo apt-get install -y google-chrome-stable - name: Run qavajs tests run: npm test # Or whatever script you define in package.json to run your qavajs tests env: # Example of setting environment variables # BASE_URL: ${{ secrets.BASE_URL }} # Some other variable: 'value' - name: Upload test results (e.g., JUnit XML) if: always() # Run this step even if previous steps fail uses: actions/upload-artifact@v4 with: name: qavajs-test-results path: ./reports/junit-report.xml # Adjust path to your generated report ``` -------------------------------- ### Configure WebDriverIO with @qavajs/steps-wdio Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/wdio.md Configuration object for WebDriverIO, specifying timeouts, capabilities, and page object instances. This setup is crucial for integrating the QavaJS steps library with your WebDriverIO project. ```typescript import App from './page_object'; export default { require: [ 'node_modules/@qavajs/steps-wdio/index.js' ], browser: { timeout: { present: 10000, visible: 20000, clickable: 15000, page: 10000, implicit: 0, //wdio implicit wait for element, element: 2000 ,//timeout to element to be accesible, value: 5000, // expect value timeout valueInterval: 500 //expect value interval }, capabilities: { browserName: 'chrome' } }, pageObject: new App() } ``` -------------------------------- ### WDIO Service Integration with Parameters using Qavajs Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Guides/wdio-adapter.md Illustrates how to use the wdioAdapter with a service that requires parameters, such as the appium-service. This example shows how to pass an object with arguments, including a specific chromedriver executable path, to the service configuration. ```javascript const wdioService = require('@qavajs/wdio-service-adapter'); module.exports = { default: { service: [ wdioService([ '@wdio/appium-service', { args: { chromedriverExecutable: resolve('node_modules/chromedriver/lib/chromedriver/chromedriver.exe') } } ]) ], } } ``` -------------------------------- ### Install Webstorm Adapter for Qavajs Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Guides/webstorm.md Installs the necessary adapter package to integrate Qavajs with the Webstorm IDE's cucumberjs plugin. This is the first step in setting up the integration. ```bash npm install @qavajs/webstorm-adapter ``` -------------------------------- ### Integrate WDIO Selenium Standalone Service with qavajs Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Guides/wdio-adapter.md Demonstrates the basic integration of the WDIO selenium-standalone-service using the qavajs adapter. This setup is common for running tests with Selenium WebDriver. ```typescript import wdioService from '@qavajs/wdio-service-adapter'; export default { service: [ wdioService('@wdio/selenium-standalone-service') ], } ``` -------------------------------- ### JavaScript: Defining constants and computed values Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Guides/memory.md Provides examples of setting constant values and computed values (JavaScript function references) that can be used in feature files. ```javascript module.exports = { constant: 42, computed: function() { return Date.now() } }; ``` -------------------------------- ### Install qavajs with Playwright dependencies Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/StandaloneSolutions/playwright.md Installs the necessary packages for qavajs to work with Playwright, including the cucumber adapter and memory management. ```shell npm init playwright npm install @cucumber/cucumber @qavajs/playwright @qavajs/playwright-runner-adapter @qavajs/memory ``` -------------------------------- ### GitLab CI/CD Configuration for qavajs Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Guides/cicd.md A .gitlab-ci.yml file to configure GitLab CI/CD for running qavajs tests. It defines stages, uses a Node.js Docker image, installs dependencies and Chrome, executes tests, and specifies artifacts for reports. ```yaml stages: - test variables: # Example of setting global environment variables # BASE_URL: "http://your-app.com" test_qavajs: stage: test image: node:22 # Use a Node.js image before_script: - apt-get update && apt-get install -y google-chrome-stable # Install Chrome if needed - npm install script: - npm test # Your qavajs test command artifacts: when: always reports: junit: "**/junit-report.xml" # Path to your JUnit report paths: - reports/ # Path to your reports directory (e.g., HTML reports) ``` -------------------------------- ### Configure Xray Formatter for Jira Server Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Formatters/xray-formatter.md Configuration example for using the xray formatter with Jira Server. It includes the endpoint, personal access key, test execution key, and an optional tag regular expression. ```javascript export default { format: ['@qavajs/xray-formatter:report/xray.out'], formatOptions: { xray: { endpoint: 'https://your.jira.instance/jira', //jira api endpoint client_secret: 'client_secret', // personal access key from jira instance testExecutionKey: 'ABC-12', // test execution jira key to send result tagRegexp: 'TEST_(.+)' // optional, parse tag regexp } } } ``` -------------------------------- ### Send API Request (GET) Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/api.md Send a GET request to a specified URL and save the response. This step is fundamental for interacting with API endpoints. ```gherkin When I send "GET" request to "$BASE_API_URL" and save response as "response" ``` -------------------------------- ### Example Gherkin Usage of Distributed Users Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Guides/parallel.md Shows how to reference distributed user credentials (username and password) within Gherkin scripts using the '$user.username' and '$user.password' syntax. ```gherkin Feature: Parallel Scenario: Verify that user is able to login When I type '$user.username' to 'Username Input' And I type '$user.password' to 'Password Input' ``` -------------------------------- ### Configure Xray Formatter for Xray Cloud Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Formatters/xray-formatter.md Configuration example for using the xray formatter with Xray Cloud. It specifies the formatter path and options like client ID, client secret, and test execution key. ```javascript export default { format: ['@qavajs/xray-formatter:report/xray.out'], formatOptions: { xray: { client_id: 'client_id', // generated client_id from xray cloud client_secret: 'client_secret', // generated client_id from xray client_secret testExecutionKey: 'ABC-12', // test execution jira key to send result tagRegexp: 'TEST_(.+)' // optional, parse tag regexp. default /@(.+-\d+)/ } } } ``` -------------------------------- ### Send API Request with Headers (GET) Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/api.md Send a GET request to a specified URL with custom headers and save the response. This allows for authenticated or customized requests. ```gherkin When I send "GET" request to "$BASE_API_URL" with headers "$headers" and save response as "response" ``` -------------------------------- ### Send API Request with Headers and Query String (GET) Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/api.md Send a GET request to a specified URL with both custom headers and query string parameters, saving the response. This combines customization and filtering capabilities. ```gherkin When I send "GET" request to "$BASE_API_URL" with headers "$headers" with qs "?category=HR&name=test" and save response as "response" ``` -------------------------------- ### Send API Request with Query String (GET) Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/api.md Send a GET request to a specified URL with query string parameters and save the response. This is useful for filtering or specifying request parameters. ```gherkin When I send "GET" request to "$BASE_API_URL" with qs "?category=HR&name=test" and save response as "response" ``` -------------------------------- ### Execute Complex Logic with executeStep (JavaScript) Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Guides/composing-steps.mdx Demonstrates using the `executeStep` world method in JavaScript to programmatically call multiple Gherkin steps within a single step. It includes examples of typing text, clicking buttons, and filling data tables. ```javascript const { When, DataTable } = require('@qavajs/core'); When('I do smth complex', async function() { await this.executeStep(`I type 'username' to 'Username Input'`); await this.executeStep(`I type 'password' to 'Password Input'`); await this.executeStep(`I click 'Login Button'`); await this.executeStep(`I fill following fields`, new DataTable([ [ 'Order', '123' ], [ 'Delivery Location', 'New York' ] ])); }); ``` -------------------------------- ### Azure DevOps Pipeline for qavajs Tests Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Guides/cicd.md An Azure DevOps pipeline configuration to run qavajs tests. It specifies the agent image, installs Node.js, installs dependencies, sets up Google Chrome on Linux agents, executes the tests, and publishes test results and artifacts. ```yaml trigger: - main - develop pool: vmImage: 'ubuntu-latest' # Or 'windows-latest', 'macOS-latest' steps: - task: NodeTool@0 inputs: versionSpec: '22.x' # Use your preferred Node.js version displayName: 'Install Node.js' - script: | npm install displayName: 'Install Dependencies' - script: | sudo apt-get update sudo apt-get install -y google-chrome-stable displayName: 'Install Google Chrome' condition: eq(variables['Agent.OS'], 'Linux') # Only run on Linux agents - script: | npm test # Or your qavajs test command displayName: 'Run qavajs Tests' env: # Example of setting environment variables # BASE_URL: $(BASE_URL) # Use pipeline variables or variable groups # Some other variable: 'value' - task: PublishTestResults@2 inputs: testResultsFormat: 'JUnit' testResultsFiles: '**/junit-report.xml' # Adjust path to your generated report mergeResults: true failTaskOnFailedTests: true # Fail the pipeline if tests fail displayName: 'Publish Test Results' - task: PublishBuildArtifacts@1 inputs: pathToPublish: 'reports' # Path to your reports directory artifactName: 'qavajsTestReports' displayName: 'Publish qavajs Reports' ``` -------------------------------- ### Execute Complex Logic with executeStep (TypeScript) Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Guides/composing-steps.mdx Shows how to use the `executeStep` world method in TypeScript to chain multiple Gherkin steps. This example illustrates calling text input, button click, and data table filling steps programmatically, with type safety. ```typescript import { IQavajsWorld, When, DataTable } from '@qavajs/core'; When('I do smth complex', async function(this: IQavajsWorld) { await this.executeStep(`I type 'username' to 'Username Input'`); await this.executeStep(`I type 'password' to 'Password Input'`); await this.executeStep(`I click 'Login Button'`); await this.executeStep(`I fill following fields`, new DataTable([ [ 'Order', '123' ], [ 'Delivery Location', 'New York' ] ])); }); ``` -------------------------------- ### Migrate Global Variable Access to v2 'this' Context Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/v2.md This snippet illustrates the migration of global variable access in v1 to the `this` context in v2. Examples include `global.config` to `this.config`, and specific WebDriverIO and Playwright browser/context/page accesses. ```JavaScript ```javascript // v1 global.config; global.browser; // wdio global.driver; // wdio global.browser; // playwright global.context; // playwright global.page; // playwright // v2 this.config; this.wdio.browser; this.wdio.driver; this.playwright.browser; this.playwright.context; this.playwright.page; ``` ``` -------------------------------- ### Custom XML Parsing Logic Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Steps/api.md Provides an example of a custom parser function for XML data using the 'fast-xml-parser' library. This function takes a response, converts it to text, and then parses it into a JavaScript object. ```typescript import { XMLParser } from 'fast-xml-parser'; const xml = new XMLParser(); class Data { soap = async (response: Response) => { const text = await response.text(); return xml.parse(text); } } ``` -------------------------------- ### Create Page Objects with Locators (TypeScript) Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Guides/page-object.mdx Provides an example of defining page objects in TypeScript using qavajs locators. Covers various locator strategies including nested and repeated components. ```typescript import { locator } from '@qavajs/steps-playwright/po'; // Use '@qavajs/steps-wdio/po' for WebdriverIO class App { // Simple CSS selector SimpleLocator = locator('.single-element'); // XPath selector XPathElement = locator('xpath=//div[@class='example']'); // Nested component Header = locator('.header-container').as(HeaderComponent); // Component with multiple instances ProductCards = locator('.product-card').as(ProductCard); } class HeaderComponent { Logo = locator('.logo'); SearchBar = locator('input.search'); UserMenu = locator('.user-menu'); } class ProductCard { Title = locator('.product-title'); Price = locator('.product-price'); AddToCartButton = locator('button.add-to-cart'); } export default App; ``` -------------------------------- ### Configure MySQL and PostgreSQL Clients Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/sql.md Sets up default database clients for MySQL and PostgreSQL within the QavaJS configuration. It specifies the path to the SQL steps and provides connection details for each client. ```javascript const { MySQLClient, PgClient } = require('@qavajs/steps-sql/clients'); module.exports = { default: { require: [ 'node_modules/@qavajs/steps-sql/index.js' ], dbClients: { default: new MySQLClient({ host: 'http://127.0.0.1', port: 3306, database: 'qavajsdb', user: 'username', password: 'password' }), pg: new PgClient({ host: 'http://127.0.0.1', port: 3307, database: 'qavajsdb2', username: 'username', password: 'password' }), } } } ``` -------------------------------- ### TypeScript: Custom predicate example Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Guides/validation.mdx Provides a TypeScript implementation for the 'either' predicate used in the 'satisfy' validation, demonstrating how to create custom validation logic. ```typescript function either(...expected) { return function (actual) { return expected.includes(actual) } } ``` -------------------------------- ### Direct Memory Access in Custom Steps (JavaScript) Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/Guides/memory.mdx Provides an example of accessing the memory object directly within custom JavaScript step definitions to save and retrieve values using `setValue` and `getValue`. ```javascript const memory = require('@qavajs/memory'); When(/^I save value '(.+)' as '(.+)'$/, async function (value, key) { memory.setValue(key, value); }); Then(/^value in '(.+)' should equal '(.+)'$/, async function (variable, expectedValue) { const actualValue = memory.getValue(variable); expect(actualValue).to.equal(expectedValue); }); ``` -------------------------------- ### Configure @qavajs/steps-api Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/api.md Configure the project to use the @qavajs/steps-api library by specifying the require path in the configuration file. ```javascript module.exports = { default: { require: [ 'node_modules/@qavajs/steps-api/index.js' ] } } ``` -------------------------------- ### Basic Template Usage in Gherkin Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Modules/template.md Demonstrates a basic template usage in Gherkin, where a scenario 'I login' calls predefined steps like opening a URL and typing into input fields. ```gherkin Feature: Templates Scenario: I login When I open 'https://your-app.com' And I type 'username' to 'Login Form > Username Input' And I type 'password' to 'Login Form > Password Input' And I click 'Login Form > Login Button' ``` -------------------------------- ### Build Static Website Content with npm Source: https://github.com/qavajs/qavajs.github.io/blob/main/README.md Generates the static content for the QavaJS website into the 'build' directory. This output can be hosted on any static content hosting service. ```bash npm run build ``` -------------------------------- ### Configure WebdriverIO Steps Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/wdio.md Sets up the default configuration for @qavajs/steps-wdio, including WebdriverIO timeouts, capabilities, and page object instantiation. It also specifies the path to the step definitions. ```javascript const App = require('./page_object'); module.exports = { default: { require: [ 'node_modules/@qavajs/steps-wdio/index.js' ], browser: { timeout: { present: 10000, visible: 20000, clickable: 15000, page: 10000, implicit: 0, //wdio implicit wait for element, element: 2000 ,//timeout to element to be accesible, value: 5000, // expect value timeout valueInterval: 500 //expect value interval }, capabilities: { browserName: 'chrome' } }, pageObject: new App() } } ``` -------------------------------- ### Request Construction API Steps Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/api.md Steps for constructing and preparing API requests, including creating requests, adding headers, body, and URLs. ```APIDOC ## Request Construction ### Create Request **Description**: Creates a new API request and saves it in memory with a specified key. **Method**: N/A (This is a Gherkin step definition) **Endpoint**: N/A #### Parameters * **method** (string) - Required - The HTTP method for the request (e.g., 'GET', 'POST'). * **requestKey** (string) - Required - The key to save the request in memory. ### Request Example ```gherkin When I create 'GET' request 'request' ``` ### Add Headers to Request (Data Table) **Description**: Adds a set of headers to a request using a data table. **Method**: N/A (This is a Gherkin step definition) **Endpoint**: N/A #### Parameters * **requestKey** (string) - Required - The key of the request to add headers to. * **headersDataTable** (DataTable) - Required - A data table containing header key-value pairs. ### Request Example ```gherkin When I create 'GET' request 'request' And I add headers to '$request': | Content-Type | application/json | ``` ### Add Headers to Request (Key) **Description**: Adds headers to a request, where the headers are stored in memory with a specific key. **Method**: N/A (This is a Gherkin step definition) **Endpoint**: N/A #### Parameters * **requestKey** (string) - Required - The key of the request to add headers to. * **headersKey** (string) - Required - The memory key of the headers (resolves to a JS object). ### Request Example ```gherkin When I create 'GET' request 'request' And I add '$headers' headers to '$request' ``` ### Add Body to Request (Multiline) **Description**: Adds a request body to a request, provided as a multiline string. **Method**: N/A (This is a Gherkin step definition) **Endpoint**: N/A #### Parameters * **requestKey** (string) - Required - The key of the request to add the body to. * **body** (string - Multiline) - Required - The request body content. ### Request Example ```gherkin When I create 'GET' request 'request' And I add body to '$request': """ { "message": "qavajs" } """ ``` ### Add Body to Request (Key) **Description**: Adds a request body to a request, where the body content is stored in memory with a specific key. **Method**: N/A (This is a Gherkin step definition) **Endpoint**: N/A #### Parameters * **requestKey** (string) - Required - The key of the request to add the body to. * **body** (string) - Required - The memory key of the request body. ### Request Example ```gherkin When I create 'GET' request 'request' And I add '$body' body to '$request' ``` ### Add URL to Request **Description**: Adds a URL to a request. **Method**: N/A (This is a Gherkin step definition) **Endpoint**: N/A #### Parameters * **requestKey** (string) - Required - The key of the request to add the URL to. * **url** (string) - Required - The URL to add. ### Request Example ```gherkin When I create 'GET' request 'request' And I add 'https://qavajs.github.io/' url to '$request' ``` ### Send Request and Save Response **Description**: Sends a prepared API request and saves the response in memory with a specified key. **Method**: N/A (This is a Gherkin step definition) **Endpoint**: N/A #### Parameters * **requestKey** (string) - Required - The memory key of the request to send. * **responseKey** (string) - Required - The memory key to save the response. ### Request Example ```gherkin When I create 'GET' request 'request' And I add 'https://qavajs.github.io/' url to '$request' And I send '$request' request and save response as 'response' ``` ``` -------------------------------- ### qavajs CLI Commands Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-2x/writing-tests.md Command-line interface commands for running qavajs tests. Includes options for running all tests, specific features, or tests with specific tags. ```bash # Run all tests npx qavajs run # Run specific feature npx qavajs run --feature features/wikipedia.feature # Run with specific tags npx qavajs run --tags @smoke ``` -------------------------------- ### Template with Parameterized Steps Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Modules/template.md Shows how templates can accept parameters, illustrated by a 'login as' template that takes '' and '' as dynamic inputs. ```gherkin Feature: Templates Scenario: I login as '' with '' password When I open 'https://your-app.com' And I type '' to 'Login Form > Username Input' And I type '' to 'Login Form > Password Input' And I click 'Login Form > Login Button' ``` -------------------------------- ### Configure Snapshots Source: https://github.com/qavajs/qavajs.github.io/blob/main/versioned_docs/version-1x/Steps/wdio.md Configures @qavajs/steps-wdio to take snapshots on specific events like 'onFail', 'beforeStep', or 'afterStep'. ```javascript module.exports = { default: { browser: { snapshot: ['onFail'] } } } ```