{"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install promises-aplus-tests"],"cli":{"name":"promises-aplus-tests","version":null}},"imports":["import promisesAplusTests from 'promises-aplus-tests';"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}