{"_id":"cypress-types","_rev":"3318251","name":"cypress-types","description":"A vitejs plugin which automatically incorporates your own Cypress \"commands\" into Cypress's typing definition","dist-tags":{"latest":"0.1.0"},"maintainers":[{"name":"ksnyde","email":"ken+oss@ken.net"}],"time":{"modified":"2024-06-11T08:58:04.000Z","created":"2022-05-19T21:53:26.254Z","0.1.0":"2022-05-19T21:53:26.254Z"},"users":{},"author":{"name":"Ken Snyder","email":"ken@ken.net"},"versions":{"0.1.0":{"name":"cypress-types","description":"A vitejs plugin which automatically incorporates your own Cypress \"commands\" into Cypress's typing definition","version":"0.1.0","author":{"name":"Ken Snyder","email":"ken@ken.net"},"license":"MIT","main":"dist/index.mjs","scripts":{"build":"tsup src/index.ts --format esm --dts","watch":"tsup src/index.ts --format esm --dts --watch","test":"vitest"},"dependencies":{"cypress":"^9.6.1","ts-morph":"^14.0.0","vite":"^2.9.9"},"devDependencies":{"@types/node":"16","@vitest/ui":"^0.12.6","tsup":"^5.12.8","typescript":"^4.6.4","vitest":"^0.12.6"},"types":"./dist/index.d.ts","gitHead":"cd0b7c360687e791c1789da3506041d21e7caf51","_id":"cypress-types@0.1.0","_nodeVersion":"16.15.0","_npmVersion":"8.5.5","dist":{"shasum":"5a1592d721873c05b6e016b02d323a9be7213cbf","size":2939,"noattachment":false,"key":"/cypress-types/-/cypress-types-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/cypress-types/download/cypress-types-0.1.0.tgz"},"_npmUser":{"name":"ksnyde","email":"ken@ken.net"},"directories":{},"maintainers":[{"name":"ksnyde","email":"ken+oss@ken.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cypress-types_0.1.0_1652997206114_0.8255810157755383"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-05-19T21:53:33.664Z","publish_time":1652997206254,"_cnpm_publish_time":1652997206254}},"readme":"# Cypress Types\n\nCypress provides the means to add commands to the Cypress command API but if you're using Typescript -- which of course you _should be_ -- then your commands are not typed [sad face].\n\nThis plugin addresses that shortcoming.\n\n## Usage\n\nIn your `vite.config.ts` file you'll the following:\n\n```ts\nimport CypressTypes from \"cypress-types\";\n\nexport default defineConfig({\n    // ...\n    plugins: [\n        // ...\n        CypressTypes()\n    ]\n})\n```\n\nWith that added, your \"commands\" file will be analyzed at build time along as whenever a new command is updated and the type will then be made available immediately in a fully typed manner.\n\nBefore it will fully work ... one more piece of good news. Instead of doing something like the following:\n\n```ts\nCypress.Commands.add('foobar', (foo: string) => {\n  return `foo may be ${foo}, but bar is better!`;\n})\n```\n\nInstead just export a functions like so:\n\n```ts\nexport function foobar(foo: string) {\n    return `foo may be ${foo}, but bar is better!`;\n}\n```\n\nThe Vite plugin will detect the commands file being updated and it's type will be computed and made available. Soon your increased productivity when dealing _foobar_ will be so good that people will pull you aside and ask you what you're doing and whether you can get \"some of that stuff\" for them. Feel free to tell them or you can simply awkwardly laugh and then excuse yourself from the room.\n\n## Directories\n\nBy default Cypress sets up in the repo's `/cypress` directory and then there is a subdirectory `/cypress/support` where you're supposed to put your `index.ts` file full of goodies. This is where this plugin will look by default but because we sense you're the \"rebel without a cause\" type you might change the location (I sure do) and that's fine. Changing this directory is simply a matter of stating that in your `cypress.json` file:\n\n```json\n{\n    \"commandsFolder\": \"test/integration/support\"\n}\n```\n\nNow if you -- by chance -- don't have a `cypress.json` file at the root of your repo then:\n\n1. you should probably get your head checked\n2. you can alternatively set the COMMANDS_FOLDER environment variable to direct us to the right place\n","_attachments":{},"license":"MIT"}