Home/Tools/@tpmjs/tools-acceptance-criteria

acceptanceCriteriaTool

@tpmjs/tools-acceptance-criteria

Format acceptance criteria from requirements using the Given/When/Then (Gherkin) format. Ideal for defining testable requirements for user stories and features in BDD style.

Official
documentation
v0.2.0
MIT
⚠️

This tool is currently broken

Execution Failed
Runtime error with test parameters
Criteria array must contain at least one criterion

Last checked: 1/1/2026, 8:18:34 AM

Interactive Playground

Test @tpmjs/tools-acceptance-criteria (acceptanceCriteriaTool) with AI-powered execution

0/2000 characters

Installation & Usage

Install this tool and use it with the AI SDK

1. Install the package

npm install @tpmjs/tools-acceptance-criteria
pnpm add @tpmjs/tools-acceptance-criteria
yarn add @tpmjs/tools-acceptance-criteria
bun add @tpmjs/tools-acceptance-criteria
deno add npm:@tpmjs/tools-acceptance-criteria

2. Import the tool

import { acceptanceCriteriaTool } from '@tpmjs/tools-acceptance-criteria';

3. Use with AI SDK

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { acceptanceCriteriaTool } from '@tpmjs/tools-acceptance-criteria';

const result = await generateText({
  model: openai('gpt-4o'),
  tools: { acceptanceCriteriaTool },
  prompt: 'Your prompt here...',
});

console.log(result.text);

Parameters

Available configuration options

Auto-extracted
story
Required
Type: string

The user story or feature description

criteria
Required
Type: array

Array of criteria objects, each with given, when, and then properties following Gherkin format

Schema extracted: 1/1/2026, 8:18:34 AM

README

@tpmjs/tools-acceptance-criteria

Format acceptance criteria from requirements using Given/When/Then (Gherkin) format.

Installation

npm install @tpmjs/tools-acceptance-criteria

Usage

import { acceptanceCriteriaTool } from '@tpmjs/tools-acceptance-criteria';

const result = await acceptanceCriteriaTool.execute({
  story: `As a user, I want to reset my password so that I can regain access to my account
    if I forget my credentials.`,
  criteria: [
    {
      given: 'I am on the login page',
      when: 'I click "Forgot Password"',
      then: 'I should see a password reset form',
    },
    {
      given: 'I have entered my email address',
      when: 'I submit the password reset form',
      then: 'I should receive a password reset email',
    },
    {
      given: 'I have clicked the reset link in my email',
      when: 'I enter a new password and confirm it',
      then: 'my password should be updated and I should be logged in',
    },
  ],
});

console.log(result.formatted);
// # Acceptance Criteria
//
// ## As a user, I want to reset my password so that I can regain access to my account
//
// As a user, I want to reset my password so that I can regain access to my account
// if I forget my credentials.
//
// ---
//
// ## Scenarios
//
// ### Scenario 1
//
// **Given** I am on the login page
// **When** I click "Forgot Password"
// **Then** I should see a password reset form
//
// ### Scenario 2
//
// **Given** I have entered my email address
// **When** I submit the password reset form
// **Then** I should receive a password reset email
//
// ### Scenario 3
//
// **Given** I have clicked the reset link in my email
// **When** I enter a new password and confirm it
// **Then** my password should be updated and I should be logged in

console.log(result.criteriaCount); // 3

API

acceptanceCriteriaTool.execute(input)

Formats acceptance criteria using the Given/When/Then (Gherkin) format.

Input

  • story (string, required): The user story or feature description
  • criteria (Criterion[], required): Array of criteria objects with:
    • given (string): The initial context or precondition
    • when (string): The action or event that occurs
    • then (string): The expected outcome or result

Output

Returns a Promise<AcceptanceCriteria> with:

  • formatted (string): The formatted acceptance criteria in markdown
  • criteriaCount (number): Number of scenarios included

Features

  • Gherkin format: Uses industry-standard Given/When/Then structure
  • Clear scenarios: Each criterion becomes a numbered scenario
  • Markdown output: Returns clean, readable markdown
  • Validation: Ensures all criteria have required fields
  • BDD-ready: Output is ready for BDD testing frameworks

Gherkin Structure

Each criterion follows the Gherkin format:

  • Given: Describes the initial context or state
  • When: Describes the action or event
  • Then: Describes the expected outcome

This structure makes requirements:

  • Testable
  • Unambiguous
  • Readable by non-technical stakeholders

Use Cases

  • Define acceptance criteria for user stories
  • Create testable requirements for features
  • Document expected behavior for QA
  • Generate scenarios for BDD testing frameworks
  • Communicate requirements between team members

Best Practices

  • Keep each scenario focused on a single path
  • Use active voice ("I click", "the system displays")
  • Be specific about expected outcomes
  • Include both happy path and edge cases
  • Write from the user's perspective

Integration with BDD Tools

The formatted output works well with BDD frameworks like:

  • Cucumber
  • SpecFlow
  • Behave
  • JBehave

Simply copy the scenarios into your .feature files.

License

MIT

Statistics

Downloads/month

0

Quality Score

0%

Bundle Size

NPM Keywords

tpmjs
documentation
ai
acceptance-criteria
gherkin
bdd
testing

Maintainers

thomasdavis(thomasalwyndavis@gmail.com)

Frameworks

vercel-ai