Vue-test-utils: Tests do fail if Array.flat() is used in *.spec.js or in the application

Created on 11 Sep 2019  路  1Comment  路  Source: vuejs/vue-test-utils

Version

1.0.0-beta.29

Reproduction link

https://github.com/Kritten/vue-utils-error

Steps to reproduce

  1. Create a new project with the cli and select "jest" as unit test setup.
  2. Insert the statement [].flat(); in the generated example.spec.js.
  3. Run the tests.

Or simply use my repo and execute the tests.

What is expected?

The tests should be valid indicating jest could properly parse the inserted statement.

What is actually happening?

The tests fail with TypeError: [].flat is not a function


babel-jest was setup by the cli with '^. \\.jsx?$': 'babel-jest' in the jest.config.js.

My tests failed while jest was executing/testing a method in my application containing the Array.flat function.

Most helpful comment

Your Node version doesn't support Array.prototype.flat. Support was added in Node 11. Upgrading to 12 or polyfilling will solve your issue.

>All comments

Your Node version doesn't support Array.prototype.flat. Support was added in Node 11. Upgrading to 12 or polyfilling will solve your issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexanderstudte picture alexanderstudte  路  3Comments

vwxyutarooo picture vwxyutarooo  路  3Comments

38elements picture 38elements  路  3Comments

yoyoys picture yoyoys  路  3Comments

eddyerburgh picture eddyerburgh  路  4Comments