{"_id":"@atom/babel-plugin-chai-assert-async","_rev":"3-30c16100585e3161861df40d9cd69175","name":"@atom/babel-plugin-chai-assert-async","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0-0":{"name":"@atom/babel-plugin-chai-assert-async","version":"1.0.0-0","description":"await assert.async()","repository":{"type":"git","url":"git+https://github.com/atom/babel-plugin-chai-assert-async.git"},"license":"MIT","author":{"name":"Michelle Tilley","email":"michelle@michelletilley.net"},"main":"lib/index.js","devDependencies":{"@babel/cli":"7.2.3","@babel/core":"7.3.4","@babel/preset-env":"7.3.4","@babel/register":"7.0.0","chai":"4.2.0","dedent-js":"1.0.1","mocha":"6.0.2","test-until":"^1.1.1"},"peerDependencies":{"@babel/core":"7.x","test-until":"1.x"},"scripts":{"clean":"rm -rf lib","build":"babel src -d lib","test":"npm run prepublish && mocha --require @babel/register test","prepublish":"npm run clean && npm run build"},"keywords":["babel","chai","assert","async","babel-plugin"],"dependencies":{"@babel/helper-module-imports":"7.0.0"},"gitHead":"165a029fc87218ce437065ac5eb53ce36848400a","bugs":{"url":"https://github.com/atom/babel-plugin-chai-assert-async/issues"},"homepage":"https://github.com/atom/babel-plugin-chai-assert-async#readme","_id":"@atom/babel-plugin-chai-assert-async@1.0.0-0","_nodeVersion":"8.9.3","_npmVersion":"6.8.0","dist":{"integrity":"sha512-Hh0JrFu7THfCVJEudceu92KR0vaTXHx6QW2kWdZiUnfOXFskc55TUCXJZ39tdEIX14HQboVBYr+EM5LzPV714w==","shasum":"fabffc752f036327a592de00d9ee90bf83f29e62","tarball":"https://registry.npmjs.org/@atom/babel-plugin-chai-assert-async/-/babel-plugin-chai-assert-async-1.0.0-0.tgz","fileCount":7,"unpackedSize":10752,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcdFlpCRA9TVsSAnZWagAA2OwP/1pNU3sModFrNssz8SjM\nnf6/SWukMICR/37/4ttCOaIqQaJJPQ1qZUDhiA9LylMehWDg/tt7H6HE9PFG\nFFcAKyrOtgvlLSzx7qkAEFYBiOs9dz9micOhqaIyegr6ttyLmb3ggi6oYgsU\nNsNPlmVG/Og4o9j1g2Dn/7Hc1igCRa/XgFvcFca3FThf/yiWSDox0CloPtKt\nlwlXPc/n4dqJ8cSAPU0o3dcLa3xqoU5Tq5dcExA+SGPl4TbeINRtP3RVTFzb\nttINLF06sKdhPyKZbfxg+CwVhfIS8pRME+IYAilRu2e72i4jK9UzvQRfpcn5\nG8n/I9M3gUc6EKs5Gun0RKJZ9/FzFKM3GRF04rMj9BcXBESksBQWcT2Qrzvy\nC11JCfAuoKxmKL/7pE7eD6HqU6tLQ+EhmCzn1M7X0UzhRRxNTaU1XQsOB/yP\nopFSzvz/Xtjr9IAJDcnLbW/aK5jPeSrlBKXhUyKa2K+LqYI6YEmPTMmvmILl\n1Y4R8UeYdq/ceuuWbBy+qoe8FjCOwr+taTuOaIx2xa5zw1UOGJ0YLSE/nzi0\nNFvB9f4V4mG94PLrJ2YJcioL3qv/2lmEwDH5+NP0GJEx0fTFOxEeJDYQBB5I\neCGsOV/5/o0Wb7UG4xPUYoojuz2k/vF2mWdq5GUuoj8VvPPKyODA3RkA/gVO\npnru\r\n=jKkW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGIPmPrHHB9IkQ6OFnSbX2jyhBWBGiKYfdBpvsbI1QqcAiEAm0eyCUC2tMGSYNcEgYjfkedRoEMT/pBSVXOWhyIZsYs="}]},"maintainers":[{"name":"daviwil","email":"daviwil@github.com"},{"name":"binarymuse","email":"michelle@michelletilley.net"},{"name":"kuychaco","email":"kuychaco@gmail.com"},{"name":"atom-team","email":"atom@github.com"},{"name":"smashwilson","email":"smashwilson@gmail.com"},{"name":"nathansobo","email":"nathan@github.com"},{"name":"maxbrunsfeld","email":"maxbrunsfeld@gmail.com"},{"name":"simurai","email":"sim@simurai.com"},{"name":"iolsen","email":"ian.olsen@gmail.com"},{"name":"as-cii","email":"as-cii@github.com"},{"name":"jasonrudolph","email":"jason@jasonrudolph.com"},{"name":"lee-dohm","email":"lee@lee-dohm.com"},{"name":"donokuda","email":"helloyesthisisdon@gmail.com"}],"_npmUser":{"name":"smashwilson","email":"smashwilson@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/babel-plugin-chai-assert-async_1.0.0-0_1551128936721_0.3447658905898303"},"_hasShrinkwrap":false},"1.0.0":{"name":"@atom/babel-plugin-chai-assert-async","version":"1.0.0","description":"await assert.async()","repository":{"type":"git","url":"git+https://github.com/atom/babel-plugin-chai-assert-async.git"},"license":"MIT","author":{"name":"Michelle Tilley","email":"michelle@michelletilley.net"},"main":"lib/index.js","devDependencies":{"@babel/cli":"7.2.3","@babel/core":"7.3.4","@babel/preset-env":"7.3.4","@babel/register":"7.0.0","chai":"4.2.0","dedent-js":"1.0.1","mocha":"6.0.2","test-until":"^1.1.1"},"peerDependencies":{"@babel/core":"7.x","test-until":"1.x"},"scripts":{"clean":"rm -rf lib","build":"babel src -d lib","test":"npm run prepublish && mocha --require @babel/register test","prepublish":"npm run clean && npm run build"},"keywords":["babel","chai","assert","async","babel-plugin"],"dependencies":{"@babel/helper-module-imports":"7.0.0"},"gitHead":"ab2aab066c5d368b800e5449b8369cbaad2f29bc","bugs":{"url":"https://github.com/atom/babel-plugin-chai-assert-async/issues"},"homepage":"https://github.com/atom/babel-plugin-chai-assert-async#readme","_id":"@atom/babel-plugin-chai-assert-async@1.0.0","_nodeVersion":"8.9.3","_npmVersion":"6.8.0","dist":{"integrity":"sha512-YGYfZkFzMfw/fa/vVivqSMJQPN/wbReg6ikTq53/CDsN3aZgtdWKwYOQThExN0GvrgXsTGqmZl5uWs1hccKE5w==","shasum":"94bfb18f4e343950c7cdfaa9b4023014b962a902","tarball":"https://registry.npmjs.org/@atom/babel-plugin-chai-assert-async/-/babel-plugin-chai-assert-async-1.0.0.tgz","fileCount":7,"unpackedSize":10801,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcdF6VCRA9TVsSAnZWagAAxEQQAIDMRNdITDJS+RUfK2Oc\nkZ4kblby6vdNz4JnKjbTsHyckI6x102pT9azE/dHQcocKalVFjYy3IdIzdJX\n4qgcxI+Nmd3DrMr2Zmi0z6So8Ph5+dW7hnrXss03pHG1RAYo+a02rbJ5LC/y\nqa4En96kVqH8A3sHx6m4VLOv+NwVIee1rx3nuBaSdYqGMiC3M4L2jSgrZ9fI\ni3/BY/GZTL1bOxSoxDGBXXdxAn5jRI2R3dKWGB4KKZ46wrG6Sr7UTzCbCCdL\njgjL36+UualScu0T2mG0cnMoKRjESjnj65BAj3CkIbTsYmiAcpJGD8QoxX3h\nnk6vHnWDCFW3dUk5NbwmrzjsdsLAtg5ckM9USI5I/1J7e2XdGiavK7QyLY3H\niJEuX1PyRUSqfERxzjZfyRj4s5HsDpCmSMAg9DKa+jvZYKCSybG0fMOLMRMR\n2GykHloaHW3fanJa7EgZgRS9VvRuTS0mcJNqei17+mjCJZwzs0kB06tAJ6R9\nWHhMYyTZTmrH8k3DvH44c6NE+izD8+7wuO02yHUHJOoW7MydhHhL13QpCuDo\nrSlPyK0Z2w0xcxkQ3xRSuaW3r3vcqiv5Gm48I64u+SQM6Nb6gJEpN8MBnlim\nrr8VAh8mjuNuL/G0jey8wPj9tOs56nsIGIHrYytwQdYI4ZevpZ/ICtbNw2U0\n0vaO\r\n=yJ+d\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEFYL1oZQW232PuBdzufFGx0eF61Wrpfd09mCNl2aBH+AiEAgxoNpTF2IxYG8R/bszbPPt4IP1fZbXVp/poeH0Vfz5c="}]},"maintainers":[{"name":"as-cii","email":"as-cii@github.com"},{"name":"atom-team","email":"atom@github.com"},{"name":"binarymuse","email":"michelle@michelletilley.net"},{"name":"daviwil","email":"daviwil@github.com"},{"name":"donokuda","email":"helloyesthisisdon@gmail.com"},{"name":"iolsen","email":"ian.olsen@gmail.com"},{"name":"jasonrudolph","email":"jason@jasonrudolph.com"},{"name":"kuychaco","email":"kuychaco@gmail.com"},{"name":"lee-dohm","email":"lee@lee-dohm.com"},{"name":"maxbrunsfeld","email":"maxbrunsfeld@gmail.com"},{"name":"nathansobo","email":"nathan@github.com"},{"name":"simurai","email":"sim@simurai.com"},{"name":"smashwilson","email":"smashwilson@gmail.com"}],"_npmUser":{"name":"smashwilson","email":"smashwilson@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/babel-plugin-chai-assert-async_1.0.0_1551130260386_0.9814960443338354"},"_hasShrinkwrap":false}},"time":{"created":"2019-02-25T21:08:56.596Z","1.0.0-0":"2019-02-25T21:08:57.017Z","modified":"2022-04-04T16:14:25.431Z","1.0.0":"2019-02-25T21:31:00.554Z"},"maintainers":[{"email":"mazen.elkashef@gmail.com","name":"kashef"},{"email":"daviwil@github.com","name":"daviwil"},{"email":"michelle@michelletilley.net","name":"binarymuse"},{"email":"kuychaco@gmail.com","name":"kuychaco"},{"email":"atom@github.com","name":"atom-team"},{"email":"smashwilson@gmail.com","name":"smashwilson"},{"email":"nathan@github.com","name":"nathansobo"},{"email":"maxbrunsfeld@gmail.com","name":"maxbrunsfeld"},{"email":"sim@simurai.com","name":"simurai"},{"email":"ian.olsen@gmail.com","name":"iolsen"},{"email":"as-cii@github.com","name":"as-cii"},{"email":"jason@jasonrudolph.com","name":"jasonrudolph"},{"email":"lee@lee-dohm.com","name":"lee-dohm"},{"email":"helloyesthisisdon@gmail.com","name":"donokuda"}],"description":"await assert.async()","homepage":"https://github.com/atom/babel-plugin-chai-assert-async#readme","keywords":["babel","chai","assert","async","babel-plugin"],"repository":{"type":"git","url":"git+https://github.com/atom/babel-plugin-chai-assert-async.git"},"author":{"name":"Michelle Tilley","email":"michelle@michelletilley.net"},"bugs":{"url":"https://github.com/atom/babel-plugin-chai-assert-async/issues"},"license":"MIT","readme":"# babel-plugin-chai-assert-async\n\nTransforms `assert.async.*` calls into `test-until` expressions that resolve when the assertion passes, preserving error messages for failed assertions.\n\n[![Build Status](https://travis-ci.org/atom/babel-plugin-chai-assert-async.svg?branch=master)](https://travis-ci.org/atom/babel-plugin-chai-assert-async)\n\n## Installation\n\nAssuming you're [already using Babel](http://babeljs.io/docs/setup/), install the Babel plugin *and the peer dependency* with your package manager of choice:\n\n```sh\n$ npm install @atom/babel-plugin-chai-assert-async test-until\n```\n\n## Usage\n\n### Via `.babelrc`\n\n**.babelrc**\n\n```json\n{\n  \"plugins\": [\"@atom/babel-plugin-chai-assert-async\"]\n}\n```\n\n### Via CLI\n\n```sh\n$ babel --plugins @atom/babel-plugin-chai-assert-async script.js\n```\n\n### Via Node API\n\n```javascript\nrequire(\"babel-core\").transform(\"code\", {\n  plugins: [\"@atom/babel-plugin-chai-assert-async\"]\n});\n```\n\n## Details\n\nDuring tests, it's sometime's useful to test values that are set asynchronously, or to wait for a condition to be true before continuing the test. Here's a convoluted example:\n\n```javascript\nfunction setValueAsync(obj) {\n  setTimeout(() => obj.val = 42, 100)\n}\n\ndescribe('setValueAsync', function() {\n  it('sets a value asynchronously', function() {\n    const obj = {val: 0}\n    setValueAsync(obj)\n    assert.equal(obj.val, 42) // will fail\n  })\n})\n```\n\nThis test will fail because `obj.val` does not equal `42` at the time the assertion is run.\n\nWe can use [a library like `test-until`](https://www.npmjs.com/package/test-until) to ensure the test doesn't continue until `obj.val` does equal `42`. Here's an example with Mocha, `async`/`await`\n\n```javascript\nimport until from 'test-until'\n// ....\nit('sets a value asynchronously', function() {\n  const obj = {val: 0}\n  setValueAsync(obj)\n  await until(() => obj.val === 42)\n})\n```\n\nHowever, in converting from the `assert.equal` version of this test to the `await until` version, we lost some information. In particular, it's more difficult to know exactly what we're testing, and if the `until` expression times out, we get a very generic error message like \"timed out waiting for something to happen\" instead of something useful like \"expected obj.val to equal 42\".\n\nThis transform allows you to convert something like `assert.equal(obj.val, 42)` into an equivalent `until` expression by writing `assert.async.equal(obj.val, 42)`:\n\n```javascript\nfunction setValueAsync(obj) {\n  setTimeout(() => obj.val = 42, 100)\n}\n\ndescribe('setValueAsync', function() {\n  it('sets a value asynchronously', async function() {\n    const obj = {val: 0}\n    setValueAsync(obj)\n    await assert.async.equal(obj.val, 42)\n  })\n})\n```\n\nIn this case, if the async assertion fails, the original error message like \"expected obj.val to equal 42\" will be preserved.\n\nIf you want to pass a timeout to `test-until`, you can specify it as an argument to `async`:\n\n```javascript\nawait assert.async(100).equal(obj.val, 42)\n```\n\n## Examples\n\n**Basic**\n\nIn\n\n```js\nasync function test() {\n  await assert.async.equal(thing, other);\n}\n```\n\nOut\n\n```js\n\"use strict\";\n\nimport until from 'test-until';\n\nasync function test() {\n  await until(async function (fail) {\n    try {\n      assert.equal(thing, other);\n      return true;\n    } catch (err) {\n      return fail(err);\n    }\n  });\n}\n```\n\n**With explicit timeout**\n\nIn\n\n```js\nasync function test() {\n  await assert.async(500).equal(thing, other);\n}\n```\n\nOut\n\n```js\n\"use strict\";\n\nimport until from 'test-until';\n\nasync function test() {\n  await until(async function (fail) {\n    try {\n      assert.equal(thing, other);\n      return true;\n    } catch (err) {\n      return fail(err);\n    }\n  }, 500);\n}\n```\n","readmeFilename":"README.md"}