{"id":21995338,"url":"https://github.com/polymerlabs/ristretto","last_synced_at":"2025-04-30T17:26:34.922Z","repository":{"id":57137596,"uuid":"101297512","full_name":"PolymerLabs/ristretto","owner":"PolymerLabs","description":"An extensible test runner ☕️","archived":false,"fork":false,"pushed_at":"2024-10-09T18:58:54.000Z","size":100,"stargazers_count":30,"open_issues_count":3,"forks_count":3,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-18T04:48:48.744Z","etag":null,"topics":["bdd","coffee","tdd","test","test-reporting","test-runner","testing-framework","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PolymerLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-24T13:25:22.000Z","updated_at":"2020-10-29T02:41:47.000Z","dependencies_parsed_at":"2024-11-29T21:14:23.740Z","dependency_job_id":"3cb28481-b247-409d-8a35-3eef9940f0ea","html_url":"https://github.com/PolymerLabs/ristretto","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerLabs%2Fristretto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerLabs%2Fristretto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerLabs%2Fristretto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerLabs%2Fristretto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PolymerLabs","download_url":"https://codeload.github.com/PolymerLabs/ristretto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251750363,"owners_count":21637710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bdd","coffee","tdd","test","test-reporting","test-runner","testing-framework","testing-tools"],"created_at":"2024-11-29T21:14:17.417Z","updated_at":"2025-04-30T17:26:34.898Z","avatar_url":"https://github.com/PolymerLabs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"*🚨 **PROJECT STATUS: EXPERIMENTAL** 🚨This product is in the Experimentation phase. Someone on the team thinks it’s an idea worth exploring, but it may not go any further than this. Use at your own risk.*\n\n# Ristretto\n\nRistretto is an extensible test runner.\n\nThere are several established test runners in the JavaScript ecosystem\n([Mocha](https://mochajs.org/), [Jasmine](https://jasmine.github.io/) and\n[Jest](https://facebook.github.io/jest/) to name a few of the more prominent\nones). Ristretto was created to address a feature sweet spot left unaddressed\nby incumbent projects.\n\nRistretto has the following qualities:\n\n - Simple, concise, class-based factorization\n - Consumable as modules with browser-compatible path specifiers OOB\n - Batteries included for the most popular testing syntaxes (BDD/TDD)\n - Designed for extensibility (mixins, specialized reporters and a\n spec-as-data-structure philosophy)\n - Ships with mixins that enhance specs with powerful features (e.g., fixtures\n and test isolation)\n - Authored in TypeScript\n - No build tooling required to use\n - \"JavaScript is the native language, The Web is the native land\"\n\nRistretto is intended to be a single-responsibility detail of a broader, more\ncomprehensive testing regime. In this regard, it is most similar to Mocha in its\nbreadth of capabilities.\n\nCurrently, Ristretto only supports direct usage in a web browser with ESM\nsupport. Other browsers and platforms (such as Node.js) should work fine with\nsufficient code transformations applied to this module.\n\n## Installing\n\n```sh\nnpm install @polymer/ristretto\n```\n\n## Writing tests\n\nAll tests start with crafting a spec and exporting that spec for consumption\nelsewhere. Here is an example of a spec written with Ristretto:\n\n```javascript\n// Import the Spec class from Ristretto:\nimport { Spec } from '../../@polymer/ristretto/lib/spec.js';\n\n// Create a Spec instance that represents our spec:\nconst spec = new Spec();\n\n// These \"describe\" and \"it\" methods work as you would expect when writing\n// a test in Mocha, Jasmine or Jest:\nconst { describe, it } = spec;\n\n// Author your spec as you would in any other test runner:\ndescribe('My spec', () =\u003e {\n  it('never fails', () =\u003e {});\n});\n\n// Export the spec as a module:\nexport { spec as mySpec };\n```\n\n## Running tests\n\nIn order to run the tests in your spec, you will need to craft a test suite.\nA test suite is a collection of specs, and an optional specialized test\nreporter. Here is a basic example of crafting a test suite and running tests:\n\n```javascript\n// Import the Suite class from Ristretto:\nimport { Suite } from '../../@polymer/ristretto/lib/suite.js';\n\n// Import the spec we crafted above:\nimport { mySpec } from './my-spec.js';\n\n// Craft a suite that includes our spec:\nconst suite = new Suite([ mySpec /*, other, specs, go, here */ ]);\n\n// Run the test suite at your leisure. It will return a promise that resolves\n// when all tests have been run:\nsuite.run();\n```\n\n## Reporting results\n\nBy default, Ristretto will use a basic `console`-based reporter called\n`ConsoleReporter`. However, it is very easy to craft a custom reporter to\nsuite your needs. Let's write a custom reporter that counts tests and\nreports how many failed at the end of the test suite run:\n\n```javascript\n// Import the base Reporter class from Ristretto:\nimport { Reporter } from '../../@polymer/ristretto/lib/reporter.js';\n\n// We export a class that extends the base Reporter class. The reporter has\n// a series of test suite life-cycle callbacks that can be optionally\n// implemented by child classes to perform specialized reporting. We implement\n// a few of them here:\nexport class CountingReporter extends Reporter {\n\n  onSuiteStart(suite) {\n    // Initialize some state when the test suite begins:\n    this.totalTestCount = 0;\n    this.failedTestCount = 0;\n  }\n\n  onTestStart(test, suite) {\n    // When a test starts, increment the total test counter:\n    this.totalTestCount++;\n  }\n\n  onTestEnd(result, test, suite) {\n    // If there is an error in the result when a test ends, increment the\n    // failed test counter:\n    if (result.error) {\n      this.failedTestCount++;\n    }\n  }\n\n  onSuiteEnd(suite) {\n    // When the test suite run has completed, announce the total number of\n    // tests, and if there were any failed tests announce that number as well:\n    console.log(`Total tests: ${this.totalTestCount}`);\n    if (this.failedTestCount \u003e 0) {\n      console.error(`Failed tests: ${this.failedTestCount}`);\n    } else {\n      console.log('All tests pass!');\n    }\n  }\n}\n```\n\nNow that we have a custom reporter, let's use it in a test suite:\n\n```javascript\n// Import the Suite class from Ristretto:\nimport { Suite } from '../../@polymer/ristretto/lib/suite.js';\n\n// Import the custom reporter we created:\nimport { CountingReporter } from './counting-reporter.js';\n\n// Craft a suite that includes any specs and our custom reporter:\nconst suite = new Suite([ /* specs, go, here */ ], new CountingReporter());\n\n// Run the test suite at your leisure. The suite will invoke reporter callbacks\n// is testing progresses to completion:\nsuite.run();\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolymerlabs%2Fristretto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolymerlabs%2Fristretto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolymerlabs%2Fristretto/lists"}