Jest: TypeError: str.matchAll is not a function only during tests

Created on 14 Nov 2019  路  3Comments  路  Source: facebook/jest

馃悰 Bug Report

In a project where we've setup both babel and jest there is a problem where the .matchAll() method is not found in a string instance only in the tests. When running the code normally via babel-node everything is fine. When the same code is ran through a test it fails with:

TypeError: str.matchAll is not a function

To Reproduce

Create a project where you are using string.matchAll(). Setup babel with babel-node to make it runnable. Setup babel-jest to make the same code runnable in tests. Write a test for the same code. Run the test and see the error above.

Expected behavior

No error should be displayed and the test should pass or fail as expected. Running a piece of code through babel-node and through jest should have the same behavior.

Link to repl or repo (highly encouraged)

Use this repo. Check the README.

envinfo

  System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
  Binaries:
    Node: 10.16.3 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.19.1 - C:\Program Files\nodejs\yarn.CMD
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    jest: ^24.9.0 => 24.9.0
Bug Report Needs Repro Needs Triage

Most helpful comment

Seems like the NodeJS version makes a difference. Using NodeJS 10 fails the test, but using NodeJS 12 it passes.

https://node.green/#ES2020-features-String-prototype-matchAll

All 3 comments

Your repro passes for me
image

Hm, interesting. I will investigate more and report back. Thank you.

Seems like the NodeJS version makes a difference. Using NodeJS 10 fails the test, but using NodeJS 12 it passes.

https://node.green/#ES2020-features-String-prototype-matchAll

Was this page helpful?
0 / 5 - 0 ratings