0.2.0 • Published 6 years ago
thinkable v0.2.0
thinkable 
Why?
- Initializes and cleans up the database.
- Each test worker gets its own isolated database.
- Easily seed the database and configure it.
Install
npm install thinkable --save-devUsage
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 for more details.
- Fork it.
- Make a feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request.
License
Go make something, dang it.