Skip to content

Impossible to use t.try in before hook #2511

Closed
@tymfear

Description

@tymfear

Please provide details about:

  • What you're trying to do
    Use t.try in the test.before hook

  • What happened
    The following error is thrown:

  TypeError {
    message: 'test.registerUniqueTitle is not a function',
  }
  • What you expected to happen
    No error are thrown

Please share relevant sample code. Or better yet, provide a link to a minimal reproducible example.

import anyTest, { ExecutionContext, TestInterface } from 'ava';
const test: TestInterface = anyTest as TestInterface;

test.before(async (t: ExecutionContext) => {
  const res = await t.try((tt: ExecutionContext) => tt.is(1, 1))

  res.commit();
})

test('test', async (t: ExecutionContext) => t.pass());

We'll also need your AVA configuration (in package.json or ava.config.* configuration files) and how you're invoking AVA. Share the installed AVA version (get it by running npx ava --version).
AVA version: 3.8.2

Config:

export default function factory() {
  return {
    require: ['ts-node/register', 'tsconfig-paths/register'],
    files: ['spec/**/*'],
    cache: true,
    failWithoutAssertions: true,
    verbose: true,
    extensions: ['ts'],
    concurrency: process.env.AVA_CONCURRENCY || 10,
    timeout: '90s',
  };
}

AVA is invoked with npx ava path/to/file command. Also reproducible with IDEA Node configuration

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions