{"_id":"@cameronhunter/find-related-files","_rev":"2-6ec844822f32c60d5d1903895e1bcff1","name":"@cameronhunter/find-related-files","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@cameronhunter/find-related-files","version":"1.0.0","main":"build/lib.js","types":"build/lib.d.ts","bin":{"find-related-tests":"build/main.js"},"license":"MIT","scripts":{"start":"yarn build && ./build/main.js","build":"tsc && chmod +x ./build/main.js","build:diagrams":"dot -Tsvg -O ./docs/*.dot","test":"jest"},"dependencies":{"dependency-graph":"^0.11.0","glob":"^8.0.3","jest-config":"^29.3.1","jest-docblock":"^29.2.0","jest-resolve-dependencies":"^29.3.1","jest-runtime":"^29.3.1"},"devDependencies":{"@tsconfig/node18-strictest":"^1.0.0","@types/dedent":"^0.7.0","@types/glob":"^8.0.0","@types/jest":"^29.2.4","@types/node":"^18.11.15","dedent":"^0.7.0","jest":"^29.3.1","memfs":"^3.4.12","ts-jest":"^29.0.3","typescript":"^4.9.4"},"engines":{"node":">= 18"},"jest":{"preset":"ts-jest","testEnvironment":"node","testPathIgnorePatterns":["__fixtures__"]},"publishConfig":{"access":"public"},"description":"Find tests related to changed files, using a simple tagging mechanism.","_id":"@cameronhunter/find-related-files@1.0.0","dist":{"shasum":"afbb5855817ac1bf161b2660a17ab3ef6f9af09e","integrity":"sha512-mW4/0UOHGQ/xXgc/A20IPhOrlkCWssKzvYgX2XbTTaNwmAChBfTUaF5p9Fwfg/L8TEN/unu1FsS1bAMAhm5LLA==","tarball":"https://registry.npmjs.org/@cameronhunter/find-related-files/-/find-related-files-1.0.0.tgz","fileCount":6,"unpackedSize":12529,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHwrgsirLXn1LnuYwxQC3JK7Z6Nu7o3IOBjgIGl1gCbaAiEA6Cg/oAwKNRWEg4NaKlwN7GkwZGESck2F9iP07Nupgo0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjoNNwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoTzg//Y5PBWmjB9v/9adFuTBzmbPXjgskcIEX7MekwTLknjGQCfgtk\r\nhSrW4wEeKA2X+8lpjgu4x9XdoFNI9mYrCJpqLuQA9Hp00vz48BKsLj9hDF4X\r\nTigAUmSNQFc8DCMHvHWh3EGzqEVR/nnOR9OS+DofOyo5jMflk1YkxAjUmpVS\r\nLR5eSFMr3rJHs5w6iqlFQBb70vem9wb6vwceW1clviyCDjq0gvHey9XBqrOe\r\nvqmg3zZiMJziLSaEajSLLih1FZLVGQaR6aAEbqo0ubxYUInW4T2DBCEvPQpV\r\nXhUMJs3Zdqi5vGHva4P2AymK9Ow+LPQmgVK5/j6Y2nlxzBcMQ+oRFIZuYsXA\r\nI8Pk9dloTbWHu+5UZr+GtqIXOuK5Y5hO/R8eS/nTcwZLlZF8A+8Rch2Ztt2Z\r\nGZ8+gcWIDxdVwIoxQrMvbIpEXT5lM9eOolLDXd2n8z+BNWVV8L42kSVUAQWi\r\nLe2YJXYNr5e/ccWIt94uyQJDBZLeC/KVUK2p5bP1xn69bxd4xvvQHHluDJMd\r\noghfFfn9oPHKCepZesGFW4PQzEtzWQu4ZhlaTNumVKHVqptaYJ1/JiAf3iLw\r\nBwaiMjhHTDAdqaXNS3ZWOaDij3A6DrEda38j5kujEZhD1yu/5ordH0474ynB\r\nn1PxmdmbdSgEjy6kTVbB2gIvujoHYTGWld0=\r\n=d1LW\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"cameronhunter","email":"hello@cameronhunter.co.uk"},"directories":{},"maintainers":[{"name":"cameronhunter","email":"hello@cameronhunter.co.uk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/find-related-files_1.0.0_1671484272331_0.9014974557817255"},"_hasShrinkwrap":false},"1.0.1":{"name":"@cameronhunter/find-related-files","version":"1.0.1","main":"build/lib.js","types":"build/lib.d.ts","bin":{"find-related-tests":"build/main.js"},"license":"MIT","scripts":{"start":"yarn build && ./build/main.js","build":"tsc && chmod +x ./build/main.js","build:diagrams":"dot -Tsvg -O ./docs/*.dot","test":"jest"},"dependencies":{"jest-config":"^29.3.1","jest-docblock":"^29.2.0","jest-resolve-dependencies":"^29.3.1","jest-runtime":"^29.3.1"},"devDependencies":{"@tsconfig/node18-strictest":"^1.0.0","@types/dedent":"^0.7.0","@types/glob":"^8.0.0","@types/jest":"^29.2.4","@types/node":"^18.11.15","dedent":"^0.7.0","jest":"^29.3.1","memfs":"^3.4.12","ts-jest":"^29.0.3","typescript":"^4.9.4"},"engines":{"node":">= 18"},"jest":{"preset":"ts-jest","testEnvironment":"node","testPathIgnorePatterns":["__fixtures__"]},"publishConfig":{"access":"public"},"description":"Find tests related to changed files, using a simple tagging mechanism.","_id":"@cameronhunter/find-related-files@1.0.1","dist":{"shasum":"29fec84fd817a4f48a3371078d1dc660a80a464e","integrity":"sha512-Q8fr1BIicvVu27YsEBAjYwuMG4ObgtyQiWnhqERhPXbYRvzmP7DKKJeI01gV0RyfxGGfCCIDN9dLZuoKU13nXA==","tarball":"https://registry.npmjs.org/@cameronhunter/find-related-files/-/find-related-files-1.0.1.tgz","fileCount":8,"unpackedSize":19200,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHxMkySro6Td7OltgXxUdnSjDQ0/Kgwz9aECTixdmsvVAiEAzNlkn93Dt8azm+RstGjf89vXPhl95iGbbQWJuj3j4dg="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjoNunACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmraeBAAkl6Kc27LshoCRtby/uVrntygDrgBa0E3S0gzhjgHuB9iRU3l\r\no8OtKFYFycy8awUQ1HHoBS6xESgVdXT8kz+JZu64o4J/jUarvjPiT1yAr/Ad\r\nnkwCcjbcftR7VeddN0UqiVl7C3OPxFEi8b63sjc7jgrPQ4/voaVyxHoogM7R\r\na2nbdrqYwyXrqWQgHeNMQwKe/cSMMUKCKqquGi6ygrvt8gL9nuYZUsneS03l\r\ncEDujUS8LAGgMXuVBTl0fi0Ji0K9QTfh7nx6Q3ycsMRUx/lFLiw5P3iI6xm7\r\nMGItHb6bCGem5dcXLAmbbJCxrvkCYFOJgwkJr4JJJNhz9ltCiXGsZ3vxkvhv\r\nQyE7SlTUAysMZOr7wx8zZ1z2b7+w6snnsU62nwhwbmY26WZ0IQTgvZ7I6/2D\r\nQPNt3XV0v1YpenwgrJE/KVkm3h/lJ0t3DO0M+nGjskvlSi1tE8ybpBy6109f\r\nEsNXk7ROwgPqW6MA2pRosr1+bnyfwkpHRNNk0Ftc5WxaE1DZEqpiGXZaJBAr\r\n+anRUgogv3zF/8Ckd0XAU3xdZnrfhY+17QCUQpJn7JCR5qsSwUZrs7dOT2dm\r\nWhUyr91YGEckuLDaQTIL9KN7Dy9yRA+8Q3OSK6CQ1z1Kc9R53tGfo0dbW5Vh\r\nPS01ULS6DiZsG3Y73uc57dh7UvJhIFXjNN8=\r\n=7dgP\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"cameronhunter","email":"hello@cameronhunter.co.uk"},"directories":{},"maintainers":[{"name":"cameronhunter","email":"hello@cameronhunter.co.uk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/find-related-files_1.0.1_1671486375760_0.80285758248654"},"_hasShrinkwrap":false},"1.0.3":{"name":"@cameronhunter/find-related-files","version":"1.0.3","main":"build/lib.js","types":"build/lib.d.ts","bin":{"find-related-tests":"build/main.js"},"license":"MIT","scripts":{"start":"yarn build && ./build/main.js","build":"tsc && chmod +x ./build/main.js","build:diagrams":"dot -Tsvg -O ./docs/*.dot","test":"jest"},"dependencies":{"@jest/core":"^29.3.1","jest-config":"^29.3.1","jest-docblock":"^29.2.0","jest-resolve-dependencies":"^29.3.1","jest-runtime":"^29.3.1"},"devDependencies":{"@tsconfig/node18-strictest":"^1.0.0","@types/dedent":"^0.7.0","@types/glob":"^8.0.0","@types/jest":"^29.2.4","@types/node":"^18.11.15","dedent":"^0.7.0","jest":"^29.3.1","memfs":"^3.4.12","ts-jest":"^29.0.3","typescript":"^4.9.4"},"engines":{"node":">= 18"},"jest":{"preset":"ts-jest","testEnvironment":"node","testPathIgnorePatterns":["__fixtures__"]},"publishConfig":{"access":"public"},"description":"Find tests related to changed files, using a simple tagging mechanism.","_id":"@cameronhunter/find-related-files@1.0.3","dist":{"shasum":"4b52973dbaea7aa836e0ddc211f03834612c7d07","integrity":"sha512-AsGbHaHJHY8klRYeN1Y9aM4Pvh7mlC4W2vXhR8Kuhb4TsXvIWBuXU4ybjS52H+VNyFcpy7B/6TsP1yiTUr39SA==","tarball":"https://registry.npmjs.org/@cameronhunter/find-related-files/-/find-related-files-1.0.3.tgz","fileCount":8,"unpackedSize":19229,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBYtwdxVow+AjTeBwpoaa9j8GyKTyNdzfBo2MjOLX72fAiBqhL5suwW+mBT0m/WTcIJstLwmx8ibWNUXJCOcFTWFRA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjoN4bACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq8kBAAhnpr1UEcpmwoEOK3T1shEMgqOi1wwuPTijda7/x984YPgL9k\r\nieSP9Hq3RSRqyAsM4B7c2OCRJU0GpAixSj1IeSbsxXWNUfxgNaqAlk26cVEe\r\nCrcCVKKT4KE2wOFI0LWYVRkGBlvbHlifK20FRHvB0y66J1GEzH2wTAMtgi0F\r\nxJvd3aKQ8dO+144BgqBQmde/JdrJbLYYPBRKph9qCdejQYxs6aU5PlGqlP/A\r\nu5gMhMnapuJQTACLhqL+CH8IsGjr1tsZJZ/1L0nm+pt1/dNOOk7dNJ22MVx1\r\nteJZHcRyf8sNMSpataKuT3c5jlxVaY9hIXqFxReiDugUXlfxB8RLplIbRQdT\r\nGOGOGVA2Pz7Ic0e51alF2gV2scF8c4c1mRQv2Yx93XAQ2X/ekltJGXj1h7M+\r\nqRT3dwgTakZ3KOodx2KOfHAPZwCiNDXjj0mr8XO1d4EofPfCcPzLiXB5+YTt\r\nULPDlfvSftzPQd7W5FoPswVwYMmz1cTCoFxU/LrD6sV7Jsi/Q1n5hr5ggzM/\r\n0H7Bpcr/6hXadkCjyB9a5pLYz5gJJhs1iYCnGHZ00Y9jP1wBetO2UbcTTKXL\r\nKZzmZ79XT9oc7k8i0yBxPrZH2a0diukScLA6lCoUNkWSNnWeQZ9zbZ+hVS8d\r\nWNvvRJSRfk0ZukHMEBFFtN/yLdbwoe94OPg=\r\n=o0QS\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"cameronhunter","email":"hello@cameronhunter.co.uk"},"directories":{},"maintainers":[{"name":"cameronhunter","email":"hello@cameronhunter.co.uk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/find-related-files_1.0.3_1671487003030_0.19097691854231358"},"_hasShrinkwrap":false}},"time":{"created":"2022-12-19T21:11:12.250Z","1.0.0":"2022-12-19T21:11:12.517Z","modified":"2022-12-19T21:56:43.287Z","1.0.1":"2022-12-19T21:46:15.908Z","1.0.3":"2022-12-19T21:56:43.207Z"},"maintainers":[{"name":"cameronhunter","email":"hello@cameronhunter.co.uk"}],"description":"Find tests related to changed files, using a simple tagging mechanism.","license":"MIT","readme":"# Find Related Tests\n\nFind tests related to changed files, using a simple tagging mechanism.\n\n## Context\n\nTesting can be broadly split into two buckets: open-box and closed-box tests.\n\nUnit tests are \"open-box\" tests, they import a piece of code and place expectations and assertions on its behavior. The\nstatic import of the code under test makes it very easy to find related tests using a dependency graph. In fact, Jest\nprovides a CLI parameter for exactly this use-case: `--findRelatedTests` ([documentation](https://jestjs.io/docs/29.0/cli#--findrelatedtests-spaceseparatedlistofsourcefiles)).\n\nFunctional tests are \"closed-box\" tests, they do _not_ import code directly making it impossible to connect a change set\nto a list of related functional tests.\n\n## Connecting the dots\n\nThis library aims to connect the dots between code changes and functional tests.\nIt does this by building a dependency graph, like shown below:\n\n![A dependency graph](./docs/diagram_1.dot.svg)\n\nAs you can see, there is an application built of files that have dependencies on\neach other. There are functional tests (which we know do _not_ have a dependency\non the application), some of which may make use of a Page Object Model (POM) to\nhelp model how to programmatically interact with the application.\n\nWe begin by adding a [docblock](https://en.wikipedia.org/wiki/Docblock) to the\ntop of any application file we're interested in functionally testing. We could\nstart with just the top-level routes, but these could be anywhere in the\napplication we want.\n\n```ts\n/**\n * @tag search\n */\n```\n\nWe can also add tags to the functional test files to specify which \"tags\" we're\ntesting. Here's an example of how we could annotate our example application:\n\n![An annotated dependency graph](./docs/diagram_2.dot.svg)\n\nNotice that we don't need to annotate every file.\n\nOK, it's time to put this into action.\n\nLet's say that a developer makes a change to `Button.js`. The library will build\nan _inverse_ dependency graph, and collect tags from all dependent files (as\nwell as the tags specified in `Button.js`).\n\n![How tags are found](./docs/diagram_3.dot.svg)\n\nBy following the inverse dependencies from `Button.js`, we can see that it is\nused in `Keyboard` and `Menu`, and those components are used in `Profiles`,\n`Search`, and `Details`. This results in these tags:\n\n```ts\n['button', 'details', 'keyboard', 'profiles', 'search'];\n```\n\nWe can use these to find all tests which contain any of these tags. For our\nchange to `Button.js`, this will be:\n\n```ts\n['button.test.js', 'details.test.js', 'keyboard.test.js', 'search.test.js', 'smoke.test.js'];\n```\n\nNotice that `smoke.test.js` is included – this is because we use the dependency\ngraph to associate tags with tests. This enables us to implicitly tag tests when\nwe use shared libraries, such as the Page Object Model.\n\nAs a second example, changing `Synopsis.js` would result in:\n\n```ts\n['browse.test.js', 'details.test.js', 'smoke.test.js'];\n```\n\nThis dramatically reduces the number of tests that we need to run, while\n_knowing_ that we're not losing coverage. We're simply testing only what needs\nto be tested.\n\nSee the tests for further examples: [test/lib.test.ts](test/lib.test.ts).\n\n## Usage\n\n```sh\nnpm install @cameronhunter/find-related-tests\n```\n\nYou can use this as a library:\n\n```ts\nimport { Project } from '@cameronhunter/find-related-tests';\n\nconst project = new Project('jest.config.js');\n\nconst changedFiles = ['application/components/Button.js'];\n\nconst relatedTests = await project.findRelatedTests(changedFiles);\n```\n\nOr as a CLI:\n\n```sh\n$ find-related-tests --config jest.config.js --file application/components/Button.js\napplication/__functional__/button.test.js\napplication/__functional__/details.test.js\napplication/__functional__/keyboard.test.js\napplication/__functional__/search.test.js\napplication/__functional__/smoke.test.js\n```\n","readmeFilename":"README.md"}