{"id":13683689,"url":"https://github.com/Testy/TestyTs","last_synced_at":"2025-04-30T13:31:46.194Z","repository":{"id":33490548,"uuid":"152934879","full_name":"Testy/TestyTs","owner":"Testy","description":"✔️ Decorator-based TypeScript testing framework experiment.","archived":false,"fork":false,"pushed_at":"2023-03-06T02:28:09.000Z","size":1528,"stargazers_count":123,"open_issues_count":17,"forks_count":8,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-20T19:36:39.817Z","etag":null,"topics":["test-driven-development","testing","testing-framework","typescript"],"latest_commit_sha":null,"homepage":"http://testy.github.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Testy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-10-14T03:12:58.000Z","updated_at":"2025-02-28T11:24:04.000Z","dependencies_parsed_at":"2024-01-14T17:13:26.274Z","dependency_job_id":"fbd6719a-b26a-4b8e-9f12-43a913764548","html_url":"https://github.com/Testy/TestyTs","commit_stats":{"total_commits":484,"total_committers":6,"mean_commits":80.66666666666667,"dds":"0.14462809917355368","last_synced_commit":"37942f295a93e36e11875741db4987e269c782c0"},"previous_names":["aboisier/testyts"],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Testy%2FTestyTs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Testy%2FTestyTs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Testy%2FTestyTs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Testy%2FTestyTs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Testy","download_url":"https://codeload.github.com/Testy/TestyTs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251712896,"owners_count":21631461,"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":["test-driven-development","testing","testing-framework","typescript"],"created_at":"2024-08-02T13:02:23.359Z","updated_at":"2025-04-30T13:31:45.334Z","avatar_url":"https://github.com/Testy.png","language":"TypeScript","readme":"![Test](https://github.com/Testy/TestyTs/workflows/Test/badge.svg)\n[![codecov](https://codecov.io/gh/Testy/TestyTs/branch/master/graph/badge.svg)](https://codecov.io/gh/Testy/TestyTs)\n[![npm version](https://badge.fury.io/js/testyts.svg)](https://badge.fury.io/js/testyts)\n[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://clicktotweet.co/daN8y)\n\n\u003cimg src=\"./img/testy_colour_rgb_transparent.png\" alt=\"Shoutout to Kateryna Jones for that sweet logo!\" /\u003e\n\n### Testy.Ts is a modern TypeScript testing framework.\n\n## Why?\n\nWriting tests should be fun. The other testing framework solutions do not make use of the full power of TypeScript. This one uses decorators and OOP and stuff. Therefore, it makes writing tests fun.\n\n## Installation\n\n```\n$ npm install --save-dev testyts\n$ npm install -g testyts\n```\n\n## Setup\n\nTo generate a basic testy.json configuration file, use the following command. To see all available configurations, see [this section](#configuration-file).\n\n```\n$ testyts init\n```\n\n## Write some tests\n\n### The basics\n\nWriting tests with Testy is simple. Don't forget to export your test suites though. Otherwise, they won't be discovered by the test runner.\n\n```ts\n@TestSuite()\nexport class MyTestSuite {\n  @Test()\n  onePlusOne() {\n    // Act\n    const result = 1 + 1;\n\n    // Assert\n    expect.toBeEqual(result, 2);\n  }\n}\n```\n\n### Setup and teardown\n\nTesty provides setup and teardown hooks.\n\n```ts\n@TestSuite()\nexport class MyTestSuite {\n  @BeforeAll()\n  beforeAll() {\n    // This is executed before all the tests\n  }\n\n  @BeforeEach()\n  beforeEach() {\n    // This is executed before each test\n  }\n\n  @AfterEach()\n  afterEach() {\n    // This is executed after each test\n  }\n\n  @AfterAll()\n  afterAll() {\n    // This is executed after all the tests\n  }\n}\n```\n\nIf you need to setup global stuff, you may do so by specifying a setup file in your `testy.json`.\n\n_testy.json_\n\n```json\n{\n  \"setupFile\": \"test-setup.ts\"\n}\n```\n\n_test-setup.ts_\n\n```ts\n// Import modules here, setup global variables, the whole nine yards\nglobal['foo'] = 'I can be used in test 😎';\n```\n\n### Asynchronous stuff\n\nAsynchronous tests, setup and teardown methods are supported out of the box. Just make your method async.\n\n```ts\n@TestSuite()\nexport class MyTestSuite {\n  @Test()\n  async asyncTest() {\n    // Asynchronous stuff\n  }\n}\n```\n\n### Timeout\n\nIf a test is taking too long to complete, it will fail automatically. The default timeout it 2000 ms, but you can configure it. Please note that the `Timeout` decorator goes after the `Test` decorator.\n\n```ts\n@TestSuite()\nexport class MyTestSuite {\n  @Test()\n  @Timeout(100000) // Really slow test\n  slowTest() {\n    // Some test\n  }\n}\n```\n\n### Reuse code!\n\nThis is where stuff gets interesting. Testy allows you to use base test classes. The base test can have setup and teardown methods. Your child test suite may also have setup and teardown methods. In that case, the base test methods are executed first.\n\n```ts\nclass MyBaseTestSuite {\n  // Setup/teardown extravaganza\n}\n\n@TestSuite()\nclass MyTestSuite extends MyBaseTestSuite {\n  // My tests\n}\n```\n\n### Test cases\n\nYou can easily run the same test with different inputs using the `TestCase` decorator. The first argument is the test case name, the following arguments will be\npassed to your test method. Please note this decorator goes after the `@Test` decorator.\n\n```ts\n@TestSuite()\nexport class MyTestSuite {\n  @Test()\n  @TestCase('Two plus two is four', 2, 2, 4)\n  @TestCase(`Minus one that's three`, 4, -1, 3)\n  addition(a: number, b: number, result: number) {\n    expect.toBeEqual(a + b, result);\n  }\n}\n```\n\n### Asserting\n\nThere's a whole bunch of assertion methods and also a dash of syntactic sugar sexyness in the expect class.\n\n```ts\nexpect.toBeTrue(2 \u003e 1);\nexpect.toBeEqual('a', 'a');\nexpect.not.toBeEqual('p', 'np');\nexpect.toThrow(() =\u003e someNastyMethod());\nexpect.toBeSorted.inAscendingOrder([0, 1, 1, 2, 3, 5, 8]);\n// More!\n```\n\n### Ignoring or focusing some tests\n\nYou can ignore tests by calling the `ignore` method on a test suite or a test decorator. Ignored tests will still show up in the test report, but they will be marked as ignored.\n\n```ts\n@TestSuite.ignore() // This test suite will be ignored\nexport class MyTestSuite {\n  // Your tests\n}\n\n@TestSuite()\nexport class MyTestSuite {\n  @Test.ignore() // This test will be ignored\n  onePlusOne() {\n    // Some test\n  }\n}\n```\n\nYou can also focus tests by calling the `focus` method on a test suite or a test decorator. If at least one test or test suite is focused, only focused tests or tests within a focused test suite will be run. The others will be reported as ignored. Ignored tests inside focused test suite will remain ignored.\n\n```ts\n@TestSuite.focus() // This test suite will be focused.\nexport class MyTestSuite {\n...\n}\n\n@TestSuite()\nexport class MyTestSuite {\n\n    @Test.focus() // This test will be focused\n    onePlusOne() {\n       // Your test\n    }\n}\n```\n\n## Custom tests and test suites names\n\nThe tests and test suites names are inferred from the method or class name by default. You can specify a custom name.\n\n```ts\n@TestSuite('My glorious test suite')\nexport class MyTestSuite {\n  @Test('Adding one plus one, should equal two')\n  onePlusOne() {\n    // Act\n    const result = 1 + 1;\n\n    // Assert\n    expect.toBeEqual(result, 2);\n  }\n}\n```\n\n## Configuration file\n\n| Key               | Description                                                                                                                                                          | Type                                  | Note         |\n| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | ------------ |\n| `include`         | The [test loader](src\\lib\\utils\\testsLoader.ts) will look for tests in files that match any of those [glob patterns](https://www.npmjs.com/package/glob#glob-primer) | `string[]`                            | _Required_   |\n| `tsconfig`        | Alternate tsconfig for the test loader to use. If not specified, the loader will use the `tsconfig.json` in the current directory                                    | `string`                              | _Optional_   |\n| `timeout`         | Global test timeout. By default, the global timeout is 2000 ms. The global timeout will be overriden by test-level timeouts.                                         | `number`                              | _Optional_   |\n| `setupFile`       | A .ts or .js file that will be run before the tests run starts.                                                                                                      | `string`                              | _Optional_   |\n| `reporters`       | Output format.                                                                                                                                                       | `{[reporter: ReporterName]: object }` | Optional.    |\n| \u003cs\u003e`reporter`\u003c/s\u003e | Output format.                                                                                                                                                       | `'standard'` \u0026#124; `'TAP'`           | _Deprecated_ |\n\nExample configuration file:\n\n```json\n{\n  \"include\": [\"**/*.spec.ts\"],\n  \"tsconfig\": \"./tsconfig.spec.json\",\n  \"reporters\": {\n    \"standard\": {\n      \"color\": true\n    }\n  },\n  \"timeout\": 10000\n}\n```\n\n## Cli arguments\n\nCli arguments will override config file values.\n\n```\n-c --config \u003cconfig\u003e // Specify a testy.json configuration file\n-t --tsconfig \u003ctsconfig\u003e // Specify a tsconfig.json file\n-f --files \"\u003cfiles\u003e\" // Run only tests found in files matching the given glob patterns. A comma-separated list of glob patterns.\n-r --reporter \u003creporter\u003e // Specify a comma-separated list of reporters. Does not support reporters configs.\n--reporter \u003creporter\u003e // DEPRECATED. Specify a reporter. Either standard or TAP.\n```\n\n## Run the tests\n\nTo run the tests, use the following command\n\n```\n$ testyts\n$ testyts --config custom/config/file.json // To specify a custom configuration file\n$ testyts --tsconfig custom/tsconfig.json // To specify a custom typescript configuration file (tsconfig.json)\n$ testyts --files \"my-first-file.spec.ts,my-folder/**.spec.ts\" // To run tests in files matching the specified glob patterns\n```\n\n## More documentation\n\nThe [examples](./examples) folder contains example projects with various use-cases.\n\n- [Simple example](./examples/simple)\n- [Code coverage with NYC](./examples/code-coverage-nyc)\n\n## Try it out online!\n\nHere's an online [REPL](https://repl.it/@Aboisier/TestyTs-Playground) for you to try Testy.Ts!\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update unit tests and [e2e tests](./e2e/README.md) as appropriate.\n\nIf you have any questions, do not hesitate to email me at \u003caboisiermichaud@gmail.com\u003e.\n\n## More documentation\n\n- [E2E tests](./e2e/README.md)\n\n## License\n\n- [ISC](./LICENSE)\n\n## Code of conduct\n\nThe code of conduct can be consulted [here](./CODE_OF_CONDUCT.md).\n\n\u003cimg src=\"./img/testy_colour_rgb_transparent.png\" alt=\"Shoutout to Kateryna Jones for that sweet logo!\" width=\"150\"\u003e \u003cbr\u003e \u003csub\u003e_Shoutout to [Kateryna Jones](https://www.katerynajones.com/) for that sweet logo!_\u003c/sub\u003e\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTesty%2FTestyTs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTesty%2FTestyTs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTesty%2FTestyTs/lists"}