https://github.com/codeworksfrance/toml-it
A stupid TOML integration tests typescript library
https://github.com/codeworksfrance/toml-it
codeworks integration-testing javascript jest toml typescript
Last synced: 1 day ago
JSON representation
A stupid TOML integration tests typescript library
- Host: GitHub
- URL: https://github.com/codeworksfrance/toml-it
- Owner: CodeWorksFrance
- Created: 2022-11-08T12:55:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-14T10:51:15.000Z (over 3 years ago)
- Last Synced: 2025-03-04T16:16:48.777Z (about 1 year ago)
- Topics: codeworks, integration-testing, javascript, jest, toml, typescript
- Language: TypeScript
- Homepage:
- Size: 186 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# toml-it
[](https://www.npmjs.com/package/toml-it) [](https://github.com/CodeWorksFrance/toml-it/actions/workflows/nodejs-ci.yml) [](https://github.com/CodeWorksFrance/toml-it/actions/workflows/eslint.yml)
`toml-it` it a simple integration tests runner. It tests the output of a `node` program.
## How to install?
```sh
npm i -D toml-it
```
## How to write a test?
Tests files must match the following pattern `**/*.spec.toml`.
The structure of a tests should be:
``` toml
stdout=""
description=""
args=""
```
## Run tests
If you are using `jest` as test runner, you can simply create a file `toml-it.spec.ts` and enter the following code:
```ts
import { TestRunner } from "toml-it";
describe('integration tests with toml', () => {
it('toml it', () => {
new TestRunner().run();
});
});
```
Then add the following command in your `package.json`:
```json
"scripts": {
...,
"test:integration": "tsc; jest",
},
```
## Example
If you want to test the following production code:
```ts
if (process.argv.length === 3) {
console.log("ok");
} else {
console.log("not ok");
}
```
You now could write two files:
### `notok.spec.toml`
```toml
stdout = "not ok"
args = "argument_1 argument_2 argument_3"
description="Should display 'not ok'"
```
### `ok.spec.toml`
```toml
stdout = "ok"
args = "argument_1"
description="Should display 'ok'"
```