{"_id":"@bowtieddevops/bowtieddevops-test-package-2","_rev":"1-b0c566bb4f63c7d80dba931d0e58df98","name":"@bowtieddevops/bowtieddevops-test-package-2","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@bowtieddevops/bowtieddevops-test-package-2","version":"0.0.1","description":"Clarunit, enables writing unit tests in Clarity","main":"src/index.ts","bin":{"bowtieddevops-test-package-2":"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-2@0.0.1","gitHead":"83c94e0be4e6b0f54340ee07f65d5a25e2a4581e","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-+0PWrvgo35tFKwX4SOH5iD1oVMKMNpObx2+OcM0o98i4oa2qPxTY+TuhatjNfdusXd7KZxFBeOzEkijuajC+sw==","shasum":"be9620bb00c15e065df02cf7ccd710674a85e0b4","tarball":"https://registry.npmjs.org/@bowtieddevops/bowtieddevops-test-package-2/-/bowtieddevops-test-package-2-0.0.1.tgz","fileCount":40,"unpackedSize":161940,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHmVZ6Wnv27KzCyv875Yo8Hyc2QC7gXIqxWguYAWOB7UAiEA7Wj7VTTkx5UUDWwCbg5Sbuw7WP8q5WUq+yGnhKqHfaE="}]},"_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-2_0.0.1_1712235058918_0.45640141166106285"},"_hasShrinkwrap":false},"0.0.2":{"name":"@bowtieddevops/bowtieddevops-test-package-2","version":"0.0.2","description":"Clarunit, enables writing unit tests in Clarity","main":"src/index.ts","bin":{"bowtieddevops-test-package-2":"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-2@0.0.2","gitHead":"e446ff1407f948e6d3816b2c6db51af0eb2f8fb9","_nodeVersion":"20.12.0","_npmVersion":"10.5.0","dist":{"integrity":"sha512-c3kG5jva/nmERLEdTcOuhVPxhjrneHV4rVIZU69it1zPs2CtLjO79+JXntg2LUb9wIQNDxVh16Vr5GgWMVY6aA==","shasum":"44ef0e586aed6ccd7281c7890d8cc5304cd97702","tarball":"https://registry.npmjs.org/@bowtieddevops/bowtieddevops-test-package-2/-/bowtieddevops-test-package-2-0.0.2.tgz","fileCount":40,"unpackedSize":161940,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEE+Z0cBhPWUU4K2wfF51elkZjk4CNd0N1fhIkC66Aj2AiBbpGYzte6yxHHF6H7aZxQcRlZ6oxkX9uTWUi49B257qg=="}]},"_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-2_0.0.2_1712235126172_0.5193440442930093"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-04T12:50:58.825Z","0.0.1":"2024-04-04T12:50:59.102Z","modified":"2024-04-04T12:52:06.544Z","0.0.2":"2024-04-04T12:52:06.360Z"},"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"}