npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

boundary-value-analytics

v1.0.1

Published

A Playwright-based utility for automated Boundary Value Analysis (BVA) testing, supporting both integers and floating-point numbers.

Downloads

9

Readme

🎯 Boundary Value Analysis (BVA) Test Automation with Playwright

Overview

This package provides a helper function bvaTest to automate Boundary Value Analysis (BVA) testing using Playwright. The function simplifies testing minimum and maximum boundaries for both integer and floating-point input values in web applications. 🌍

📊 Boundary Value Analysis (BVA)

Boundary Value Analysis is a testing technique used to identify defects by focusing on edge cases at the boundaries of input ranges. These boundaries are more likely to have issues, as developers may overlook extreme values during coding. Boundary Value Analysis (BVA)

The key boundaries tested are:
  • Lower Boundary: The minimum value the input field should accept.
  • Upper Boundary: The maximum value the input field should accept.
  • Just Below Lower Boundary: A value slightly smaller than the minimum boundary, which should be rejected.
  • Just Above Lower Boundary: A value slightly greater than the minimum boundary, which should be accepted.
  • Just Below Upper Boundary: A value slightly smaller than the maximum boundary, which should be accepted.
  • Just Above Upper Boundary: A value slightly greater than the maximum boundary, which should be rejected.

🚀 Installation

To use this package, you need to install Playwright and this module.

Step 1: Install Playwright

First, if you haven't already, install Playwright:

npm install @playwright/test

Step 2: Install the BVA Test Function

npm i boundary-value-analytics

🛠️ Usage

Function: bvaTest

This function tests boundary values (both integers and floats) for form inputs using Playwright. It also allows for country-specific boundary increments.

Parameters
  • minValue: (number) The minimum boundary value to test.
  • maxValue: (number) The maximum boundary value to test.
  • elementXPath: (string) The XPath of the input element where the test values will be entered.
  • submitXPath: (string) The XPath of the submit button to trigger form submission.
  • successXPath: (string or null) The optional XPath of the element that displays a success message. If the success message is not required, pass null.
  • errorXPath: (string) The XPath of the element that displays an error message if validation fails.
  • page: (object) The Playwright page object representing the browser page.

📊 Country-Specific Boundary Increment

The boundary increment (or "delta") adjusts based on the difference between the minimum and maximum values. This is useful in cases where boundaries vary by country or specific case ranges.

  • If the boundary difference is greater than or equal to 1, the delta is 1.
  • If the difference is less than or equal to 0.5, the delta is 0.1.
  • If the difference is less than or equal to 0.1, the delta is 0.01.
  • If the difference is less than or equal to 0.01, the delta is 0.001.

These rules help accommodate different ranges for boundary values, which may differ in internationalized applications or based on country-specific increments.

Example

Below is an example of how to use the bvaTest function in your test suite:

const { test } = require('@playwright/test');
const { bvaTest } = require('boundary-value-analytics');

test('Boundary Value Analysis Test', async ({ page }) => {
  const minValue = 1;
  const maxValue = 10;
  const elementXPath = '//input[@id="numberInput"]';
  const submitXPath = '//button[@id="submit"]';
  const successXPath = "//div[@class='success-message']";  // XPath of success message
  // const successXPath = null;  // Optional: Set to null if no success message element
  const errorXPath = '//div[@id="errorMessage"]';
  
  await bvaTest(minValue, maxValue, elementXPath, submitXPath, successXPath, errorXPath, page);
});

🌟 How It Works

  1. Boundary Values: The bvaTest function checks key boundary values, including:
    • Exact minimum and maximum values.
    • Values just inside and outside these boundaries (with a delta).
  2. Delta Calculation: Based on the difference between minValue and maxValue, the function dynamically determines the appropriate delta value for testing near-boundary cases. This is especially useful for country-specific or case-specific increments.
  3. XPath Locators: You provide the XPath locators for the input element, submit button, and success/error messages. The function interacts with these elements during testing.
  4. Optional Success Message: If you do not need to check for a success message (e.g., in negative tests), simply pass null as the value for successXPath. The function will still check for error messages if the input is invalid.

🧑‍🔧 Boundary Testing Scenarios

Here are the test scenarios the function runs for each boundary:

  • Lower Boundary: Tests the exact minimum value (e.g., minValue).
  • Just Below Lower Boundary: Tests a value just below the minimum boundary (minValue - delta), which should fail.
  • Just Above Lower Boundary: Tests a value just above the minimum boundary (minValue + delta), which should pass.
  • Upper Boundary: Tests the exact maximum value (e.g., maxValue).
  • Just Below Upper Boundary: Tests a value just below the maximum boundary (maxValue - delta), which should pass.
  • Just Above Upper Boundary: Tests a value just above the maximum boundary (maxValue + delta), which should fail.

🔥 Notes

  • The function ensures that numeric values are tested. If the boundary values are not valid numbers, it will throw an error.
  • The page object must be an active instance of a Playwright page.
  • The successXPath parameter is optional. Pass null if you don’t need to check for a success message after submission.
  • This function supports both integer and floating-point boundary values.

📜 License

MIT License