{"id":"bigfootpp/spec","name":"spec","scope":"bigfootpp","platform":"roblox","description":"A minimal testing library for LuaU","version":"0.1.0","latest":"0.1.0","versions":["0.1.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":false,"dependencies":{},"integrity":"46bc8e80e47c6b65f8aa55bd4f8a23f0dde48f55ba6efa571261f77ccebd9184","likes":0,"downloads":0,"install":"forest install bigfootpp/spec","url":"https://forest.dev/p/roblox/bigfootpp/spec","files":"https://api.forest.dev/ai/package/roblox/bigfootpp/spec/files","readme":"`spec` is a collection of minimal, portable testing libraries for Luau,\r\nbuilt on a few principles:\r\n\r\n- Simple, idiomatic Luau throughout.\r\n- Zero external dependencies.\r\n- Small core, extend with plugins.\r\n- Runtime independence.\r\n- No opinions about project structure.\r\n\r\n`spec` comes with pre-configured bundles for popular runtimes like Roblox and\r\nLune, or pick and mix your own modules and plugins!\r\n\r\n## Features\r\n\r\n- `test()` and `describe()` callbacks\r\n- Clean, correctly-cropped stack traces\r\n- Declarative `expect()` API with line numbers and code visualisation\r\n- Pretty-formatted summaries of reports with emoji, Unicode, and colour\r\n- Benchmark how long tests run for\r\n- Extensible, lightweight plugin system\r\n- Snapshot testing for all quotable data types\r\n\r\n### Planned\r\n\r\n- Test discovery for Lune\r\n\r\n## Installation\r\n\r\nNo installation needed!\r\n\r\n`spec` is distributed as a set of portable Luau files that sit next to each\r\nother. Drop them into your `lib` folder, keep the ones you need, and start using\r\n`spec` right away :)\r\n\r\n\r\n## Usage\r\n\r\n> *🎨 The printed reports come with colour - try it in your terminal!*\r\n\r\nHere's an example file written with `spec_for_lune`:\r\n\r\n```Lua\r\n--!strict\r\n\r\nlocal spec = require(\"@spec_for_lune\").configure({\r\n\tsnapshot_path = \"./test/__snapshots__\",\r\n\tsave_snapshots = true\r\n})\r\n\r\nlocal function my_test_suite()\r\n\tlocal describe = spec.describe\r\n\tlocal test = spec.test\r\n\tlocal expect = spec.expect\r\n\tlocal snapshot = spec.snapshot\r\n\r\n\tdescribe(\"some cool features\", function()\r\n\t\ttest(\"it works\", function()\r\n\t\t\texpect(2 + 2).is(4)\r\n\t\tend)\r\n\r\n\t\ttest(\"snapshots\", function()\r\n\t\t\tsnapshot({\r\n\t\t\t\thello = \"world\",\r\n\t\t\t\tfoo = true,\r\n\t\t\t\tbar = 2\r\n\t\t\t})\r\n\t\tend)\r\n\tend)\r\nend\r\n\r\nlocal tests = spec.collect_tests(my_test_suite)\r\nspec.run_tests(tests, {})\r\n```\r\n\r\nThe above example generates a report like this and prints it to stdout:\r\n\r\n```\r\n══════════════════════════════ Status of 2 test(s) ═════════════════════════════\r\n\r\n✅ some cool features ▸ it works - 74.9µs\r\n✅ some cool features ▸ snapshots - 137.71ms\r\n\r\n══════════════════════════════ 2 passed, 0 failed ══════════════════════════════\r\n\r\nTime to run: 217.9ms\r\n\r\n════════════════════════════════════════════════════════════════════════════════\r\n```\r\n\r\nFailures look like this:\r\n\r\n```\r\n═════════════════════════════ Errors from 2 test(s) ════════════════════════════\r\n\r\n❌ some cool features ▸ it works\r\nExpectation not met\r\n   │\r\n16 │ expect(4).is(5)\r\n   │\r\n[string \"test/test_main\"]:16\r\n\r\n❌ some cool features ▸ snapshots\r\nSnapshot does not match\r\n   │\r\n78 │ snapshot({\r\n   │   [\"bar\"] = 2;\r\n   │   [\"foo\"] = true;\r\n   │   [\"hello\"] = \"world\";\r\n   │ })\r\n   │\r\n   │ -- snapshot on disk:\r\n   │ snapshot({\r\n   │   [\"bar\"] = 5;\r\n   │   [\"foo\"] = false;\r\n   │   [\"hello\"] = \"earth\";\r\n   │ })\r\n   │\r\n[string \"test/test_main\"]:20\r\n\r\n══════════════════════════════ Status of 2 test(s) ═════════════════════════════\r\n\r\n❌ some cool features ▸ it works - 111.6ms\r\n❌ some cool features ▸ snapshots - 174.9ms\r\n\r\n══════════════════════════════ 0 passed, 2 failed ══════════════════════════════\r\n\r\nTime to run: 292.81ms\r\n\r\n════════════════════════════════════════════════════════════════════════════════\r\n```\r\n\r\n## License\r\n\r\nLicensed the same way as all of my open source projects: BSD 3-Clause + Security Disclaimer.\r\n\r\nAs with all other projects, you accept responsibility for choosing and using this project.\r\n\r\nSee [LICENSE](./LICENSE) or [the license summary](https://github.com/dphfox/licence) for details.\r\n","readmeTruncated":false}