React-testing-library: [bug] act-compat assume console.error is called with a string

Created on 14 Aug 2019  路  7Comments  路  Source: testing-library/react-testing-library

  • react-testing-library version:
  • react version:
  • node version:
  • npm (or yarn) version:

Relevant code or config:

Code is situated here: https://github.com/testing-library/react-testing-library/blob/master/src/act-compat.js#L32

args[0].indexOf(
              'Warning: Do not await the result of calling ReactTestUtils.act',
            ) === 0

This assumes the first arg passed to console.error is a string; but the type could be different. For example, it can be an object console.error({ error })

Suggested solution:

We could either:

  1. Stringify the args before calling indexOf
  2. Type check the arg first

Most helpful comment

@kentcdodds I can go ahead and add some type checking to the args for this.

All 7 comments

Type check the arg first

This seems fine, since the condition is always false (never matches) when the input is not a string

Agreed. Would you like to make a pull request for this @SBoudrias?

@kentcdodds I can go ahead and add some type checking to the args for this.

@ely-alamillo you still taking this? I can also do this one?

@rvdkooy yes, there was a blocking issue but it's now resolved so i'm still working on this.

If I don't get anything in by the eow you can take it.

Why does this case exist if it's not doing anything ? https://github.com/testing-library/react-testing-library/blob/master/src/act-compat.js#L38

@kentcdodds

Was this page helpful?
0 / 5 - 0 ratings

Related issues

julienw picture julienw  路  4Comments

good-idea picture good-idea  路  4Comments

mezei picture mezei  路  3Comments

jalvarado91 picture jalvarado91  路  3Comments

alejandronanez picture alejandronanez  路  4Comments