{"id":23705715,"url":"https://github.com/pouchdb/pouchdb-plugin-helper","last_synced_at":"2025-06-21T17:05:58.369Z","repository":{"id":57142984,"uuid":"41298731","full_name":"pouchdb/pouchdb-plugin-helper","owner":"pouchdb","description":"A helper tool for PouchDB plugins to run tests and more","archived":false,"fork":false,"pushed_at":"2017-06-27T22:00:51.000Z","size":25,"stargazers_count":0,"open_issues_count":2,"forks_count":2,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-30T02:29:49.548Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pouchdb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-24T11:12:10.000Z","updated_at":"2016-01-15T16:44:49.000Z","dependencies_parsed_at":"2022-09-05T22:30:11.006Z","dependency_job_id":null,"html_url":"https://github.com/pouchdb/pouchdb-plugin-helper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pouchdb/pouchdb-plugin-helper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fpouchdb-plugin-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fpouchdb-plugin-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fpouchdb-plugin-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fpouchdb-plugin-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pouchdb","download_url":"https://codeload.github.com/pouchdb/pouchdb-plugin-helper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pouchdb%2Fpouchdb-plugin-helper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261162066,"owners_count":23118221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-30T14:56:51.843Z","updated_at":"2025-06-21T17:05:53.344Z","avatar_url":"https://github.com/pouchdb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"pouchdb-plugin-helper\n=====================\n\n[![Build Status](https://travis-ci.org/pouchdb/pouchdb-plugin-helper.svg?branch=master)](https://travis-ci.org/pouchdb/pouchdb-plugin-helper)\n[![Dependency Status](https://david-dm.org/pouchdb/pouchdb-plugin-helper.svg)](https://david-dm.org/pouchdb/pouchdb-plugin-helper)\n[![devDependency Status](https://david-dm.org/pouchdb/pouchdb-plugin-helper/dev-status.svg)](https://david-dm.org/pouchdb/pouchdb-plugin-helper#info=devDependencies)\n\n\u003e A helper tool for PouchDB plugins to run tests and more\n\nFor an example, see the\n[pouchdb-auth](https://github.com/pouchdb/pouchdb-auth) project.\n\nInstallation\n------------\n\n```bash\nnpm install --save-dev pouchdb-plugin-helper\n```\n\nUpdate your package.json script section:\n```javascript\n  \"scripts\": {\n    \"helper\": \"./node_modules/.bin/pouchdb-plugin-helper\",\n    \"test\": \"npm run helper -- test\",\n    // optional. The argument is the name of the browserify object on window\n    \"build\": \"npm run helper -- build Auth\"\n  }\n```\n\nCommands\n--------\n\n```bash\nnpm run helper -- build # builds a browserified version of the package\nnpm run helper -- coverage # run js tests with coverage\nnpm run helper -- js-test # run js tests\nnpm run helper -- lint # run linter against source files\nnpm run helper -- test # shortcut for lint \u0026 coverage\nnpm run helper -- badges # generate badges for use in README.md\nnpm run helper -- travis # generate a relevant .travis.yml file\nnpm run helper -- gitignore # generate a relevant .gitignore file\nnpm run helper -- test # runs lint and coverage\n```\n\n### Notes\n\n- The ``build`` command will generate both a minified and an unminified\n  file in the dist/ subdirectory. It gets an argument: a name as used for\n  on the ``window`` object.\n- The ``coverage`` command will put coverage info in the ``coverage``\n  subdirectory. It has a non-zero exit code if coverage isn't 100%.\n- The ``js-tests`` command runs all tests in the ``test`` subdirectory. It uses\n  [mocha](https://mochajs.org/) to do so. Files in this directory (and in this\n  directory only!) can use ES6, with as a bonus ES7's async \u0026 await.\n\nrequire() helpers\n-----------------\n\n```javascript\nimport {/* e.g.*/ PouchDB, should} from 'pouchdb-plugin-helper/testutils');\n```\n\n### PouchDB\nA PouchDB object that by default makes a\n[memdown](https://github.com/Level/memdown) backed database.\n\n### should\nA [chai](http://chaijs.com/) object used to make assertions. E.g.:\n\n```javascript\nshould.exist(undefined) // error\ntrue.should.be.ok // no problem\n```\n\n### setup()\nMakes a PouchDB database and returns it to you. Handy for use in ``mocha``'s\n``beforeEach``.\n\n### setupWithDoc()\n``setup()``, with the following document in the database:\n```javascript\n{\n  _id: 'mytest',\n  test: true\n}\n```\n\nReturns a promise which resolves to the following object:\n```javascript\n{\n  db: '\u003cthe pouchdb db\u003e',\n  rev: '1-xxx'\n}\n```\n\n### setupWithDocAndAttachment\n``setupWithDoc``, with the following attachment added to the database:\n```javascript\n{\n  _id: 'attachment_test',\n  _attachments: {\n    'text': {\n      data: new Buffer('abcd', 'ascii'),\n      type: 'text/plain'\n    }\n  }\n}\n```\n\n### setupHTTP()\nSimilar to ``setup()``, but then on the database specified by ``BASE_URL`` and ``HTTP_AUTH`` (see below). Don't use at the same time as ``setup()``.\n\n### teardown()\nCleans up the database created by ``setup()`` or ``setupHTTP``. Handy for use in ``mocha``'s\n``afterEach``. Returns a Promise.\n\n### shouldThrowError(func)\n``func`` should be a promise, and this function returns a promise too.\n\nThis function runs ``func``, and catches any error that's thrown by it. The\nfunction resolves into this error. If no error is thrown, it fails. An example\nof how it can be used:\n\n```javascript\nconst error = await shouldThrowError(async () =\u003e\n  await db.get('unexisting-doc')\n);\nerror.status.should.equal(404);\n```\n\n### Configuration constants\nSome properties of the tests can be configured. These values are available under\nthe names:\n\n``BASE_URL``: defaults to 'http://localhost:5984'\n``HTTP_AUTH``: defaults to null\n\nYou can change these values to your own development setup by making a file\n``~/.pouchdb-plugin-helper-conf.json``, with context like this:\n\n```javascript\n{\n  base_url: 'http://localhost:5985',\n  username: 'test',\n  password: 'test'\n}\n```\n\nAll keys are optional.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpouchdb%2Fpouchdb-plugin-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpouchdb%2Fpouchdb-plugin-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpouchdb%2Fpouchdb-plugin-helper/lists"}