{"name":"zora","version":"2.0.1","description":"tap test harness for nodejs and browsers","keywords":["tap","test","node","browsers","testing","tests","harness","tap-producer"],"main":"./dist/","module":"index.js","jsnext:main":"index.js","repository":{"type":"git","url":"git+https://github.com/lorenzofox3/zora.git"},"scripts":{"clean":"rm -rf ./dist","clean:benchmark":"rm -r ./benchmarks && mkdirp ./benchmarks/zora/test/ ./benchmarks/ava/test ./benchmarks/jest/test ./benchmarks/mocha/test ./benchmarks/tape/test","build:benchmark":"npm run clean:benchmark && node ./scripts/generate.js","bench:zora":"time (node ./benchmarks/zora/index.js)","bench:ava":"time ava ./benchmarks/ava/test/","bench:mocha":"time mocha ./benchmarks/mocha/test/","bench:tape":"time (node ./benchmarks/tape/index)","bench:jest":"time jest","build":"npm run clean && rollup -c ./rollup/build.js && rollup -c ./rollup/build-cdn.js","test:unit":"rollup -c ./rollup/test.js | node","test":"npm run test:unit && node ./test/samples/index.js | tap-diff && node ./test/samples/bsd/index | tap-mocha-reporter spec","xo":"xo lib/*.js index.js"},"author":{"name":"Laurent Renard","email":"laurent34azerty@gmail.com"},"license":"MIT","dependencies":{"deep-equal":"^1.0.1"},"devDependencies":{"ava":"^0.25.0","jest":"^22.2.2","mkdirp":"^0.5.1","mocha":"^5.0.0","rollup":"^0.55.4","rollup-plugin-commonjs":"^8.3.0","rollup-plugin-node-resolve":"^3.0.2","tap-diff":"^0.1.1","tap-mocha-reporter":"^3.0.6","tape":"^4.8.0","xo":"^0.18.2"},"jest":{"testRegex":".*.js","roots":["./benchmarks/jest/test"],"testEnvironment":"node"},"gitHead":"b9c2d608c80a48edee49e48a766ec4a73098f3cd","bugs":{"url":"https://github.com/lorenzofox3/zora/issues"},"homepage":"https://github.com/lorenzofox3/zora#readme","_id":"zora@2.0.1","_npmVersion":"5.7.1","_nodeVersion":"8.8.1","_npmUser":{"name":"lorenzofox3","email":"laurent34azerty@gmail.com"},"dist":{"integrity":"sha512-BHq+KJR3HZLZXU7MDMzAF69cKC6I1EiVzlS3/gFia61FsFx4dbwb3PP9r2q83Kalk5Z65oe+yqvWmqKnuWbp7Q==","shasum":"8fbc3ef6a7fb0413406f05264566f57819240a6b","tarball":"http://registry-npm.ywwl.com/zora/download/zora-2.0.1.tgz","fileCount":14,"unpackedSize":140927,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEVy/UGgvy9EbQgZuaTQgrQWScyomr6c8jlBlO1c1/DwAiEA4MWcvqpnKF+LT4UaHZ0DADzFK7mGTdG4jlYGPrDK2aI="}],"size":26679,"noattachment":false,"key":"/zora/-/zora-2.0.1.tgz"},"maintainers":[{"name":"lorenzofox3","email":"laurent34azerty@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zora_2.0.1_1523024399243_0.3194726290706291"},"_hasShrinkwrap":false,"readme":"# Zora\n\n[![npm](https://badgen.net/npm/v/zora)](https://www.npmjs.com/package/zora)\n[![install size](https://badgen.net/packagephobia/install/zora)](https://packagephobia.now.sh/result?p=zora)\n\n## Usage\n\nThe library is a _regular_ Javascript module and can be directly imported from a CDN:\n\n```Javascript\nimport {test} from 'https://unpkg.com/zora@latest/dist/index.js'\n\ntest(`hello from zora`, ({ok}) => {\n    ok(true, 'it worked');\n})\n```\n\n(Like in the [following codepen](https://codepen.io/lorenzofox3/pen/LYWOaYV?editors=1111))\n\nOr installed via a package manager such [NPM](https://www.npmjs.com/) by running the command (assuming you have [Nodejs](https://nodejs.org/en/) installed on your machine):\n\n``npm i -D zora``\n\nYou can then build your testing program by using the exported ``test`` function\n\n```Javascript\nimport {test} from 'zora';\n\ntest(`my very first test`, (assertion) => {\n    const input = false;\n    assertion.ok(input, 'input should be truthy');\n})\n\n```\n\nYou can run the testing program (with node's runtime for example) and it will start reporting its execution into the console \n\n<details>\n    <summary>test-output.tap</summary>\n\n```TAP\nTAP version 13\n# my very first test\nnot ok 1 - input should be truthy\n  ---\n    actual: false\n    expected: \"truthy value\"\n    operator: \"ok\"\n    at: \" file:///path/to/sample.js:5:13\"\n  ...\n\n1..1\n# tests 1\n# pass  0\n# fail  1\n# skip  0\n\n```\n\n</details>\n\n## Reporters\n\nThis output format is called [TAP](https://testanything.org/tap-version-13-specification.html) (Test Anything Protocol). It is a standard text based format a machine can easily parse. It means there are [plenty of reporters](https://www.npmjs.com/search?q=tap%20reporter) you can pipe the standard output stream into (not only in the Javascript world). This will help you to tailor the reporting for your particular needs.\n\nfor example, you can use [tap-diff](https://www.npmjs.com/package/tap-diff):\n``node path/to/testing/program.js | tap-diff``\n\nYou can even use basic bash command:\n\n``node path/to/testing/program.js | grep '^not ok\\|^\\s'`` will output a basic, straight to the point test report:\n\n```\nnot ok 1 - input should be truthy\n  ---\n    actual: false\n    expected: \"truthy value\"\n    operator: \"ok\"\n    at: \" file:///path/to/sample.js:5:13\"\n  ...\n```\n\nThat is the beauty of using different processes to run the testing program and to format its output: it remains very flexible.\n\n## Assertion API\n\nWhen you start a test suite with the ``test`` function. The spec functions you pass as argument will get an instance of the [Assertion object](../assert) so you can write a wide range of different expectations.\n\nFor the best performances, all the spec functions run concurrently unless you specifically wait for them within an asynchronous function (if for some reason, you want to run some test one after the other, in a serial mode).\n\n<details>\n    <summary>control-flow.js</summary>\n\n```Javascript\nimport {test} from 'zora';\n\nlet state = 0;\n\ntest('test 1', t => {\n    t.ok(true);\n    state++;\n});\n\ntest('test 2', t => {\n    //Maybe yes maybe no, you have no guarantee ! In this case it will work as everything is sync\n    t.equal(state, 1);\n});\n\n//Same thing here even in nested tests\ntest('grouped', t => {\n    let state = 0;\n\n    t.test('test 1', t => {\n        t.ok(true);\n        state++;\n    });\n\n    t.test('test 2', t => {\n        //Maybe yes maybe no, you have no guarantee ! In this case it will work as everything is sync\n        t.equal(state, 1);\n    });\n});\n\n//And\ntest('grouped', t=>{\n    let state = 0;\n\n    t.test('test 1', async t=>{\n        t.ok(true);\n        await wait(100);\n        state++;\n    });\n\n    test('test 2', t=>{\n        t.equal(state, 0, 'see the old state value as it will have started to run before test 1 is done');\n    });\n});\n\n//But\ntest('grouped', async t => {\n    let state = 0;\n\n    //specifically WAIT for the end of this test before moving on !\n    await t.test('test 1', async t => {\n        t.ok(true);\n        await wait(100);\n        state++;\n    });\n\n    test('test 2', t => {\n        t.equal(state, 1, 'see the updated value!');\n    });\n});\n```\n\n</details>\n\n\n## Environment variables\n\nYou can _configure_ the testing program with environment variables. With nodejs, simply pass it with the command line:\n\n``ZORA_REPORTER=json node path/to/testing/program.js``\n\nIn the browser, you have to set it as a global before the testing program runs:\n\n```HTML\n<script>\n    window.ZORA_REPORTER='json'\n</script>\n<script type=\"module\">\n    import {test} from 'url/to/zora';\n    \n    test('some test', (t) => {\n        t.ok(true);\n    })\n</script>\n```\n\n### ZORA_REPORTER=json\n\nBy default, the output is a TAP stream; but you can decide to produce a stream defined by [the zora json protocol messages](../reporters) if you which to build a custom reporter on top of it.\n\n### ZORA_ONLY=true\n\nBeside the ``test`` function you can use the ``only`` function if you wish to skip all the other tests. However, from the testing program perspective, ``only`` is meaningless: it is just a convenience for a developer, locally on its machine.  \nSo if you wish to use ``only`` you need to pass the ``ZORA_ONLY`` environment variable, otherwise the program will throw an exception to prevent ``only`` statement to slip in the remote versioning control system.\n\nBeware that if you want to run only a nested test suite, all the parent test suites must use the ``only statement`:`\n\n<details>\n    <summary>test-with-only.js</summary>\n\n```Javascript\nimport {only, test} from 'zora';\n\ntest('will be skipped', t => {\n    t.ok(false);\n})\n\nonly('some test', t => {\n \n    // will be skipped as well\n    t.test('some nested test', t => {\n        t.ok(false);\n    });\n    \n    // will run\n    t.only('some other nested test', t => {\n        t.ok(true);\n    });\n});\n```\n\n</details>\n\n### ZORA_TIMEOUT\n\nIn milliseconds: change the default test timeout value (see below)\n\n## test timeout\n\nIf a test hangs or takes too long to complete, it will report a failure. By default, the threshold is 5000ms. You can change that global value thanks to the ``ZORA_TIMEOUT`` environment variable.\nYou can change that value for a given text as well, thanks to the options object:\n\n<details>\n    <summary>timeout example</summary>\n\n```Javascript\ntest(\n  'broken promise',\n  ({ ok }) => {\n    return new Promise(() => {}).then(() => {\n      ok(true);\n    });\n  },\n  { timeout: 500 }\n);\n```\n\n</details>\n\n## skip a test\n\nYou can skip a test using the root level ``skip`` function or within a test suite using the ``skip`` method of the assertion object\n\n<details>\n    <summary>test-with-skip.js</summary>\n\n```Javascript\nimport {skip, test} from 'zora';\n\nskip('will be skipped', t => {\n    t.ok(false);\n})\n\ntest('some test', t => {\n \n    // will be skipped as well\n    t.skip('some nested test', t => {\n        t.ok(false);\n    });\n    \n    // will run\n    t.test('some other nested test', t => {\n        t.ok(true);\n    });\n});\n```\n\n</details>\n","publish_time":1523024399354,"_cnpm_publish_time":1523024399354,"dist-tags":{"latest":"6.0.4","next":"5.0.0-beta.1"}}