Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sholladay/thinkable
Helpers for testing RethinkDB apps with AVA
https://github.com/sholladay/thinkable
ava database db hook rethinkdb tests
Last synced: 23 days ago
JSON representation
Helpers for testing RethinkDB apps with AVA
- Host: GitHub
- URL: https://github.com/sholladay/thinkable
- Owner: sholladay
- License: mpl-2.0
- Created: 2017-10-21T07:20:27.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-12-14T06:39:02.000Z (about 5 years ago)
- Last Synced: 2024-04-14T00:25:05.124Z (9 months ago)
- Topics: ava, database, db, hook, rethinkdb, tests
- Language: JavaScript
- Homepage:
- Size: 25.4 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# thinkable [![Build status for Thinkable](https://travis-ci.com/sholladay/thinkable.svg?branch=master "Build Status")](https://travis-ci.com/sholladay/thinkable "Builds")
> Helpers for testing [RethinkDB](https://rethinkdb.com/) apps with [AVA](https://github.com/avajs/ava)
## Why?
- Initializes and cleans up the database.
- Each test worker gets its own isolated database.
- Easily seed the database and configure it.## Install
```sh
npm install thinkable --save-dev
```## Usage
```js
import test from 'ava';
import r from 'rethinkdb';
import { init, cleanup } from 'thinkable';const seed = {
dbOne : {
tableA : [
{ name : 'Jane Doe' }
]
},
dbTwo : {
tableA : [
{ color : 'blue' }
]
}
};test.before(init(seed));
test.after.always(cleanup);test('does some stuff', async (t) => {
const conn = await r.connect({
port : t.context.dbPort
});
console.log(await r.dbList().run(conn));
});
```## API
### init(seed, option)
Returns an async function that is meant to be passed as `fn` to AVA's `test.before(fn)`. The returned function, when called, starts and seeds the database.
### cleanup()
Stops the database and cleans up its data.
#### option
Type: `object`
##### cwd
Type: `string`
A path where the RethinkDB data directory should be created.
##### password
Type: `string`
An initial password for the `admin` user.
## Contributing
See our [contributing guidelines](https://github.com/sholladay/thinkable/blob/master/CONTRIBUTING.md "Guidelines for participating in this project") for more details.
1. [Fork it](https://github.com/sholladay/thinkable/fork).
2. Make a feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. [Submit a pull request](https://github.com/sholladay/thinkable/compare "Submit code to this project for review").## License
[MPL-2.0](https://github.com/sholladay/thinkable/blob/master/LICENSE "License for thinkable") © [Seth Holladay](https://seth-holladay.com "Author of thinkable")
Go make something, dang it.