{"_id":"@aminzer/describe-function-test","_rev":"1-aa0d0a0e725103c44aa24a2b62c37ae0","name":"@aminzer/describe-function-test","dist-tags":{"latest":"1.0.0"},"versions":{"0.0.2":{"name":"@aminzer/describe-function-test","version":"0.0.2","keywords":["tests","jest"],"author":{"name":"aminzer"},"license":"MIT","_id":"@aminzer/describe-function-test@0.0.2","maintainers":[{"name":"aminzer","email":"minzer.alexey@gmail.com"}],"homepage":"https://github.com/aminzer/describe-function-test#readme","bugs":{"url":"https://github.com/aminzer/describe-function-test/issues"},"dist":{"shasum":"aa6979de25746d3f0427aa32beaae48f763a01ad","tarball":"https://registry.npmjs.org/@aminzer/describe-function-test/-/describe-function-test-0.0.2.tgz","fileCount":30,"integrity":"sha512-a4K1wTM2cyB0oZukfGyvg0nYl4zSJibzqoLuTGJpVkpSX49jxY0/cniCdxVeeex415ZQ2iy/syZaaXTwLNLtoA==","signatures":[{"sig":"MEQCIAFoSuUkV06gybGB3n1paxTVVEnsg+WbNpTRLocnvRHcAiBKZ0o9O7KWxphg0NIrtdziQhbJo3NV3M/ZlI2Z2oI/0Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16148},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=12.0.0"},"gitHead":"6d1d5fe845bcdcb99fe740ecab55db8652f2f0d9","scripts":{"lint":"eslint src/**/*.ts test/**/*.ts","test":"jest","build":"tsc --project tsconfig.build.json","clean":"rimraf dist","prepare":"npm run rebuild","rebuild":"run-s clean build","lint:fix":"npm run lint -- --fix"},"_npmUser":{"name":"aminzer","email":"minzer.alexey@gmail.com"},"repository":{"url":"git+https://github.com/aminzer/describe-function-test.git","type":"git"},"_npmVersion":"8.15.0","description":"Simple helper for defining Jest tests for functions","directories":{},"_nodeVersion":"16.17.0","dependencies":{"app-root-path":"^3.1.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","eslint":"^8.39.0","rimraf":"^5.0.0","ts-jest":"^29.1.0","prettier":"^3.2.5","typescript":"5.0.4","@types/jest":"^29.5.1","@types/node":"^18.16.0","npm-run-all":"^4.1.5","eslint-plugin-jest":"^27.2.1","eslint-plugin-import":"^2.27.5","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.1.3","@typescript-eslint/parser":"^5.59.1","eslint-config-airbnb-base":"^15.0.0","eslint-config-airbnb-typescript":"^17.0.0","@typescript-eslint/eslint-plugin":"^5.59.1"},"_npmOperationalInternal":{"tmp":"tmp/describe-function-test_0.0.2_1721070975899_0.8080833113755734","host":"s3://npm-registry-packages"}},"1.0.0":{"name":"@aminzer/describe-function-test","version":"1.0.0","description":"Simple helper for defining Jest tests for functions","keywords":["tests","jest"],"repository":{"type":"git","url":"git+https://github.com/aminzer/describe-function-test.git"},"license":"MIT","author":{"name":"aminzer"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc --project tsconfig.build.json","clean":"rimraf dist","lint":"eslint src/**/*.ts test/**/*.ts","lint:fix":"npm run lint -- --fix","prepare":"npm run rebuild","rebuild":"run-s clean build","test":"jest"},"dependencies":{"app-root-path":"^3.1.0"},"devDependencies":{"@types/jest":"^29.5.1","@types/node":"^18.16.0","@typescript-eslint/eslint-plugin":"^5.59.1","@typescript-eslint/parser":"^5.59.1","eslint":"^8.39.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-airbnb-typescript":"^17.0.0","eslint-config-prettier":"^9.1.0","eslint-plugin-import":"^2.27.5","eslint-plugin-jest":"^27.2.1","eslint-plugin-prettier":"^5.1.3","jest":"^29.5.0","npm-run-all":"^4.1.5","prettier":"^3.2.5","rimraf":"^5.0.0","ts-jest":"^29.1.0","typescript":"5.0.4"},"engines":{"node":">=12.0.0"},"gitHead":"6cb2174478e25aaf8f40f05fc8eb2b3beab95bc3","bugs":{"url":"https://github.com/aminzer/describe-function-test/issues"},"homepage":"https://github.com/aminzer/describe-function-test#readme","_id":"@aminzer/describe-function-test@1.0.0","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-13XO0XFpfSPds3mYFf+yzjTP7Pew1y6+sjJQ4nyx3xdYQQHGddNPJKj6NUCEg+I+tO+LvDA+R2k7EWdjK5ClgA==","shasum":"cfad1e39094f9ee13102871c57a60d057b55e61f","tarball":"https://registry.npmjs.org/@aminzer/describe-function-test/-/describe-function-test-1.0.0.tgz","fileCount":30,"unpackedSize":16148,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCbUIrHgNQessAohN6BlGRokczWNJjru+jLFjIpRhMkfAIgBRgMu520wlMDLO7I4xFr3OC0pee7sHeF3oZg2e6PgcQ="}]},"_npmUser":{"name":"aminzer","email":"minzer.alexey@gmail.com"},"directories":{},"maintainers":[{"name":"aminzer","email":"minzer.alexey@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/describe-function-test_1.0.0_1721072663443_0.23616615006817443"},"_hasShrinkwrap":false}},"time":{"created":"2024-07-15T19:16:15.806Z","modified":"2024-07-15T19:44:23.813Z","0.0.2":"2024-07-15T19:16:16.086Z","1.0.0":"2024-07-15T19:44:23.648Z"},"bugs":{"url":"https://github.com/aminzer/describe-function-test/issues"},"author":{"name":"aminzer"},"license":"MIT","homepage":"https://github.com/aminzer/describe-function-test#readme","keywords":["tests","jest"],"repository":{"type":"git","url":"git+https://github.com/aminzer/describe-function-test.git"},"description":"Simple helper for defining Jest tests for functions","maintainers":[{"name":"aminzer","email":"minzer.alexey@gmail.com"}],"readme":"## @aminzer/describe-function-test\r\n\r\nSimple helper for defining Jest tests for functions.\r\n\r\n### Usage example\r\n\r\nExample function:\r\n```typescript\r\nconst formatGreeting = ({ personName }: { personName?: string } = {}): string => {\r\n  if (personName) {\r\n    return `Welcome, ${personName}!`;\r\n  }\r\n\r\n  return `Welcome!`;\r\n};\r\n\r\nexport default formatGreeting;\r\n```\r\n\r\nExample test:\r\n```typescript\r\nimport { describeFunctionTest } from '@aminzer/describe-function-test';\r\nimport formatGreeting from './formatGreeting';\r\n\r\ndescribeFunctionTest(formatGreeting, __filename, {\r\n  testCases: [\r\n    {\r\n      description: 'when no arguments are passed',\r\n      args: [],\r\n      expectedResult: 'Welcome!',\r\n    },\r\n    {\r\n      description: 'when person name is passed',\r\n      args: [{ personName: 'Mike' }],\r\n      expectedResult: 'Welcome, Mike!',\r\n    },\r\n  ],\r\n});\r\n\r\n```\r\n\r\n### API\r\n\r\n**describeFunctionTest**\r\n\r\n##### Overview\r\n\r\n`describeFunctionTest` is used for defining a test for the provided function with predefined test cases.\r\nIt's using native Jest `describe` function under the hood.\r\n\r\n##### Import\r\n```typescript\r\nimport { describeFunctionTest } from '@aminzer/describe-function-test';\r\n```\r\n\r\n##### Parameters\r\n\r\n* `functionToTest` (`function`, required) - function to be tested.\r\n* `testFilePath` (`string`, required) - Path to the test file. `__filename` can be used here.\r\n* `options` (`object`, required) - test settings.\r\n\r\n`options` object accepts the following arguments:\r\n* `testCases` (`TestCase[]`, optional) - non-grouped test cases to be verified.\r\n* `testCaseGroups` (`{ description: string, testCases: TestCase[], only?: boolean }[]`, optional) - grouped test cases to be verified.\r\n* `prepareResult` (`function`, optional) - function to format actual and expected test results before comparison. If not provided - the results are compared as is.\r\n* `beforeAll` (`function`, optional) - function that's passed as an argument to Jest `beforeAll` call for all tests.\r\n* `afterAll` (`function`, optional) - function that's passed as an argument to Jest `afterAll` call for all tests.\r\n\r\n`TestCase<Args extends unknown[], Result>` type contains:\r\n* `description` (`string`, optional) - test case description.\r\n* `args` (`Args`, required) - array of arguments that are passed to the tested function in this test case.\r\n* `expectedResult` (`Result`, required) - expected function call return value for the passed args.\r\n* `additionalAssertion` (`function`, optional) - additional checks that need to be verified in this test case.\r\n* `only` (`boolean`, optional) - if `true` - this test case is defined with Jest `describe.only` call.\r\n\r\n##### Return value\r\n\r\n`void`, nothing is returned.\r\n\r\n**formatTestName**\r\n\r\n##### Overview\r\n\r\n`formatTestName` is used for generation of test name in format `path > to > tested > file`.\r\n\r\n##### Import\r\n```typescript\r\nimport { formatTestName } from '@aminzer/describe-function-test';\r\n```\r\n\r\n##### Parameters\r\n\r\n* `testFilePath` (`string`, required) - Path to the test file. `__filename` can be used here.\r\n\r\n##### Return value\r\n\r\n`string` - formatted test name.\r\n","readmeFilename":"README.md"}