Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

88 - Update placeholder end-user README #116

Merged
merged 10 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
cache: "npm"
registry-url: "https://registry.npmjs.org"

- name: Copy global readme to package
run: cp README.md packages/lest/README.md

- name: Publish to NPM
uses: JS-DevTools/npm-publish@v3
id: publish
Expand Down
94 changes: 91 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,93 @@
# Lest
<h1 align="center">
<img alt="Lest, painless Lua testing" src="readme.png" width="70%" />
</h1>
<p align="center">
<a href="https://www.npmjs.com/package/@taservers/lest" style="text-decoration: none;">
<img alt="NPM Package" src="https://img.shields.io/npm/v/%40taservers/lest?style=for-the-badge&logo=npm&logoColor=white" />
</a>
<a href="https://github.com/TAServers/lest/actions/workflows/release.yml" style="text-decoration: none;">
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/TAServers/lest/release.yml?branch=master&logo=github&style=for-the-badge" />
</a>
<a href="https://discord.taservers.com" style="text-decoration: none;">
<img alt="Discord" src="https://img.shields.io/discord/800234484649820163?color=%237289DA&label=Discord&logo=discord&logoColor=white&style=for-the-badge" />
</a>
<a href="https://github.com/TAServers/lest/blob/master/LICENSE">
<img alt="License: MIT" src="https://img.shields.io/github/license/TAServers/lest?style=for-the-badge&color=blue" />
</a>
</p>

Lua testing framework providing a similar API to Jest, and without external dependencies or reliance on Luarocks.
---

This is still in the very early stages of development, however it's feature complete enough to be used in small projects where there is low risk.
Lest is an easy to use and performant Lua testing framework sporting an API that aligns with Jest. If you've tested JavaScript or TypeScirpt before you probably already know how to use it!

Lest can be run with zero dependencies by downloading the `lest.lua` file published with every GitHub release, or you can install the [`@taservers/lest` NPM Package][npm-package] which is recommended for easy updating and version management.

## Key Features

- API that 1:1 matches Jest in most places (with some Lua-specific aliases like `toBeNil`)
- Fast test running despite being a single thread, with Lest's 157 tests (at the time of writing) running in **under a second**!
- Full support for all major versions of Lua (`5.1.5`, `5.2.4`, `5.3.6`, `5.4.4`, `LuaJIT 2.0.5` and `LuaJIT 2.1.0`)

## Quick Links

- [API Documentation][api-docs]
- [`@taservers/lest` NPM Package][npm-package]
- [Discord Server][discord]
- ⚠️ Unlike our GitHub, the TAS Discord server is not moderated beyond ToS and NSFW

## Getting Started

Install Lest using your package manager of choice (this guide assumes NPM):

```
npm install --save-dev @taservers/lest
```

Next, create a simple function to test in `sum.lua`:

```lua
-- sum.lua
local function sum(a, b)
return a + b
end

return sum
```

Then, create a new test file with the `.test.lua` suffix (this is what Lest looks for by default):

```lua
-- sum.test.lua
local sum = require("sum")

test("adds 1 + 2 to equal 3", function()
expect(sum(1, 2)).toBe(3)
end)
```

Finally, run your tests with `npx lest`!

## Configuration

Most configuration options can be either passed in from the CLI or defined in a Lua config file, but there are a couple of special CLI-only options:

- `--config` tells Lest where to read the config file from (default: `lest.config.lua`)
- `--luaCommand` is unique to the `@taservers/lest` NPM package and determines what command to run when executing Lua. If not specified, Lest will try to find an installed Lua binary automatically using the order defined [here][lua-command-priority]

The Lest config file should be a valid Lua script returning a table containing config options. For example:

```lua
-- lest.config.lua
return {
testMatch = { "tests/lua/.+%.test%.lua" }
}
```

As this script is executed before running or scanning for tests, you can use it to perform setup actions like defining `package.path`. A dedicated `setupFile` option will also be added in the future.

For a full list of configuration options, see the docs page here (🚧 UNDER CONSTRUCTION 🚧).

[npm-package]: https://www.npmjs.com/package/@taservers/lest
[api-docs]: https://taservers.github.io/lest/docs/api/expect
[discord]: https://discord.taservers.com
[lua-command-priority]: https://github.com/TAServers/lest/blob/master/packages/lest/src/helpers/lua-executable-names.json
Binary file added readme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading