{"id":13816,"library":"promises-aplus-tests","title":"Promises/A+ Compliance Test Suite","description":"This package provides the official compliance test suite for the Promises/A+ specification, currently at version 2.1.2. It is designed to verify that a promise implementation correctly adheres to the `then()` method behavior defined in the Promises/A+ specification. The suite can be run in both Node.js and browser environments, requiring a minimal adapter interface from the promise library under test. Key differentiators include its status as the authoritative test suite for the specification, allowing compliant libraries to display the Promises/A+ logo. Releases appear to be driven by specification updates and maintenance, with the last major update (v2.0.0) aligning with Promises/A+ v1.1. It ensures comprehensive test coverage for various promise states and operations, making it an essential tool for promise library authors.","status":"active","version":"2.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/promises-aplus/promises-tests","tags":["javascript","promises","promises-aplus"],"install":[{"cmd":"npm install promises-aplus-tests","lang":"bash","label":"npm"},{"cmd":"yarn add promises-aplus-tests","lang":"bash","label":"yarn"},{"cmd":"pnpm add promises-aplus-tests","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used as the underlying test runner for the compliance suite. While typically installed as a devDependency of 'promises-aplus-tests', users leveraging the CLI or programmatic API should be aware that Mocha drives the execution and reporting.","package":"mocha","optional":false}],"imports":[{"note":"The package's main export is a function that serves as the test runner. It's consumed as a default import in ESM or via `require` in CommonJS. The library itself primarily uses CommonJS style internally.","wrong":"const promisesAplusTests = require('promises-aplus-tests');","symbol":"default","correct":"import promisesAplusTests from 'promises-aplus-tests';"}],"quickstart":{"code":"/* adapter.js - Your custom promise implementation adapter */\nmodule.exports = {\n  resolved: function (value) {\n    // Replace `MyPromise` with your actual Promise constructor, e.g., `new MyPromise(resolve => resolve(value))`\n    // Using native Promise for demonstration; replace with your library's equivalent.\n    return Promise.resolve(value);\n  },\n  rejected: function (reason) {\n    // Replace `MyPromise` with your actual Promise constructor, e.g., `new MyPromise((_, reject) => reject(reason))`\n    // Using native Promise for demonstration; replace with your library's equivalent.\n    return Promise.reject(reason);\n  },\n  deferred: function () {\n    let resolve, reject;\n    // Replace `MyPromise` with your actual Promise constructor\n    const promise = new Promise((res, rej) => {\n      resolve = res;\n      reject = rej;\n    });\n    return { promise, resolve, reject };\n  }\n};\n\n/* test-runner.js - Script to run the tests */\nconst promisesAplusTests = require('promises-aplus-tests');\nconst adapter = require('./adapter.js'); // Path to your adapter file\n\nconsole.log('Running Promises/A+ compliance tests...');\npromisesAplusTests(adapter, { reporter: 'spec' }, function (err) {\n  if (err) {\n    console.error('Promises/A+ tests failed:', err);\n    console.error(`Total failures: ${err.failures}`);\n    process.exit(1);\n  } else {\n    console.log('Promises/A+ tests passed successfully!');\n    process.exit(0);\n  }\n});","lang":"javascript","description":"Demonstrates how to programmatically run the Promises/A+ compliance test suite against a provided custom promise adapter, outputting results using Mocha's 'spec' reporter."},"warnings":[{"fix":"Update your promise adapter to use `resolved` and `resolve` instead of `fulfilled` and `fulfill` to align with Promises/A+ specification v1.1.","message":"The adapter interface underwent a breaking change in version 2.0.0. The methods `fulfilled(value)` and `deferred.fulfill(value)` were renamed to `resolved(value)` and `deferred.resolve(value)` respectively.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure your adapter code includes robust error handling, wrapping any potentially throwing operations from your promise library in `try`/`catch` statements to prevent test failures.","message":"All functions within your custom promise adapter (e.g., `resolved`, `rejected`, `deferred().resolve`, `deferred().reject`) are expected not to throw exceptions. If your promise implementation can throw, you must wrap these calls in `try`/`catch` blocks within the adapter.","severity":"gotcha","affected_versions":"*"},{"fix":"If your promise library has factory methods for already-resolved or already-rejected promises, implement and export `resolved(value)` and `rejected(reason)` functions in your adapter.","message":"While `resolved` and `rejected` exports in the adapter are optional (the test runner can generate them), providing your promise library's native implementations is strongly recommended. This provides better code coverage and can help uncover specific bugs in those native factory methods.","severity":"gotcha","affected_versions":"*"},{"fix":"If you are using an older version (prior to 2.0.4), ensure that no-value Mocha arguments are not the final argument, or update the package to version 2.0.4 or newer.","message":"When using the command-line interface, prior to version 2.0.4, there was a bug affecting the parsing of no-value Mocha arguments (like `--bail`) when they were passed as the last argument.","severity":"gotcha","affected_versions":"<2.0.4"}],"env_vars":null,"search_vec":"'2.1.2':20 'adapt':56 'adher':31 'align':101 'allow':77 'aplus':129 'appear':86 'author':124 'authorit':71 'behavior':36 'browser':51 'complianc':2,10 'compliant':78 'comprehens':107 'correct':30 'coverag':109 'current':17 'defin':37 'design':23 'differenti':65 'display':81 'driven':89 'ensur':106 'environ':52 'essenti':119 'implement':29 'includ':66 'interfac':57 'javascript':125 'key':64 'last':97 'librari':61,79,123 'logo':84 'mainten':94 'major':98 'make':116 'method':35 'minim':55 'node.js':49 'offici':9 'oper':115 'packag':6 'promis':28,60,112,122,126,128 'promises-aplus':127 'promises/a':1,15,40,83,103 'provid':7 'releas':85 'requir':53 'run':46 'specif':16,41,76,91 'state':113 'status':68 'suit':4,12,43,73 'test':3,11,63,72,108 'tool':120 'updat':92,99 'v1.1':104 'v2.0.0':100 'various':111 'verifi':25 'version':19","created_at":"2026-04-20T01:56:27.282009+00:00","updated_at":"2026-04-20T01:56:27.282009+00:00","problems":[{"fix":"Ensure your adapter module (e.g., `module.exports = { deferred: ... }`) includes a correctly implemented `deferred` function that returns `{ promise, resolve, reject }`.","cause":"The `deferred()` function, which is a mandatory part of the adapter interface, is either missing or incorrectly exported from your adapter file.","error":"Error: Adapter must export a 'deferred' function."},{"fix":"Verify that the `deferred()` function in your adapter returns an object with `promise`, `resolve`, and `reject` properties, and that `resolve` and `reject` are indeed functions.","cause":"The object returned by your adapter's `deferred()` function does not contain a callable `resolve` property (or similar for `reject`).","error":"TypeError: resolve is not a function"},{"fix":"Review the detailed output from the test runner (Mocha) in your console to identify which specific Promises/A+ specification points failed and debug your promise library accordingly. The `err.failures` property will indicate the count of failed tests.","cause":"The test suite detected one or more non-compliance issues with the promise implementation provided by your adapter, indicated by a non-zero number of failures.","error":"Promises/A+ tests failed: { failures: N, ... }"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"promises-aplus-tests","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/promises-aplus/promises-tests","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/promises-aplus-tests","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}