Ava: t.throws async example fails

Created on 13 Feb 2018  Â·  4Comments  Â·  Source: avajs/ava

The following test comes from the example from the docs,:

test('throws', async t => {
    const error = await t.throws(async () => {
        throw new TypeError('🦄');
    }, TypeError);

    t.is(error.message, '🦄');
});

Error Message & Stack Trace

  ✖ throws
Unhandled Rejection: app/services/services.test.js
  TypeError: 🦄
    _callee$ (app/services/services.test.js:100:11)
    tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
    GeneratorFunctionPrototype.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
    GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
    step (app/services/services.test.js:9:191)
    app/services/services.test.js:9:437
    app/services/services.test.js:9:99
    _tryBlock (node_modules/core-assert/index.js:311:5)
    _throws (node_modules/core-assert/index.js:330:12)
    Function.assert.throws (node_modules/core-assert/index.js:360:3)
    _callee2$ (app/services/services.test.js:99:25)
    tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
    GeneratorFunctionPrototype.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:303:22)
    GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
    step (app/services/services.test.js:9:191)
    app/services/services.test.js:9:437
    Test.<anonymous> (app/services/services.test.js:9:99)
    Test.fn (app/services/services.test.js:98:1)
    processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)
    processEmit [as emit] (node_modules/nyc/node_modules/signal-exit/index.js:155:32)

Config

Copy the relevant section from package.json:

{
  "ava": {
    "files": [
      "app/**/*.test.js"
    ],
    "source": [
      "app/**/*.js"
    ],
    "require": [
      "babel-register",
      "./test/helpers/setupBrowserEnv.js"
    ],
    "babel": "inherit"
  },
}

Command-Line Arguments

 ava --verbose --env test

Environment

npm --versionNode.js v6.12.3
darwin 17.4.0
ava --version 0.22.0
npm --version = 3.10.10

Most helpful comment

@leegee after Babel 7 does. But if your project doesn't use Babel itself, or is already using Babel 7, then you should use AVA's beta releases.

All 4 comments

The documentation is for a newer AVA version. Since you're using v0.22 you'll want to be looking here: https://github.com/avajs/ava/tree/v0.22.0.

This feature is available as of 1.0.0-beta.1, which you can install through npm install ava@next. Here's the release notes: https://github.com/avajs/ava/releases/tag/v1.0.0-beta.1.

Many thanks. Thought it might relate to #73

This feature is available as of 1.0.0-beta.1

Do you have a road map for when it might leave beta?

TIA
Lee

@leegee after Babel 7 does. But if your project doesn't use Babel itself, or is already using Babel 7, then you should use AVA's beta releases.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

avaly picture avaly  Â·  4Comments

ivogabe picture ivogabe  Â·  5Comments

clitetailor picture clitetailor  Â·  3Comments

ehmicky picture ehmicky  Â·  4Comments

fregante picture fregante  Â·  3Comments