Complete illustrated user guide Β· v1.3.3

Test Framework
Scaffolder

One-stop scaffolder for Playwright functional automation and k6 performance testing with Grafana.

TypeScriptJavaScriptPythonJavaUI + APIk6 + Grafana

1. Requirements

Install the tools for the language you want to generate.

Language Required Runner
TypeScript / JavaScript Node.js 22+ and npm Playwright Test
Python Python 3.10+ and pip pytest
Java JDK 17+ and Maven JUnit 5 or TestNG
Performance k6, Node.js 22+, and Docker Compose for dashboards k6 with Prometheus and Grafana
UI automation needs a Playwright browser. API-only projects do not need a browser download. Install k6 before running a performance project; Docker is optional unless you want the local Grafana dashboard.

Install k6

brew install k6                         # macOS
winget install k6 --source winget       # Windows

2. Create a project

Recommended

mkdir automation-projects
cd automation-projects
npx test-framework-scaffolder@latest

Optional global install

npm install --global test-framework-scaffolder@latest
test-framework-scaffolder

The project is created under the directory where the command is launched. Run pwd first if unsure.

$ npx test-framework-scaffolder@latest

πŸš€ Test Framework Scaffolder
βœ” Project name: k6-tests
βœ” Select language: Performance β€” k6 + Grafana
βœ” Select framework style: BDD
βœ” Include GitHub Actions? Yes
βœ” Framework files created

Created at:
  /Users/me/performance-projects/k6-tests

Open in VS Code:
  code "/Users/me/performance-projects/k6-tests"
Visual example: k6 generation and the absolute output location.

3. Prompt choices

Project name

Use a lowercase name such as crm-tests. The destination must not exist.

Language

TypeScript, JavaScript, Python + pytest, Java + Maven, or Performance with k6 + Grafana.

Style

Every language offers BDD Gherkin or TDD/Non-BDD. JavaScript uses playwright-bdd, Python uses pytest-bdd, and Java uses Cucumber. k6 BDD uses a thin Given/When/Then layer and runs natively without a custom k6 binary.

Java runner

Java projects offer JUnit 5 or TestNG for both BDD and TDD/Non-BDD execution.

Testing type

UI creates browser layers, API creates service layers, and UI + API creates both. Choosing k6 automatically creates a focused performance project.

App faΓ§ade

Framework setup stays in fixtures, hooks, and base classes. Tests and steps call page/service methods through app objects.

Allure

For TypeScript/JavaScript, adds Allure result and report commands.

GitHub Actions

Adds CI with environment selection and report artifacts.

Install dependencies

Runs npm, pip, or Maven. Browser installation remains a first-run step.

4. First run

TypeScript / JavaScript

cd "/path/to/project"
npm install
npx playwright install
npm test

Python

cd "/path/to/project"
python3 -m pip install -r requirements.txt
python3 -m playwright install
python3 -m pytest

Java

cd "/path/to/project"
mvn test

k6 + Grafana

cd "/path/to/project"
docker compose up -d
npm run test:grafana

Open in VS Code

code "/absolute/path/to/project"

If code is unavailable, select VS Code β†’ File β†’ Open Folder.

5. Project structure

project/
β”œβ”€β”€ config/run.config.json       environment and execution settings
β”œβ”€β”€ test-data/
β”‚   β”œβ”€β”€ smoke.json
β”‚   └── uat.json
β”œβ”€β”€ utils/CommonMethods.*        reusable helpers
β”œβ”€β”€ pages/                       UI selection only
β”œβ”€β”€ api/                         API selection only
β”œβ”€β”€ features/ and steps/         BDD projects
β”œβ”€β”€ tests/                       executable tests
β”œβ”€β”€ reporters/ and scripts/
β”œβ”€β”€ playwright.config.*          TypeScript / JavaScript
└── .github/workflows/           optional CI

Only selected capabilities are generated. API-only projects do not contain UI files.

Generated k6 structure

k6-project/
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ run.config.json          environment, profile, thresholds
β”‚   └── load-profiles.js         smoke, load, stress, spike
β”œβ”€β”€ test-data/
β”‚   β”œβ”€β”€ smoke.json
β”‚   └── uat.json
β”œβ”€β”€ lib/performance-app.js       reusable requests and checks
β”œβ”€β”€ tests/                       thin k6 entry point
β”œβ”€β”€ features/ and steps/         BDD projects only
β”œβ”€β”€ observability/
β”‚   β”œβ”€β”€ prometheus.yml
β”‚   └── grafana/                 provisioning and dashboard
β”œβ”€β”€ scripts/run-k6.mjs           environment/profile runner
β”œβ”€β”€ docker-compose.yml
└── .github/workflows/k6.yml     optional CI

6. Run configuration

Edit config/run.config.json. Test commands read it automatically.

{
  "environment": "smoke",
  "timeout": 30000,
  "actionTimeout": 10000,
  "navigationTimeout": 30000,
  "headless": true,
  "retries": 0,
  "ciRetries": 2,
  "fullyParallel": true,
  "workers": null
}
Property Meaning
environment Loads test-data/<environment>.json.
timeout Maximum time for one test in milliseconds.
actionTimeout Limit for click, fill, and similar actions.
navigationTimeout Maximum navigation duration.
headless Set false to see the browser during debugging.
retries / ciRetries Local and CI retries.
fullyParallel Runs independent tests concurrently.
workers Null uses automatic workers; otherwise set a positive number.

k6 run configuration

{
  "environment": "smoke",
  "profile": "smoke",
  "summaryTrendStats": ["avg", "min", "med", "max", "p(90)", "p(95)", "p(99)"],
  "thresholds": {
    "http_req_failed": ["rate<0.01"],
    "http_req_duration": ["p(95)<500", "p(99)<1000"],
    "checks": ["rate>0.99"]
  }
}

environment selects the matching JSON data file. profile selects a workload from config/load-profiles.js. A failed threshold makes the command and CI job fail.

7. Add any environment

  1. Copy test-data/smoke.json.
  2. Rename it, for example test-data/crm.json.
  3. Set "environment": "crm" in run.config.json.
  4. Run the normal command.
{
  "baseUrl": "https://crm.example.com",
  "apiBaseUrl": "https://api.crm.example.com",
  "apiExpectedStatus": 200,
  "validUser": {
    "username": "standard_user",
    "password": "use-a-secret-variable"
  }
}
Never commit secrets. Use environment variables or GitHub Actions secrets for credentials and tokens.

k6 environment data

{
  "baseUrl": "https://test.k6.io",
  "endpoint": "/",
  "expectedStatus": 200,
  "thinkTimeSeconds": 1
}

Add any name such as test-data/crm.json, then set "environment": "crm". The normal npm test command discovers it automatically.

8. Run tests

TypeScript and JavaScript

Goal Command
Entire suite npm test
One BDD feature npm test login.feature
One spec npm test login.spec.ts or npm test login.spec.js
One tag npm test -- --tag @smoke
BDD expression npm test -- --tag "@smoke and not @slow"
UI / API scope npm run test:ui / npm run test:api
Environment override npm test crm or npm test -- --env=crm
List tests npm test -- --list

Python

python3 -m pytest                       # all
python3 -m pytest tests/test_login.py   # one file
python3 -m pytest -m smoke              # marker
TEST_ENV=crm python3 -m pytest          # environment

Java

mvn test                                # all
mvn -Dtest=LoginTest test               # one class
mvn test -Dcucumber.filter.tags="@smoke" # BDD tag
mvn -Denv=crm test                      # environment

k6 performance

npm test                                # run config defaults
npm run test:smoke                      # smoke profile
npm run test:load                       # load profile
npm test -- --env uat --profile stress # explicit data + profile
npm run test:grafana                    # publish live metrics

Set environment and profile in config/run.config.json. Any matching test-data/<environment>.json is selected automatically. Grafana is available at http://localhost:3000 after Docker Compose starts.

$ npm test login.feature

[RUN] Framework: bdd | Test type: ui-api
[RUN] Environment: from config/run.config.json
[RUN] Starting Playwright tests...

βœ“ Login β€Ί Successful login @smoke

1 passed (2.1s)
Visual example: executing one BDD feature.

9. k6 + Prometheus + Grafana

k6 executes JavaScript performance journeys. Prometheus receives the live metrics and Grafana displays the provisioned dashboard.

BDD and Non-BDD

BDD

Includes a readable .feature specification and thin Given/When/Then functions. The native k6 entry point calls those steps without requiring a custom k6 binary.

Non-BDD

Includes one thin tests/load-test.js entry point that calls the reusable performance journey directly.

Available load profiles

Profile Generated workload Command
Smoke 1 virtual user, 1 iteration npm run test:smoke
Load 10 virtual users for 1 minute npm run test:load
Stress Ramps from 0 to 20, then 50, then back to 0 npm run test:stress
Spike Rapidly ramps to 100 virtual users and back down npm run test:spike

Start and use the dashboard

  1. Run npm run dashboard:up.
  2. Run npm run test:grafana.
  3. Open http://localhost:3000.
  4. Sign in with local credentials admin / admin.
  5. Open Performance β†’ k6 Performance Overview.
  6. Stop the services with npm run dashboard:down.

The dashboard shows request rate, p95 duration, failed-request rate, and active virtual users. The runner uses k6's experimental-prometheus-rw output and sends metrics to http://localhost:9090/api/v1/write.

$ npm run test:grafana

[RUN] k6 bdd | environment=smoke | profile=smoke | grafana=true

βœ“ checks rate > 99%
βœ“ http_req_failed rate < 1%
βœ“ p95 duration < 500ms
Visual example: k6 thresholds passing while metrics stream to Prometheus and Grafana.

10. Reports and diagnostics

  • reports/errors.log records failures.
  • test-results/ retains failure screenshots, video, and traces where supported.
  • Open a trace: npx playwright show-trace path/to/trace.zip.
  • HTML report: npx playwright show-report.
  • Allure: npm run allure, then npm run allure:open.
  • k6 thresholds fail the command when service-level goals are not met; Grafana shows live request rate, latency, failures, and VUs.

Traces combine actions, DOM snapshots, console events, and network requests.

11. Add tests

UI

Keep browser behavior in Page Objects. Tests and steps should only call business methods through the app fixture.

API

Keep endpoints and response verification in services so scenarios only call reusable methods.

App faΓ§ade

Page construction, browser contexts, API contexts, tracing, and cleanup belong in the generated app/base layer.

Common methods

Keep shared configuration/data utilities in the generated CommonMethods.

Performance journeys

Keep requests, checks, and reusable flows in lib/performance-app.js; keep load models in config/load-profiles.js.

Tags

BDD uses @smoke. TDD/Non-BDD uses { tag: '@smoke' }.

Quality checks

npm run typecheck
npm run lint
npm test

12. GitHub Actions

The optional workflow installs dependencies, runs the chosen environment, and uploads reports. Push the project, open Actions, choose Run workflow, and enter smoke, uat, or another test-data filename. Store credentials under Settings β†’ Secrets and variables β†’ Actions.

A generated k6 workflow uses grafana/setup-k6-action and provides separate environment and profile inputs. Choose smoke, load, stress, or spike from the Actions screen. The CI command fails when a configured performance threshold is crossed.

13. Publish generator updates

Run publishing commands from the folder that contains this package's package.json. npm requires a new version for every release and requires account 2FA or an appropriate publishing token.

cd "/path/to/NPM Scaffolds pacakge"
npm whoami
npm run typecheck
npm run lint
npm test
npm pack --dry-run
npm version patch
npm publish --access public

Verify the registry with npm view test-framework-scaffolder version. The npm page and its README change only after the new version is successfully published.

14. Troubleshooting

Problem Fix
Folder not visible in VS Code Run pwd and ls -la <project>, then code "$(pwd)/<project>" or File β†’ Open Folder.
Destination exists Choose a new name or safely move/remove the old target.
Browser executable missing Run npx playwright install or python3 -m playwright install.
No tests found Check the filename and use npm test -- --list. BDD also requires matching steps.
Unknown environment Create test-data/<name>.json matching the configured name.
k6 is not installed or not on PATH Install k6, restart the terminal, and confirm with k6 version.
Grafana has no k6 results Start Docker with npm run dashboard:up, then use npm run test:grafana, not plain npm test.
k6 threshold failed Review the failed metric and endpoint behavior before changing the limits in config/run.config.json.
Docker port 3000 or 9090 is already used Stop the conflicting service or change the host-side port in docker-compose.yml.
Installation is slow The first run downloads dependencies; browser installation is separate.
npm E403 Enable npm 2FA or use an appropriate granular publishing token.

15. Quick reference

Create

npx test-framework-scaffolder@latest

Open

code "/absolute/project/path"

Configure

config/run.config.json
test-data/<environment>.json

Run

npm test
python3 -m pytest
mvn test
npm run test:grafana

k6 dashboard

npm run dashboard:up
npm run test:grafana
npm run dashboard:down

Recommended flow: generate β†’ open the printed path β†’ install a browser for UI tests β†’ review configuration β†’ run the sample β†’ replace sample data and coverage.