The nilgiricucumber
module integrates Cucumber and Playwright to simplify and enhance automated BDD testing. It generates feature files, step definitions, and test scripts, making it easier to write structured, reusable test cases.
-
Ensure you have Node.js and TypeScript installed on your machine.
- Download Node.js from here.
- To install TypeScript globally, run:
npm install -g typescript
-
IDE: Use an IDE that supports TypeScript and Node.js, such as VSCode or WebStorm.
-
AI API Key and Endpoint : Have your AI API key and endpoint ready for AI-based code generation .
npm install nilgiricucumber@latest --save-dev
To run the generateTestFiles
method, import and call it in your script:
Example: Create new test.ts file and copy paste the below example code ,
replace your apiUrl
, apiKey
, xlsxFilePath
and websiteURL
with correct values .
Example usage:
import { generateTestFiles } from 'nilgiricucumber';
const config = {
apiUrl: 'https://api.openai.com/v1/completions',
apiKey: 'sk-xxxxxx12345',
xlsxFilePath: 'path/to/excel.xlsx',
websiteURL: 'https://example.com'
};
generateTestFiles(config)
.then(() => console.log('BDD test files generated successfully!'))
.catch(err => console.error('Error:', err));
Parameter | Type | Description | Example |
---|---|---|---|
apiUrl |
string | The endpoint URL of the AI service . | 'https://api.openai.com/v1/completions' |
apiKey |
string | The API key for authentication . | 'sk-xxxxxx12345' |
xlsxFilePath |
string | Path to the Excel sheet containing test scenarios. | 'path/to/excel.xlsx' |
websiteURL |
string | The URL of the system under test. | 'https://example.com' |
-
Compile the TypeScript file:
tsc <your-file-name>.ts node <your-file-name>.js
npx ts-node <your-file-name>.ts
After running generateTestFiles(config), the following files will be created:
output.feature
- This contains the generated Cucumber feature file with test scenarios.
output.ts
- This is the Step Definition file that maps steps from the feature file to Playwright test actions.
📌 Location of Generated Files
These files will be saved in your project root folder or the default output directory based on your system settings.
✅ How to View the Files?
Open your file explorer and navigate to the project directory.
In VSCode or any IDE, check the left-hand file explorer.
Run the following command in your terminal to confirm the files exist:
ls -l output.*
📌 Note: You can now review and modify the generated test files before executing them.
- Automated BDD test generation with feature files and step definitions.
- Integrates with Playwright for powerful end-to-end testing.
- Supports AI-driven test case generation for enhanced automation.
- Works with TypeScript and JavaScript seamlessly.
For any support, please create an issue on the Nilgiri Cucumber GitHub repository.
Copyright (c) 2025 Tricon Infotech