Skip to content

Instantly share code, notes, and snippets.

@imshaiknasir
Created December 25, 2024 10:13
Show Gist options
  • Save imshaiknasir/d64bba213b806b5ce338c18e8e47c9f5 to your computer and use it in GitHub Desktop.
Save imshaiknasir/d64bba213b806b5ce338c18e8e47c9f5 to your computer and use it in GitHub Desktop.
allure command is not recognized, meaning the Allure CLI is not installed or not added to the system PATH. Here’s how to resolve this issue:

Steps to Fix

  1. Install Allure CLI
    • If you haven’t already installed the Allure CLI, you need to do so. You can install it using Node.js or manually:

      • Using Node.js:

        npm install -g allure-commandline --save-dev

        This installs Allure globally and adds it to your PATH.

      • Manual Installation:

        • Download the Allure CLI from the official Allure website.
        • Extract the downloaded file and add the bin folder to your system PATH.
    • To verify the installation, run:

      allure --version

      If it outputs the Allure version, the installation is successful.


  1. Verify Allure Results Directory
    • Ensure the ./allure-results directory exists in your project. This directory is where Playwright or your test runner stores the results for Allure to generate a report.

    • If the directory doesn’t exist, ensure you’re generating test results in the Allure format by configuring your test runner (e.g., Playwright).


  1. Run the Allure Command Again
    • After ensuring the Allure CLI is installed and the results directory exists, run:
      allure generate ./allure-results --clean
    • If everything is set up correctly, this will generate the Allure report.

  1. Serve the Allure Report
    • To view the generated report, run:
      allure open
    • This will open the report in your default browser.

Common Issues and Solutions

  • Allure Command Not Found:

    • If allure is still not recognized, ensure the CLI is added to your PATH environment variable. Restart your terminal or system after making changes to the PATH.
  • No Results in Allure Directory:

    • Ensure your test framework is configured to generate Allure results. For Playwright, add the following dependency and configuration:
      npm install allure-playwright
      In your test configuration (playwright.config.js):
      import { defineConfig } from '@playwright/test';
      import allure from 'allure-playwright';
      
      export default defineConfig({
        reporter: [
          ['line'],
          ['allure-playwright'],
        ],
      });
@imshaiknasir
Copy link
Author

To add Allure CLI (or any other program) to the PATH environment variable in Windows, follow these steps:


1. Locate the Allure Installation Directory

  • If you installed Allure using npm, the path to the executable is usually something like:

    C:\Users\<YourUsername>\AppData\Roaming\npm
    

    Look for the allure file in this directory.

  • If you downloaded Allure manually:

    • Note the directory where you extracted the Allure CLI.
    • The bin folder inside the extracted directory is what needs to be added to PATH.

2. Add Allure to the PATH

Option 1: Using Environment Variables Settings

  1. Open System Properties:

    • Press Win + S and search for Environment Variables.
    • Click on Edit the system environment variables.
  2. Access Environment Variables:

    • In the System Properties dialog, click on the Environment Variables button.
  3. Edit the PATH Variable:

    • Under System Variables or User Variables, find the Path variable and select it.
    • Click Edit.
  4. Add Allure Path:

    • In the Edit Environment Variable window, click New.
    • Add the full path to the directory containing the allure executable (e.g., C:\Users\<YourUsername>\AppData\Roaming\npm or C:\Path\To\Allure\bin).
    • Click OK to save.
  5. Apply Changes:

    • Click OK in all dialog boxes to close them.

Option 2: Using Command Prompt

  1. Open a new Command Prompt as Administrator.

  2. Run the following command (replace <path_to_allure> with the actual path):

    setx PATH "%PATH%;<path_to_allure>"

    For example:

    setx PATH "%PATH%;C:\Users\<YourUsername>\AppData\Roaming\npm"
  3. Restart the terminal for the changes to take effect.


3. Verify Allure is in PATH

  • Open a new terminal (Command Prompt, PowerShell, or Windows Terminal).
  • Run:
    allure --version
    • If the version number is displayed, Allure is correctly added to the PATH.
    • If not, recheck the path and ensure it points to the directory containing the allure executable.

4. Test Allure

  • Navigate to your project directory and try running the command again:
    allure generate ./allure-results --clean
    allure open

This should resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment