{"id":16157082,"url":"https://github.com/misode/packtest","last_synced_at":"2025-03-16T09:33:43.686Z","repository":{"id":212701520,"uuid":"731969321","full_name":"misode/packtest","owner":"misode","description":"Fabric mod for testing data packs, with data packs","archived":false,"fork":false,"pushed_at":"2024-11-28T19:24:15.000Z","size":290,"stargazers_count":21,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"1.20","last_synced_at":"2025-02-27T07:13:13.852Z","etag":null,"topics":["data-pack","data-packs","datapack","datapacks","fabricmc","gametest","gametest-minecraft","minecraft","unit-testing"],"latest_commit_sha":null,"homepage":"https://modrinth.com/mod/packtest","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/misode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-12-15T10:08:54.000Z","updated_at":"2025-01-01T13:36:10.000Z","dependencies_parsed_at":"2023-12-23T22:18:46.853Z","dependency_job_id":"6f71cdb9-08af-4450-9747-91cdaa788abd","html_url":"https://github.com/misode/packtest","commit_stats":null,"previous_names":["misode/packtest"],"tags_count":24,"template":false,"template_full_name":"FabricMC/fabric-example-mod","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misode%2Fpacktest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misode%2Fpacktest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misode%2Fpacktest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misode%2Fpacktest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/misode","download_url":"https://codeload.github.com/misode/packtest/tar.gz/refs/heads/1.20","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243809888,"owners_count":20351407,"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":["data-pack","data-packs","datapack","datapacks","fabricmc","gametest","gametest-minecraft","minecraft","unit-testing"],"created_at":"2024-10-10T01:48:07.482Z","updated_at":"2025-03-16T09:33:43.275Z","avatar_url":"https://github.com/misode.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PackTest\nPackTest allows you to write game tests in a data pack. Tests are `*.mcfunction` files in a `test` folder. They can be used to test custom data packs.\n\n[![modrinth](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy/available/modrinth_vector.svg)](https://modrinth.com/mod/packtest)\n\n## Example\n**`data/example/test/foo.mcfunction`**\n```mcfunction\n#\u003e Summons an armor stand and finds it\n# @template example:small_platform\n# @optional\n\nsummon armor_stand ~1.5 ~1 ~1.5\nexecute positioned ~1.5 ~1 ~1.5 run assert entity @e[type=armor_stand,dx=0]\n\nassert predicate example:test\n\nsetblock ~1 ~1 ~1 grass_block\nexecute if block ~1 ~1 ~1 stone run succeed\n\nfail \"Oh no\"\n```\n\n### Async tests\nTest functions can be asynchronous, using the `await` keyword!\n```mcfunction\nsetblock ~ ~ ~ stone\nsummon item ~ ~6 ~\n\nawait entity @e[type=item,distance=..2]\n\nawait delay 1s\n\ndata merge entity @e[type=item,distance=..2,limit=1] {Motion: [0.0, 0.01, 0.0]}\n```\n\n## Running tests\nTests can be run in-game using the `test` command.\n* `test runall`: runs all the tests\n* `test runall \u003cnamespace\u003e`: runs all tests from a specified namespace\n* `test run \u003ctest\u003e`: runs the test with a specified name\n* `test runfailed`: runs all the previously failed tests\n* `test runthis`: runs the closes test\n* `test runthese`: runs all tests within 200 blocks\n\n### Auto test server\nTests can also be run automatically, for instance in a CI environment. When `-Dpacktest.auto` is set, the game test server will start automatically with the loaded tests. The process will exit when all tests have finished with the exist code set to the number of failed tests. \n\nSetting `-Dpacktest.auto.annotations` will emit GitHub annotations for all test failures and resource load errors.\n\nThe following example can be adapted into a GitHub action workflow.\n```yaml\non: [push, pull_request]\n\nenv:\n  # Make sure to update these links!\n  TEST_FABRIC_SERVER: https://meta.fabricmc.net/v2/versions/loader/1.20.4/0.15.3/0.11.2/server/jar\n  TEST_FABRIC_API: https://cdn.modrinth.com/data/P7dR8mSH/versions/JMCwDuki/fabric-api-0.92.0%2B1.20.4.jar\n  TEST_PACKTEST: https://cdn.modrinth.com/data/XsKUhp45/versions/18smpIeE/packtest-1.6-mc1.20.4.jar\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - uses: actions/setup-java@v4\n        with:\n          distribution: 'temurin'\n          java-version: '17'\n      - name: Download and prepare files\n        run: |\n          curl -o server.jar $TEST_FABRIC_SERVER\n          mkdir mods\n          curl -o mods/fabric-api.jar $TEST_FABRIC_API\n          curl -o mods/packtest.jar $TEST_PACKTEST\n          mkdir -p world/datapacks\n          cp -r datapack world/datapacks/datapack\n      - name: Run tests\n        run: |\n          java -Xmx2G -Dpacktest.auto -Dpacktest.auto.annotations -jar server.jar nogui\n```\n\n## Commands\n\n### `fail`\n* `fail \u003ctext component\u003e`: fails the current test and returns from the function\n\n### `succeed`\n* `succeed`: always succeeds the current test and returns from the function\n\n### `assert`\n* `assert \u003ccondition\u003e`: if condition is unsuccessful, fails the current test and returns from the function\n* `assert not \u003ccondition\u003e`: if condition is successful, fails the current test and returns from the function\n\n### `await`\n* `await \u003ccondition\u003e`: similar to assert, but keeps trying the condition every tick until the test times our or the condition succeeds\n* `await not \u003ccondition\u003e`: keeps trying the condition until it fails\n* `await delay \u003ctime\u003e`: waits for a specified time with unit\n\n### Conditions\n* `block \u003cpos\u003e \u003cblock\u003e`: checks if the block at the specified position matches the block predicate\n* `data ...`: checks NBT data using the same syntax as `execute if score`\n* `entity \u003cselector\u003e`: checks if the selector matches any entity (can also find entities outside the structure bounds)\n* `predicate \u003cpredicate\u003e`: checks a predicate in a data pack\n* `score ...`: checks scores using the same syntax as `execute if score`\n* `chat \u003cpattern\u003e [\u003creceivers\u003e]`: checks whether a chat message was sent in the past tick matching a regex pattern\n\n## Dummies\nFake players can be spawned using the `/dummy` command. Dummies won't save or load their data from disk, they will also not load their skin.\n\n* `dummy \u003cname\u003e spawn`: spawns a new dummy\n* `dummy \u003cname\u003e respawn`: respawns the dummy after it has been killed\n* `dummy \u003cname\u003e leave`: makes the dummy leave the server\n* `dummy \u003cname\u003e jump`: makes the dummy jump, if currently on ground\n* `dummy \u003cname\u003e sneak [true|false]`: makes the dummy hold shift or un-shift (not the same as currently crouching)\n* `dummy \u003cname\u003e sprint [true|false]`: makes the dummy sprint or un-sprint\n* `dummy \u003cname\u003e drop [all]`: makes the dummy drop the current mainhand, either one item or the entire stack\n* `dummy \u003cname\u003e swap`: makes the dummy swap its mainhand and offhand\n* `dummy \u003cname\u003e selectslot`: makes the dummy select a different hotbar slot\n* `dummy \u003cname\u003e use item`: makes the dummy use its hand item, either mainhand or offhand\n* `dummy \u003cname\u003e use block \u003cpos\u003e [\u003cdirection\u003e]`: makes the dummy use its hand item on a block position\n* `dummy \u003cname\u003e use entity \u003centity\u003e`: makes the dummy use its hand item on an entity\n* `dummy \u003cname\u003e attack \u003centity\u003e`: makes the dummy attack an entity with its mainhand\n* `dummy \u003cname\u003e mine \u003cpos\u003e`: makes the dummy mine a block\n\n## Directives\nTests can be customized by placing certain directives as special comments at the start of the test function.\n\n* `@template`: the resource location of a structure template to use for the test, defaults to an empty 1x1x1 structure\n* `@timeout`: an integer specifying the timeout, defaults to `100`\n* `@optional`: whether this test is allowed to fail, defaults to `false`, if there is no value after the directive it is considered as `true`\n* `@dummy`: whether to spawn a dummy at the start of the test and set `@s` to this dummy, taking a position which defaults to `~0.5 ~ ~0.5`\n* `@batch`: the batch name for this test, defaults to `packtestBatch`\n* `@beforebatch`: a command to run before this batch, there can only be one per batch\n* `@afterbatch`: a command to run after this batch, there can only be one per batch\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisode%2Fpacktest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmisode%2Fpacktest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisode%2Fpacktest/lists"}