{"id":13722185,"url":"https://github.com/jl-/tupe","last_synced_at":"2026-01-02T21:36:24.671Z","repository":{"id":57382223,"uuid":"152510200","full_name":"jl-/tupe","owner":"jl-","description":"Generic unit-testing runner for front-end.➰","archived":false,"fork":false,"pushed_at":"2018-10-18T06:07:41.000Z","size":888,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T02:36:43.579Z","etag":null,"topics":["ava","front-end","puppeteer","test","testing","unit","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jl-.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-11T01:05:07.000Z","updated_at":"2024-04-14T17:44:20.000Z","dependencies_parsed_at":"2022-09-26T16:50:15.138Z","dependency_job_id":null,"html_url":"https://github.com/jl-/tupe","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jl-%2Ftupe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jl-%2Ftupe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jl-%2Ftupe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jl-%2Ftupe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jl-","download_url":"https://codeload.github.com/jl-/tupe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243725635,"owners_count":20337670,"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":["ava","front-end","puppeteer","test","testing","unit","unit-testing"],"created_at":"2024-08-03T01:01:25.527Z","updated_at":"2026-01-02T21:36:24.621Z","avatar_url":"https://github.com/jl-.png","language":"JavaScript","funding_links":[],"categories":["Testing"],"sub_categories":[],"readme":"# Tupe\n\n\u003c!-- Badges --\u003e\n![licence](https://badgen.net/badge/licence/MIT/blue)\n[![npm version](https://badgen.net/npm/v/tupe)](https://www.npmjs.com/package/tupe)\n[![npm downloads](https://badgen.net/npm/dm/tupe)](https://www.npmjs.com/package/tupe)\n\n##### [Features](#features) | [Motivations](#motivations) | [Configuration](#configuration) | [API](#api) | [Examples](#examples) | [FAQ](#faq)\n\n\u003e A generic unit-testing runner for front-end.➰ \n\n## Features\n- 🚀 Blazing fast: Tupe use the great [Parcel](https://github.com/parcel-bundler/parcel) as bundler, and [Puppeteer](https://github.com/GoogleChrome/puppeteer) as runtime environment under the hook, making it fast on both bundle-time and runtime.\n- 🌓 Isolation \u0026 🎎 Concurrency: Each test file is bundled and run as a isolated new tab on puppeteer concurrently. \n- 🎨 Descriptive assertion: bonus with [Power-Assert](https://github.com/power-assert-js/power-assert) builtin.\n- 🐦 Configuration-Free: almost no configuration, except for some basic babel setup, which might agrees to your project setup already\n- ❄️ Simplicity. use the standard assert interface.\n\n## Motivations\nThere are already tons of unit-testing runner/framework for JavaScript.\n- some requires a bit configuration, like karma, not simple enough.\n- when it comes to front-end code testing that requires a browser environment, many of them utilize jsdom, which is a subset emulation of a web browser for use in nodejs environment. That's awesome, but would it be great and more reliable if our code runs in a real-world browser?\n- features like concurrency and isolation are great. You should definitely try out AVA and Jest, they are awesome. But again, they don't seems to bundle for a real-world browser? Correct me if I'm wrong, thanks~\n- Puppeteer is born, which seems to be a perfect fit for browser-side JavaScript testing. Maybe we can try it out and learn how to build a unit test runner, And have all the fun along the way, that's the whole point..\n\n## Install\n```bash\nyarn add --dev tupe\n```\n\n## CLI\n```txt\ntupe \u003cfiles...\u003e\n\nRun Tests\n\nPositionals:\n  files  path or glob for test files                                    [string]\n\nOptions:\n  -h, --help     Show help                                             [boolean]\n  -v, --verbose                                                 [default: false]\n  --watch        watch mode                                     [default: false]\n  --port         server port                                     [default: 1234]\n  --tmpdir       temporary directory                           [default: \".tmp\"]\n  --fail-fast    exit on first fail                    [boolean] [default: true]\n```\n\n## Configuration\nYou can configure Tupe by specifying a `tupe` field at your project's `package.json`\n\n- `files`: file or glob for test files\n- `tmpdir`: this is a temporary folder used by [Parcel](https://parceljs.org/api.html) for compiled files\n- `fail-fast`: in a test file, global `before` or `after` hooks failure will always terminate the runner as failure; For each individual case, if a `beforeEach` hook failed, this case itself and its `afterEach` hooks will not be executed, a case-failure event will araise and the runner will continue to the next case. However, by setting this option to `true`, any case failure will terminate the runner of that test file.\n- `coverage`: options for istanbul, defaults to [this](https://github.com/istanbuljs/istanbuljs/blob/master/packages/istanbul-api/lib/config.js#L14)\n\n```json\n{\n    \"tupe\": {\n        \"files\": [\n            \"test/**/*.js\"\n        ],\n        \"tmpdir\": \".tmp\",\n        \"fail-fast\": false,\n        \"coverage\": {\n            \"dir\": \"test/.coverage\",\n            \"reporters\": [\"text\"],\n            \"check\": {\n            }\n        }\n    }\n}\n```\n\n#### .babelrc\n- to enable power-assert feature, add `power-assert` preset and set patterns for `babel-plugin-espower`\n- to enable code coverage, add `istanbul` plugin, recommend only set for a test env\n```json\n{\n    \"presets\": [\"@babel/env\", \"power-assert\"],\n    \"plugins\": [\n        [\"babel-plugin-espower\", {\n            \"patterns\": [\n                \"t(value, [message])\",\n                \"t.ok(value, [message])\",\n                \"t.equal(actual, expected, [message])\",\n                \"t.deepEqual(actual, expected, [message])\",\n                \"t.notEqual(actual, expected, [message])\",\n                \"t.strictEqual(actual, expected, [message])\",\n                \"t.notStrictEqual(actual, expected, [message])\",\n                \"t.notDeepEqual(actual, expected, [message])\",\n                \"t.deepStrictEqual(actual, expected, [message])\",\n                \"t.notDeepStrictEqual(actual, expected, [message])\",\n                \"t.throws(block, [error], [message])\"\n            ]\n        }]\n    ],\n    \"env\": {\n        \"test\": {\n            \"plugins\": [\n                [\"istanbul\", {\n                    \"include\": [\n                        \"src/**/*.js\"\n                    ]\n                }]\n            ]\n        }\n    }\n}\n\n```\n\n\n## API\n- `test.before([title], fn(t, [callback]))`\n- `test.beforeEach([title], fn(t, [callback]))`\n- `test.afterEach([title], fn(t, [callback]))`\n- `test.after([title], fn(t, [callback]))`\n- `test(title, fn(t, [callback]))`\n- `t` is a enhenced assert function, added with a additional `t.context` abject as a isolated context for each case, live through `beforeEach` due `afterEach` hook\n\n\n## Examples\n\n```javascript\nimport test from 'tupe';\n\ntest('hello tupe!', t =\u003e {\n    const who = { name: 'Tupe!' };\n    t(who.name === 'Tupe!');\n});\n\ntest('async waiting...', async t =\u003e {\n    const answer = true;\n    await new Promise(r =\u003e setTimeout(r, 1500));\n    t(answer === true);\n});\n\ntest('misspell my name ?', t =\u003e {\n    const who = { name: 'Hello Tupe!' };\n    t(who.name === 'Hel' + 'o Tupe~');\n});\n\ntest('use callback ?', (t, done) =\u003e {\n    setTimeout(() =\u003e {\n        t('dump' === 'dump');\n        done();\n    }, 1500);\n});\n\ntest('array assert', t =\u003e {\n    const runners = ['AVA', 'Tupe'];\n    t(runners.indexOf('Tupe') === 0);\n});\n```\n\n![render1539706926643](https://user-images.githubusercontent.com/6291986/47031717-152dd600-d1a3-11e8-8f7e-3626a45c14da.gif)\n\n## FAQ\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjl-%2Ftupe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjl-%2Ftupe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjl-%2Ftupe/lists"}