{"id":16720959,"url":"https://github.com/prior99/test-decorators","last_synced_at":"2025-07-31T22:40:03.724Z","repository":{"id":82791092,"uuid":"119383142","full_name":"Prior99/test-decorators","owner":"Prior99","description":"Test decorators provides a set of decorators to run javascript unit tests with.","archived":false,"fork":false,"pushed_at":"2018-03-16T22:44:41.000Z","size":80,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T08:55:11.352Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Prior99.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-29T13:02:33.000Z","updated_at":"2024-03-01T02:29:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"116c252b-6b1e-4cc5-9b8f-be55974f449b","html_url":"https://github.com/Prior99/test-decorators","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prior99%2Ftest-decorators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prior99%2Ftest-decorators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prior99%2Ftest-decorators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prior99%2Ftest-decorators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Prior99","download_url":"https://codeload.github.com/Prior99/test-decorators/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248198879,"owners_count":21063628,"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":[],"created_at":"2024-10-12T22:27:38.672Z","updated_at":"2025-04-10T10:05:40.722Z","avatar_url":"https://github.com/Prior99.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Test Decorators\n\n[![npm](https://img.shields.io/npm/v/test-decorators.svg)](https://www.npmjs.com/package/test-decorators)\n[![Build Status](https://travis-ci.org/Prior99/test-decorators.svg?branch=master)](https://travis-ci.org/Prior99/test-decorators)\n[![Coverage Status](https://coveralls.io/repos/github/Prior99/test-decorators/badge.svg?branch=master)](https://coveralls.io/github/Prior99/test-decorators?branch=master)\n\nTest decorators provides a set of decorators to run javascript unit tests with.\n\nPlease also refer to the **[Documentation](https://prior99.github.io/test-decorators/docs/index.html)**.\n\n## Table of contents\n\n * [Test Decorators](#test-decorators)\n     * [Table of contents](#table-of-contents)\n     * [Suites](#suites)\n     * [Tests](#tests)\n     * [Parameterizing](#parameterizing)\n     * [Configuration](#configuration)\n     * [Contributing](#contributing)\n         * [Building](#building)\n         * [Running the tests with coverage](#running-the-tests-with-coverage)\n         * [Linting](#linting)\n         * [Starting the example](#starting-the-example)\n     * [Contributors](#contributors)\n\n## Suites\n\nInstead of writing `describe`, define a class and decorate it with `@suite`:\n\n```typescript\nimport { suite } from \"test-decorators\";\n\n@suite\nclass TestSuite {\n}\n```\n\nThe decorator takes optional options as arguments, to provide a name or have `describe.only` called\ninstead:\n\n```typescript\nimport { suite } from \"test-decorators\";\n\n@suite(\"The name provided to describe\")\nclass TestSuite {\n}\n```\n\n```typescript\n@suite({\n    name: \"The name provided to describe\",\n    only: true\n})\nclass TestSuite {\n}\n```\n\nIf no name is provided, the name of the class is used.\n\n## Tests\n\nInstead of writing `it`, define a class decorated with `@suite` and provide methods decorated with `@test`:\n\n```typescript\nimport { suite, test } from \"test-decorators\";\n\n@suite\nclass TestSuite {\n    @test\n    private testSomething() {\n        ...\n    }\n}\n```\n\nThe decorator takes optional options as arguments, to provide a name or have `test.only` called\ninstead:\n\n```typescript\n@test(\"test something\")\nprivate testSomething() {\n    ...\n}\n```\n\n```typescript\n@test({\n    name: \"test something\",\n    only: true\n})\nprivate testSomething() {\n    ...\n}\n```\n\nIf no name is provided, the name of the method is used.\n\n## Parameterizing\n\nIt is possible to parameterize the tests to have them called with different inputs:\n\n```typescript\n@test({\n    name: \"test something\",\n    only: true,\n    params: [-1, 0, 1, 10, 1000, 2000]\n})\nprivate testSomething(input) {\n    ...\n}\n```\n\nThe test will be executed once with every parameter specified.\n\nThe name can be generated from the parameters to increase readability:\n\n```typescript\n@test({\n    name: ({ a, b, expected }) =\u003e `${a} + ${b} is ${expected}`,\n    only: true,\n    params: [\n        { a: -1, b: 1, expected: 0 },\n        { a: 0, b: 0, expected: 0 },\n        { a: 100, b: 1, expected: 101 }\n    ]\n})\nprivate testSomething({ a, b, expected }) {\n    expect(a + b).tobe(expected);\n}\n```\n\n## Configuration\n\nThis library should work out of the box with jest and mocha compatible framework without any\nadditional configuration needed. Otherwise it is possible to configure it and provide\nmocha-compatible functions:\n\n```typescript\nimport { configure } from \"test-decorators\"\n\nconfigure({\n    it: () =\u003e { ... },\n    itOnly: () =\u003e { ... },\n    describe: () =\u003e { ... },\n    describeOnly: () =\u003e { ... },\n});\n```\n\n## Contributing\n\nYarn is used instead of npm, so make sure it is installed, probably: `npm install -g yarn`.\n\nInstall all dependencies using\n\n```\nyarn install\n```\n\n### Building\n\nIn order to build the code:\n\n```\nyarn build\n```\n\n### Running the tests with coverage\n\n```\nyarn test\n```\n\n### Linting\n\n```\nyarn lint\n```\n\n### Starting the example\n\n```\ncd example\nyarn test\n```\n\n## Contributors\n\n - Frederick Gnodtke\n - Sergej Kasper\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprior99%2Ftest-decorators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprior99%2Ftest-decorators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprior99%2Ftest-decorators/lists"}