Registry / testing / dookie

dookie

JSON →
library0.5.0jsnpmunverified

Dookie is a MongoDB fixture/preprocessor tool that extends JSON and YAML with extra syntactic sugar including extended ObjectId syntax, variables, imports via $require, inheritance, and more. Version 0.5.0 requires Node >= 10.0.0. It supports push (upsert data into MongoDB) and pull (export data to file). Differentiators: built-in support for YAML, $require for modular fixtures, and MongoDB extended JSON (e.g., $oid).

npm install dookie
INSTALL
IMPORT
SIG · DOOKIE
D
dookie
testingjavascriptv0.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dookie (default)
import dookie from 'dookie'
const dookie = require('dookie')
dookie is ESM-only if you're using TypeScript or bundlers; both CommonJS and ESM are supported in Node >=10.
push
import { push } from 'dookie'
const { push } = require('dookie')
Same as above; works with both import and require.
pull
import { pull } from 'dookie'
pull is a named export; available as a function.

Pushes YAML fixture data into MongoDB using dookie.push() with async/await via co. Assumes MongoDB is running locally.

co(function*() { const dookie = require('dookie'); const yaml = require('js-yaml'); const fs = require('fs'); const uri = process.env.MONGO_URI || 'mongodb://localhost:27017/test'; const contents = fs.readFileSync('./fixtures.yml'); const data = yaml.safeLoad(contents); yield dookie.push(uri, data, './fixtures.yml'); console.log('Data pushed successfully'); });
Debug
Known issues
breakingRequires Node >= 10.0.0. Will not work on older Node 0.x or io.js.
fix
Upgrade Node to version >=10.0.0 or use an older version of dookie (if available).
affects: <10.0.0
gotchaThe .push() method requires the third argument (filename) to resolve $require paths; otherwise $require will fail.
fix
Always pass the fixture file's absolute or relative path as the third argument to push().
affects: >=0.5.0
gotchaMongoDB extended JSON $oid is parsed but not all drivers support it natively; you must use dookie's conversion.
fix
Ensure you use dookie.push() to process the data before inserting, as raw InsertMany may not handle $oid.
affects: >=0.5.0
deprecateddookie.pull() may export ObjectIds in a format that is not compatible with all MongoDB drivers.
fix
Consider using mongodump or direct MongoDB export tools for production data dumps.
affects: >=0.5.0
Errors
Common errors & fixes
Error: The $require path './child.yml' does not exist or is not readable
Missing or incorrect third argument (filename) to push(), or the required file path is wrong.
fix
Provide the correct filename as third argument to push(), e.g., dookie.push(uri, data, './parent.yml').
TypeError: Cannot read property 'push' of undefined
Trying to destructure push from the default import without using named exports correctly.
fix
Use import dookie from 'dookie' then call dookie.push(), or import { push } from 'dookie'.
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies
mongodbrequiredRequired at runtime to connect and push/pull data from MongoDB.
js-yamloptionalRequired to parse YAML fixture files if YAML is used.
Agent activity
9 hits · last 30 days
node
8
Resources
packagedookie
dookie — npm install dookie · libregistry