Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bytebit-org/fitumi
Fake It 'Till You Make It - A unit testing utility for faking dependencies in Lua
https://github.com/bytebit-org/fitumi
fake lua mocking roblox roblox-ts unit-test
Last synced: 6 days ago
JSON representation
Fake It 'Till You Make It - A unit testing utility for faking dependencies in Lua
- Host: GitHub
- URL: https://github.com/bytebit-org/fitumi
- Owner: Bytebit-Org
- License: mit
- Created: 2020-04-06T14:42:56.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-16T06:42:53.000Z (7 months ago)
- Last Synced: 2024-11-07T00:08:49.943Z (7 days ago)
- Topics: fake, lua, mocking, roblox, roblox-ts, unit-test
- Language: Lua
- Homepage:
- Size: 199 KB
- Stars: 13
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Fake It 'Till You Make It
Fake It 'Till You Make It, or fitumi, is a Lua faking library intended for helping to create comprehensive unit tests for Lua code bases. While not required, fitumi was designed with Roblox development as the primary use-case. Fitumi's design is inspired in part by [FakeItEasy](https://fakeiteasy.github.io/).
Fitumi comes paired with TypeScript annotation files for easy installation into a roblox-ts project and is published to NPM under the [@rbxts/fitumi](https://www.npmjs.com/package/@rbxts/fitumi) package.
## Installation
### roblox-ts
Simply install to your [roblox-ts](https://roblox-ts.com/) project as follows:
```
npm i @rbxts/fitumi
```### Wally
[Wally](https://github.com/UpliftGames/wally/) users can install this package by adding the following line to their `Wally.toml` under `[dependencies]`:
```
fitumi = "bytebit/[email protected]"
```Then just run `wally install`.
### From model file
Model files are uploaded to every release as `.rbxmx` files. You can download the file from the [Releases page](https://github.com/Bytebit-Org/fitumi/releases) and load it into your project however you see fit.### From model asset
New versions of the asset are uploaded with every release. The asset can be added to your Roblox Inventory and then inserted into your Place via Toolbox by getting it [here.](https://www.roblox.com/library/7881397561/fitumi-Package)## Links
- [API Documentation](DOCUMENTATION.md)## Example
```lua
local fitumi = require(path.to.fitumi)
local a = fitumi.alocal fakeDependency = a.fake()
a.callTo(fakeDependency["foo"], fakeDependency, fitumi.wildcard):returns("bar")local targetObject = TargetClass.new(fakeDependency)
targetObject:doSomething()assert(a.callTo(fakeDependency["foo"], fakeDependency, fitumi.wildcard):didHappen(), "No call to foo happened")
assert(targetObject.fooResult == "bar", "targetObject's foo result does not match provided foo result")
assert(a.writeTo(fakeDependency, "expectedKey", "expectedValue"):didHappen(), "targetObject did not write \"expectedValue\" to \"expectedKey\"")
```