Jest: [Discussion] Test Macros

Created on 7 Dec 2016  路  2Comments  路  Source: facebook/jest

In Ava, extraneous arguments you pass to it are passed to the function.

const testMacro = (input, expectedValue) => {
  const actualValue = parse(input);
  expect(actualValue).toEqual(expectedValue);
};

test('title', testMacro, 'input', 'expected');

Would something like this be useful for Jest? I know I would use it a lot.

The current behaviour is that the third argument is used as a timeout for async tasks. Changing this would be a breaking change.

Question

Most helpful comment

Yeah we cannot break this right now. We are considering to adopt other test libraries instead of Jasmine and Ava's API is awesome, so I'd love to have a standalone version of that. I'm going to close this issue out for now as we aren't likely to build this.

All 2 comments

Not exactly the same, but you can use similar syntax:

test('title', testMacro.bind(this, 'input', 'expected'));

Yeah we cannot break this right now. We are considering to adopt other test libraries instead of Jasmine and Ava's API is awesome, so I'd love to have a standalone version of that. I'm going to close this issue out for now as we aren't likely to build this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nsand picture nsand  路  3Comments

paularmstrong picture paularmstrong  路  3Comments

stephenlautier picture stephenlautier  路  3Comments

samzhang111 picture samzhang111  路  3Comments

Secretmapper picture Secretmapper  路  3Comments