Search code examples
javascriptava

node ava, t.context is not available in before test


Following the readme, this test should work:

test.before(t => { t.context = 'unicorn'; });

but it returns back: t.context is not available in before tests

I expected this to be implemented in the version 0.25, am I doing something wrong?

ava version: "0.25.0" Node.js v8.9.1 darwin 17.4.0 npm --version 5.6


Solution

  • Please check this answer.

    The documentation you see on GitHub relates to version 1.0.0-beta.3 not to the stable release that was published to npm (which is 0.25.0).

    So as you can see for the version 0.25.0 context is available only in .beforeEach hook.

    If you want to use it in .before you gotta install the latest beta:

    npm i ava@next --save-dev