Tools to manage fixtures during app development for Cozy
Manage easily the data fixtures for your Cozy developments!
Please note that the "load" process do the following:
The "concerned doctypes" are the ones found in the fixture files or the ones you gaves through parameters.
When you develop an application you might want to feed the Data System with data.
npm install -g cozy-fixturescozy-fixtures load # will load all the fixtures inside ./tests/fixtures/cozy-fixtures load ./fixtures/ # you can specify a foldercozy-fixtures load ./fixtures/my-super-fixtures.json # or a filecozy-fixtures load -d contact # only load the documents for a specified doctypecozy-fixtures load -s # run the script quietlycozy-fixutres -l load # doesn't remove documents before loading
You can use cozy-fixtures programatically to ease automatic testing:
npm install cozy-fixtures --save-dev
fixtures = require 'cozy-fixtures'fixturesloaddirPath: 'path/to/fixtures' # default is './tests/fixtures/'doctypeTarget: 'doctypeName' # default is nullsilent: true # default is falseremoveBeforeLoad: false # default is true. Remove docs for concerned doctypes before loading the datacallback: yourCallback # default is null
You can also do more precise action like:
fixtures = require 'cozy-fixtures'fixturesremoveDocs "doctypeName"consolelog err if err?
fixtures = require 'cozy-fixtures'fixturesresetDatabase: consolelog err if err?designsToRemove: true # default is false, removes all the design docs in the database (and related) views
If you want to have the same configuration for every call, use the setDefaultValues method:
fixtures = require 'cozy-fixtures'fixturessetDefautValuestarget: './a/custom/target.json'silent: trueremoveBeforeLoad: falsefixturesload : consolelog "fixtures loaded !"
You can still override the defautl values by passing the arguments to the load function.
A simple example:
Note that you can add files as attachments. In order to achieve this, add a "_attachments" field to your fixture and put the path relatively to where you run the command.
Cozy is a platform that brings all your web services in the same private space. With it, your web apps and your devices can share data easily, providing you with a new experience. You can install Cozy on your own hardware where no one profiles you.
You can reach the Cozy Community by: