{"id":26824892,"url":"https://github.com/freeelephants/tsxunit","last_synced_at":"2025-04-28T14:05:14.848Z","repository":{"id":57381354,"uuid":"54750913","full_name":"FreeElephants/TSxUnit","owner":"FreeElephants","description":"xUnit for TypeScript","archived":false,"fork":false,"pushed_at":"2016-10-24T12:07:24.000Z","size":171,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-28T14:05:10.101Z","etag":null,"topics":["testing-framework","typescript","unit-testing","xunit"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FreeElephants.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-25T22:24:11.000Z","updated_at":"2019-11-10T21:52:07.000Z","dependencies_parsed_at":"2022-09-26T16:50:29.026Z","dependency_job_id":null,"html_url":"https://github.com/FreeElephants/TSxUnit","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreeElephants%2FTSxUnit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreeElephants%2FTSxUnit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreeElephants%2FTSxUnit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreeElephants%2FTSxUnit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FreeElephants","download_url":"https://codeload.github.com/FreeElephants/TSxUnit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251326836,"owners_count":21571634,"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":["testing-framework","typescript","unit-testing","xunit"],"created_at":"2025-03-30T10:18:08.335Z","updated_at":"2025-04-28T14:05:14.823Z","avatar_url":"https://github.com/FreeElephants.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TSxUnit\n\n\u003e Because we can. \n\n[![Build Status](https://travis-ci.org/FreeElephants/TSxUnit.svg?branch=master)](https://travis-ci.org/FreeElephants/TSxUnit)\n[![npm version](https://badge.fury.io/js/ts-x-unit.svg)](https://github.com/FreeElephants/TSxUnit/releases)\n[![Downloads](https://img.shields.io/npm/dm/ts-x-unit.svg)](https://npmjs.org/package/ts-x-unit)\n[![bitHound Overall Score](https://www.bithound.io/github/FreeElephants/TSxUnit/badges/score.svg)](https://www.bithound.io/github/FreeElephants/TSxUnit)\n[![codecov](https://codecov.io/gh/FreeElephants/TSxUnit/branch/master/graph/badge.svg)](https://codecov.io/gh/FreeElephants/TSxUnit)\n\n## Usage\n\n[Tell everyone about your TypeScript Test Driven Project!](USERS.md)   \n\n### In Your Project\n\nSee sample of usage: [in micro-bench project](https://github.com/FreeElephants/micro-bench/tree/master/tests).\n\n1. Install ts-x-unit with npm\n\n    ```\n    $ npm install ts-x-unit --save-dev\n    ```\n\n2. Add next tasks to npm scripts:\n    3.1. Task for build suite cases launch map from your test-classes:\n    ```\n    \"suite-builder\": \"suite-builder\",\n    ```  \n    3.2. Update LaunchMap and compile all tests before run tests:  \n    ```\n    \"pretest\": \"suite-builder tests/ \u0026\u0026 tsc\",\n    ```  \n    3.3. Run tests in suite:\n    ```\n    \"test\": \"node tests/suite.js\"\n    ```\n    \nNow, you can use one simple command `npm test` for rebuild and run you tests!\n\n### Conventions: \nYour test-classes must:\n1. extend one of next base classes:\n    - AbstractUnitTestCase\n    - AbstractDomTestCase\n2. end with \"Test.ts\", for example `FooBarTest.ts`\n3. test methods must be starting with \"test\" prefix, for example `public testCalculateValue(){}`\n \n### Workflow\n\nSee more info in [project wiki on github](https://github.com/FreeElephants/TSxUnit/wiki). \n\n#### AbstractUnitTestCase\nBase test class has basic assertions and can be useful for unit-testing environment independent (or Node.js code). \nYou can use mockBuilder for prepare Fake objects, based on abstract or normal TypeScript classes and JavaScript Objects. \nThis Builder based on [JSMockito](https://github.com/cleishm/jsmockito). \n  \n#### AbstractDomTestCase\nAbstractDomTestCase extend AbstractUnitTestCase and designed for test client-side code.\nIt contain assertions for DOM inspection, like assertElementHasClass(), assertElementExists(), assertElementsCount() etc.\nFor create virtual Document use DocumentBuilder: it can prepare document with HTML-fixture from local file or url. \nAlso you can create Window with WindowBuilder and Location object with LocationBuilder, dispatch Events and make most manipulation with DOM in tests runned from CLI, without real browser.    \nThis implementation based on [jsdom](https://github.com/tmpvar/jsdom). \n\n#### How it's work? \nAfter your complete all installation steps, npm task `test` in your package.json run file tests/suite.js.\nPretest task call LaunchBuilder: it collect all *Test.ts files, generate map of test cases and compile all test code from TS to JS.\n\n### For Contributors: \n\nClone this repo: \n\n```\n$ git clone git@github.com:FreeElephants/TSxUnit.git \n```\n\nInstall dependencies:\n\n```\n$ npm install\n```\n\nTo run tests use:\n\n```\n$ npm test\n```\n\nThis script (re-)build launch-builder tool, update LaunchMap, compile and run tests, compute coverage. \nSee package.json for details. \n\n### Test coverage (interactive)\n\n#### Cover your project with TSxUnit\n\nInstall `istanbul` and `remap-istanbul`:\n```\nnpm install istanbul remap-istanbul --save-dev\n```\n\nAdd task as npm script:\n```\n\"scripts\": {\n    ...\n    \"istanbul\": \"istanbul\",\n    \"remap-istanbul\": \"remap-istanbul\",\n    \"coverage\": \"npm run pretest \u0026\u0026 rm -rf coverage/* \u0026\u0026 istanbul cover tests/suite.js \u0026\u0026 remap-istanbul --input coverage/coverage.json --output coverage/html-report --type html \u0026\u0026 remap-istanbul --input coverage/coverage.json --output coverage/coverage-final.json\"\n    ...\n```\n\nConfigure you tests transpiling with sourceMap:\n```\n# update package.json\n\"scripts\": {\n    ...\n    \"pretest\": \"suite-builder tests/ \u0026\u0026 tsc \u0026\u0026 tsc tests/suite.ts --sourceMap\",\n    ...\n}\n\n# or via tests/tsconfig.json:\n{\n  \"compilerOptions\": {\n    ...\n    \"sourceMap\": true\n    ...\n    },\n    ...\n}\n```\n\nNow you can run tests with coverage analysis:\n```\nnpm run coverage\n```\n\n#### Current state of project\n\nClick on graph, and it will opens separately. You can click any rectangle to see code coverage of represented class.\n\n![Test coverage grapth](https://codecov.io/gh/FreeElephants/TSxUnit/branch/master/graphs/tree.svg \"Test coverage graph\")\n\nSee [ROADMAP](ROADMAP.md) for planned features. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreeelephants%2Ftsxunit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreeelephants%2Ftsxunit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreeelephants%2Ftsxunit/lists"}