{"id":"synthetic-dev/ezspec","name":"ezspec","scope":"synthetic-dev","platform":"roblox","description":"An easy unit testing framework for Roblox / Luau","version":"0.1.4","latest":"0.1.4","versions":["0.1.0","0.1.1","0.1.2","0.1.3","0.1.4"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"d03f31c02693448e9b8267e40ffd987cf8cb9fe345cb2ccf3d68110205e24fcc","likes":0,"downloads":0,"install":"forest install synthetic-dev/ezspec","url":"https://forest.dev/p/roblox/synthetic-dev/ezspec","files":"https://api.forest.dev/ai/package/roblox/synthetic-dev/ezspec/files","readme":"# EzSpec\nA unit testing framework for Roblox and Luau!\n\nInspired by and forked from Boat's BoatTEST / Elttob's FusionCI\n\nI was always discouraged from using TestEZ since it manipulated function environments in order to expose the API. EzSpec removes all of that and provides a minimalistic way of testing.\n\n## Installation\n### From Github\nFor the most up-to-date version of the framework you can download this repository and place the `src` folder into your project, renaming it to `EzSpec`. You can also find a `.rbxmx` model and a zipped version of the `src` on the [Github Releases Page](https://github.com/Synthetic-Dev/EzSpec/releases)\n### With Wally\n[Wally](https://github.com/UpliftGames/wally) is a modern package manager for Roblox projects inspired by Cargo. You can use it to install EzSpec:\n```toml\n[dependencies]\nEzSpec = \"synthetic-dev/ezspec@0.1.0\"\n```\n\n## Usage\n\n### [Click here for API →](API.md)\n\n---\n\n#### Starting Tests:\nThis will run any `.spec` files that are descendants of `script.Parent.Specs`\n\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal EzSpec = require(ReplicatedStorage.EzSpec)\n\nEzSpec.runTests({\n\tdirectories = {\n\t\tscript.Parent.Specs;\n\t};\n\tincludeDescendants = true;\n})\n```\n\n#### Benchmarking:\n\nIf the `showExecutionTime` flag is set to `true` in the config then the amount of time taken to execute will be shown next to each test\n```lua\nEzSpec.runTests({\n\tdirectories = {\n\t\tscript.Parent.Specs;\n\t};\n\tshowExecutionTime = true;\n})\n```\n\n#### Spec files:\nIn order to be recognized by the framework files must end in `.spec`\n\nThey should be a module that returns an array of tests created using the `declare` method, see example below:\n```lua\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\n\nlocal EzSpec = require(ReplicatedStorage.EzSpec)\nlocal this = EzSpec.this\nlocal declare = EzSpec.declare\n\nreturn {\n\tdeclare(\"this will pass\", function(skip)\n\t\tthis(nil).should.never.exist()\n\tend);\n\n\tdeclare(\"this test will skip\", function(skip)\n\t\tskip(\"showing that the skip feature works\")\n\n\t\terror(\"this error should not be shown\")\n\tend);\n\n\tdeclare(\"this test should fail\", function(skip)\n\t\tthis(\"string\").will.match(\"a pattern that does not match\")\n\tend);\n}\n```\nTests will be executed and displayed in the order that they are added to the array. Except when being displayed they are grouped together as `failed`, `passed` and `skipped` tests.\n\n#### Nested tests:\nIf the `test` function returns a table containing more tests then those tests will be run if the parent test passes and is not skipped.\nSee example below:\n\n```lua\ndeclare(\"this test has nested tests\", function()\n\t-- Run this test's code here\n\n\treturn {\n\t\tdeclare(\"a nested test with nested tests\", function()\n\t\t\t-- Run this test's code here\n\n\t\t\treturn {\n\t\t\t\tdeclare(\"this test will pass\", function()\n\t\t\t\t\tthis(true).exists()\n\t\t\t\tend);\n\t\t\t}\n\t\tend);\n\t}\nend)\n```","readmeTruncated":false}