{"_id":"@bowtieddevops/bowtieddevops-test-package-6","_rev":"2-9d30f493919de60812c9a31c73082936","name":"@bowtieddevops/bowtieddevops-test-package-6","dist-tags":{"latest":"1.1.6"},"versions":{"0.1.1":{"name":"@bowtieddevops/bowtieddevops-test-package-6","version":"0.1.1","description":"Clarunit, enables writing unit tests in Clarity","main":"src/index.ts","bin":{"bowtieddevops-test-package-6":"src/cli.ts"},"type":"module","scripts":{"test":"vitest run -- --coverage"},"repository":{"type":"git","url":"git+ssh://git@github.com/stacks-network/stacks-test-tools.git"},"keywords":["stacks","blockchain","clarity","clarinet"],"author":{"name":"Clarity WG"},"contributors":[{"name":"Friedger Muffke"},{"name":"Marvin Janssen"},{"name":"Fernando Foy"},{"name":"Jesus Najera"},{"name":"Nikos Baxevanis"}],"license":"MIT","bugs":{"url":"https://github.com/stacks-network/stacks-test-tools/issues"},"homepage":"https://github.com/stacks-network/stacks-test-tools#readme","dependencies":{"@hirosystems/clarinet-sdk":"^2.4.1","@stacks/transactions":"^6.11.0","chokidar-cli":"^3.0.0","path":"^0.12.7","typescript":"^5.2.2","vite":"^5.2.6","vitest":"^1.4.0","vitest-environment-clarinet":"^2.0.0"},"devDependencies":{"fast-check":"^3.15.0"},"_id":"@bowtieddevops/bowtieddevops-test-package-6@0.1.1","gitHead":"8e77b1b7569bb2f4cd1bcad7acf661891fb2c558","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-Lo+9ZpF15G8iXuWlU97gW9wxnzjYC647uVnbM3kl59JdFbAUsme3HGxV8at2T/g18GAOAPxpsjFTS+MzRHhpUA==","shasum":"a1e1a023bcabe6b06e32672f538f759ebecc3025","tarball":"https://registry.npmjs.org/@bowtieddevops/bowtieddevops-test-package-6/-/bowtieddevops-test-package-6-0.1.1.tgz","fileCount":40,"unpackedSize":161940,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDM7kYoUlpFuPT0nibN3gENdiT/+MovqsIU8PF+ir/hhAiEAjgN9BZdHf4bDc0lDjUpcnAZmZt8awgk6KSrG5X/DJxk="}]},"_npmUser":{"name":"bowtieddevops","email":"bowtieddevops@gmail.com"},"directories":{},"maintainers":[{"name":"bowtieddevops","email":"bowtieddevops@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bowtieddevops-test-package-6_0.1.1_1712274873407_0.8031906167722975"},"_hasShrinkwrap":false},"1.1.1":{"name":"@bowtieddevops/bowtieddevops-test-package-6","version":"1.1.1","description":"Clarunit, enables writing unit tests in Clarity","main":"src/index.ts","bin":{"bowtieddevops-test-package-6":"src/cli.ts"},"type":"module","scripts":{"test":"vitest run -- --coverage"},"repository":{"type":"git","url":"git+ssh://git@github.com/stacks-network/stacks-test-tools.git"},"keywords":["stacks","blockchain","clarity","clarinet"],"author":{"name":"Clarity WG"},"contributors":[{"name":"Friedger Muffke"},{"name":"Marvin Janssen"},{"name":"Fernando Foy"},{"name":"Jesus Najera"},{"name":"Nikos Baxevanis"}],"license":"MIT","bugs":{"url":"https://github.com/stacks-network/stacks-test-tools/issues"},"homepage":"https://github.com/stacks-network/stacks-test-tools#readme","dependencies":{"@hirosystems/clarinet-sdk":"^2.4.1","@stacks/transactions":"^6.11.0","chokidar-cli":"^3.0.0","path":"^0.12.7","typescript":"^5.2.2","vite":"^5.2.6","vitest":"^1.4.0","vitest-environment-clarinet":"^2.0.0"},"devDependencies":{"fast-check":"^3.15.0"},"_id":"@bowtieddevops/bowtieddevops-test-package-6@1.1.1","gitHead":"31998eb16466f0508d6be59c908c0dcab52bd708","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-NLV/ZfUDHga4+3LaYFNpWFjqsEG5oZ70Tw/1CALExdnsr4A84Pu+MwVpvKD6fOmyWw6a6z1X/JU46shEwRXjew==","shasum":"dda14a721b23aec7dcda61ce11de9067cddb1bf9","tarball":"https://registry.npmjs.org/@bowtieddevops/bowtieddevops-test-package-6/-/bowtieddevops-test-package-6-1.1.1.tgz","fileCount":40,"unpackedSize":161940,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC4pUGPiOSQvP8oKozXSRdYpT8OThjhq7UF6SS90iWVsAiEAiMitisbur9tBwwZJSAVWEBGlfDjNnTksIy0Re/zCGGU="}]},"_npmUser":{"name":"bowtieddevops","email":"bowtieddevops@gmail.com"},"directories":{},"maintainers":[{"name":"bowtieddevops","email":"bowtieddevops@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bowtieddevops-test-package-6_1.1.1_1712275138283_0.9266757384751019"},"_hasShrinkwrap":false},"1.1.6":{"name":"@bowtieddevops/bowtieddevops-test-package-6","version":"1.1.6","description":"Clarunit, enables writing unit tests in Clarity","main":"src/index.ts","bin":{"bowtieddevops-test-package-6":"src/cli.ts"},"type":"module","scripts":{"test":"vitest run -- --coverage"},"repository":{"type":"git","url":"git+ssh://git@github.com/stacks-network/stacks-test-tools.git"},"keywords":["stacks","blockchain","clarity","clarinet"],"author":{"name":"Clarity WG"},"contributors":[{"name":"Friedger Muffke"},{"name":"Marvin Janssen"},{"name":"Fernando Foy"},{"name":"Jesus Najera"},{"name":"Nikos Baxevanis"}],"license":"MIT","bugs":{"url":"https://github.com/stacks-network/stacks-test-tools/issues"},"homepage":"https://github.com/stacks-network/stacks-test-tools#readme","dependencies":{"@hirosystems/clarinet-sdk":"^2.4.1","@stacks/transactions":"^6.11.0","chokidar-cli":"^3.0.0","path":"^0.12.7","typescript":"^5.2.2","vite":"^5.2.6","vitest":"^1.4.0","vitest-environment-clarinet":"^2.0.0"},"devDependencies":{"fast-check":"^3.15.0"},"_id":"@bowtieddevops/bowtieddevops-test-package-6@1.1.6","gitHead":"132df19ffe29fba1d8bdc7ed75eaa28f8c56d479","_nodeVersion":"20.12.0","_npmVersion":"10.5.0","dist":{"integrity":"sha512-3sXDE8/xhVmEJNJ36yi/4+sLmzBxEjmIZuLj544tkMbUtCeNn7p7fgckyu8SQAIc3s2DKGBbyAKWRwu6clZi9w==","shasum":"036d0e6e2cedd4913e2cc8b7333d455073161765","tarball":"https://registry.npmjs.org/@bowtieddevops/bowtieddevops-test-package-6/-/bowtieddevops-test-package-6-1.1.6.tgz","fileCount":40,"unpackedSize":161940,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAuXyo1WQMM9nEVZG1IPL5WTud/NEOK7ykBGWrkzRSbrAiAgic7gXX3qQaVZN8fLbz3uSrFR/468MgD8zihiQtyM7Q=="}]},"_npmUser":{"name":"bowtieddevops","email":"bowtieddevops@gmail.com"},"directories":{},"maintainers":[{"name":"bowtieddevops","email":"bowtieddevops@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bowtieddevops-test-package-6_1.1.6_1712324975687_0.5868012394031368"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-04T23:54:33.315Z","0.1.1":"2024-04-04T23:54:33.612Z","modified":"2024-04-05T13:49:36.051Z","1.1.1":"2024-04-04T23:58:58.452Z","1.1.6":"2024-04-05T13:49:35.889Z"},"maintainers":[{"name":"bowtieddevops","email":"bowtieddevops@gmail.com"}],"description":"Clarunit, enables writing unit tests in Clarity","homepage":"https://github.com/stacks-network/stacks-test-tools#readme","keywords":["stacks","blockchain","clarity","clarinet"],"repository":{"type":"git","url":"git+ssh://git@github.com/stacks-network/stacks-test-tools.git"},"contributors":[{"name":"Friedger Muffke"},{"name":"Marvin Janssen"},{"name":"Fernando Foy"},{"name":"Jesus Najera"},{"name":"Nikos Baxevanis"}],"author":{"name":"Clarity WG"},"bugs":{"url":"https://github.com/stacks-network/stacks-test-tools/issues"},"license":"MIT","readme":"# clarunit\n\nThis package allows you to write unit tests for Clarity smart contracts in the \nClarity language itself, as opposed to TypeScript. `clarunit` will automatically\ndetect test files and test functions.\n\nAn example Clarinet-sdk project using `clarunit` can be found in the `example`\nfolder.\n\n## Setup\n\n1. Install package `@stacks/clarunit` using your favourite package manager. (Be sure to\n   pin the version!)\n2. Create a test file in your existing `tests` folder, you can use any name but\n   using `clarunit.test.ts` is recommended.\n3. Add the following to the newly created file:\n   ```ts\n   import { clarunit } from \"clarunit\";\n   clarunit(simnet);\n   ```\n4. Run your tests per usual using `npm test` or `yarn test`.\n\n`clarunit` takes configuration from Clarinet via `Clarinet.toml`. It\nautomatically detects all instantiated test contracts.\n\n## Unit testing\n\n### Adding tests\n\nTo write unit tests, follow these steps:\n\n1. Create a new Clarity contract in the `./tests` folder. It can have any name\n   but it should end in `_test.clar`. Files that do not follow this convention\n   are ignored. (For example: `my-contract_test.clar` will be included and\n   `my-contract.clar` will not.)\n2. Add the new Clarity contract to `Clarinet.toml`.\n3. Write unit tests as public functions, the function name must start with\n   `test-`.\n\n### Writing tests\n\nUnit test functions should be public without parameters. If they return an `ok`\nresponse of any kind, the test is considered to have passed whereas an `err`\nindicates a failure. The failure value is printed so it can be used to provide a\nhelpful message. The body of the unit test is written like one would usually\nwrite Clarity, using `try!` and `unwrap!` and so on as needed.\n\nExample:\n\n```clarity\n(define-public (test-my-feature)\n\t(begin\n\t\t(unwrap! (contract-call? .some-project-contract my-feature) (err \"Calling my-feature failed\"))\n\t\t(ok true)\n\t)\n)\n```\n\n### Prepare function\n\nSometimes you need to run some preparation logic that is common to all or\nmultiple unit tests. If the script detects a function called `prepare`, it will\nbe invoked before calling the unit test function itself. The `prepare` function\nshould return an `ok`, otherwise the test fails.\n\n```clarity\n(define-public (prepare)\n\t(begin\n\t\t(unwrap! (contract-call? .some-project-contract prepare-something) (err \"Preparation failed\"))\n\t\t(ok true)\n\t)\n)\n\n(define-public (test-something)\n\t;; prepare will be executed before running the test.\n)\n```\n\n### Annotations\n\nYou can add certain comment annotations before unit test functions to add\ninformation or modify behaviour. Annotations are optional.\n\n| Annotation            | Description                                                                                                                                  |\n|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------|\n| `@name`               | Give the unit test a name, this text shows up when running unit tests.                                                                       |\n| `@no-prepare`         | Do not call the `prepare` function before running this unit test.                                                                            |\n| `@prepare`            | Override the default `prepare` function with another. The function name should follow the tag.                                               |\n| `@caller`             | Override the default caller when running this unit test. Either specify an account name or standard principal prefixed by a single tick `'`. |\n| `@mine-blocks-before` | Mine a number of blocks before running the test. The number of blocks should follow the tag.                                                 |\n\nExamples:\n\n```clarity\n(define-public (prepare) (ok \"Default prepare function\"))\n\n(define-public (custom-prepare) (ok \"A custom prepare function\"))\n\n;; A test without any annotations\n(define-public (test-zero) (ok true))\n\n;; @name A normal test with a name, the prepare function will run before.\n(define-public (test-one) (ok true))\n\n;; @name This test will be executed without running the default prepare function.\n;; @no-prepare\n(define-public (test-two) (ok true))\n\n;; @name Override the default prepare function, it will run custom-prepare instead.\n;; @prepare custom-prepare\n(define-public (test-three) (ok true))\n\n;; @name This test will be called with tx-sender set to wallet_1 (from the settings toml file).\n;; @caller wallet_1\n(define-public (test-four) (ok true))\n\n;; @name This test will be called with tx-sender set to the specified principal.\n;; @caller 'ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG\n(define-public (test-five) (ok true))\n\n;; @name Five blocks are mined before this test is executed.\n;; @mine-blocks-before 5\n(define-public (test-six) (ok true))\n```\n\n// test","readmeFilename":"README.md"}