We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some initial context in this discussion
TL;DR
clarinet tests
Clarinet will expose a JS library (through wasm) that will allow to test smart contracts in any JS/WASM environment (Node, Deno, Web Browers, etc).
The package could be called @stacks/clarinet-sdk/unit-tests (introducing the clarinet SDK package Add support to retrieve the observable events from the contracts in a given Clarinet project #1034)
@stacks/clarinet-sdk/unit-tests
The POC will be mostly tested with Node 20 test runner
here as a working template representing what's feasible at the end of this POC
import { main } from "../../../../hiro/clarinet/components/clarinet-sdk/dist/index.js"; import { before, describe, it } from "node:test"; import assert from "node:assert/strict"; import { Cl } from "@stacks/transactions"; let sender = "ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5"; describe("test counter", () => { let session; before(async () => { session = await main(); await session.initSession(process.cwd(), "./Clarinet.toml"); }); it("gets counter value", () => { const res = session.callReadOnlyFn("counter", "get-counter", [], sender); assert.deepEqual(Cl.int(0), res.result); assert.equal(session.blockHeight, 1); }); it("increments counter value", () => { const incrRes = session.callPublicFn("counter", "increment", [], sender); assert.deepEqual(incrRes.result, Cl.ok(Cl.bool(true))); assert.equal(session.blockHeight, 2); let res = session.callReadOnlyFn("counter", "get-counter", [], sender); assert.deepEqual(res.result, Cl.int(1)); assert.equal(session.blockHeight, 2); }); it("add any value", () => { const addRes = session.callPublicFn("counter", "add", [Cl.int(10)], sender); assert.deepEqual(addRes.result, Cl.ok(Cl.bool(true))); assert.equal(session.blockHeight, 3); let res = session.callReadOnlyFn("counter", "get-counter", [], sender); assert.deepEqual(res.result, Cl.int(11)); assert.equal(session.blockHeight, 3); }); });
A lot of features and improvements have to be considered in the next iteration (Q3). This is just a list of ideas, not all of them will be implemented
clarinet test
node test
The text was updated successfully, but these errors were encountered:
--allow-env
--allow-read
This POC is now considered done. Conclusion:
Let's pursue in this direction to build a enjoyable testing experience!
Closing in favor of #1065
Sorry, something went wrong.
hugocaillard
No branches or pull requests
Context
Some initial context in this discussion
TL;DR
clarinet tests
The POC
Clarinet will expose a JS library (through wasm) that will allow to test smart contracts in any JS/WASM environment (Node, Deno, Web Browers, etc).
The package could be called
@stacks/clarinet-sdk/unit-tests
(introducing the clarinet SDK package Add support to retrieve the observable events from the contracts in a given Clarinet project #1034)The POC will be mostly tested with Node 20 test runner
here as a working template representing what's feasible at the end of this POC
Going further
A lot of features and improvements have to be considered in the next iteration (Q3). This is just a list of ideas, not all of them will be implemented
clarinet test
run (default will benode test
)The text was updated successfully, but these errors were encountered: