{"id":16597278,"url":"https://github.com/adrianmcli/ganache-jest-example","last_synced_at":"2025-09-15T04:31:01.475Z","repository":{"id":73736785,"uuid":"163641620","full_name":"adrianmcli/ganache-jest-example","owner":"adrianmcli","description":"🚀 Minimal Solidity contract testing with Ganache and Jest","archived":false,"fork":false,"pushed_at":"2019-04-30T08:06:47.000Z","size":408,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-03T14:50:55.485Z","etag":null,"topics":["ethereum","ganache","jest","smart-contracts","solidity"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adrianmcli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-31T05:23:44.000Z","updated_at":"2023-02-23T11:29:20.000Z","dependencies_parsed_at":"2023-05-27T14:00:46.137Z","dependency_job_id":null,"html_url":"https://github.com/adrianmcli/ganache-jest-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmcli%2Fganache-jest-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmcli%2Fganache-jest-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmcli%2Fganache-jest-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmcli%2Fganache-jest-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adrianmcli","download_url":"https://codeload.github.com/adrianmcli/ganache-jest-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233077318,"owners_count":18621511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ethereum","ganache","jest","smart-contracts","solidity"],"created_at":"2024-10-11T23:55:23.220Z","updated_at":"2025-01-08T18:20:48.810Z","avatar_url":"https://github.com/adrianmcli.png","language":"JavaScript","readme":"# Minimal Solidity contract testing with Ganache and Jest\n\nA Truffle project is a great way to start a dapp, but sometimes you want something more lightweight. For example, instead of having to pull-off migrations, maybe you just want to compile a simple smart contract and test right-away.\n\nNo worries, the Truffle suite of tools has got you covered! Using Ganache, you can easily spawn a test blockchain for your tests.\n\n**Note:** This example uses `solc` to compile the contract. If you prefer to use `truffle-contract` (makes the JSON artifact a little easier to work with), check out the `truffle-contract` branch [here](https://github.com/adrianmcli/ganache-jest-example/tree/truffle-contract).\n\n## Dependencies\n\nIn this example, there are only 4 dependencies!\n\n- `ganache-core` — Allows us to spawn a \"test blockchain\".\n- `jest` — A testing framework.\n- `solc` — Compiles our Solidity contract.\n- `web3` — Allows us to interact with our contract and do other Ethereum things.\n\n## Files\n\nThere are only 3 files you need to be concerned about.\n\n### `SimpleStorage.sol`\n\nThis is a simple Solidity contract that we will use as our example. It allows you to set and get an integer and nothing more.\n\n### `compile.js`\n\nThis file houses a utility function that compiles Solidity contracts and spits out JSON we can work with. Do note that we only need two things from the JSON in this example:\n\n1. The contract ABI, and;\n2. The contract bytecode.\n\n### `test.js`\n\nThis file houses our tests. Notice that most of the heavy lifting is done in the `beforeAll` hook, where we:\n\n- Compile the contract with `solc`;\n- Spawn a \"test blockchain\" with `ganache-core`, and;\n- Deploy our contract with `web3`.\n\nIn the `afterAll` hook, we simply call `stop()` on the Provider to clean up after ourselves.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrianmcli%2Fganache-jest-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadrianmcli%2Fganache-jest-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrianmcli%2Fganache-jest-example/lists"}