question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tests are failing after upgrade to 0.8.1

See original GitHub issue

If you are reporting a bug, please fill in below. Otherwise feel free to remove this template entirely.

Can you reproduce the problem with latest npm?

I have Yarn installed, so CRA used latest yarn@0.18.0 to setup.

Description

My test command fails with the following error

 FAIL  src/App.test.js
  ● Test suite failed to run

    TypeError: /home/bserdiuk/coding/test/src/App.test.js: Cannot read property 'length' of null
      
      at Buffer._append (node_modules/babel-generator/lib/buffer.js:83:25)
      at Buffer.append (node_modules/babel-generator/lib/buffer.js:55:10)
      at Generator._append (node_modules/babel-generator/lib/printer.js:206:52)
      at Generator.word (node_modules/babel-generator/lib/printer.js:131:10)
      at Generator.Identifier (node_modules/babel-generator/lib/generators/types.js:38:8)
      at node_modules/babel-generator/lib/printer.js:298:23
      at Buffer.withSource (node_modules/babel-generator/lib/buffer.js:142:28)
      at Generator.withSource (node_modules/babel-generator/lib/printer.js:189:15)
      at Generator.print (node_modules/babel-generator/lib/printer.js:297:10)
      at Generator.VariableDeclarator (node_modules/babel-generator/lib/generators/statements.js:309:8)

It worked fine with version 0.7.0, today I tried to upgrade to latest 0.8.1 and got the error above. I have generated new test application with latest create-react-app and react-scripts and could find a minimal example to reproduce.

Add the following test in your test files, then run npm test.

it('async test', async () => {
    const {result} = doSometing();
});

Basically, destructuring assignment doesn’t work in async function with Jest. Babel Repl transpiles this code fine. Also it works fine if I will put this code into source. Problem appears only in testing code.

Expected behavior

I expect that it works as it was before in 0.7.0

Actual behavior

Tests are not run, error appears before any test starts.

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected):
npm ls react-scripts
test@0.1.0 /home/bserdiuk/coding/test
└── react-scripts@0.8.1 
  1. node -v:
v6.9.1
  1. npm -v:
4.0.3

Then, specify:

  1. Operating system: Ubuntu 16.04.1 LTS
  2. Browser and version: not applicable

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:44 (31 by maintainers)

github_iconTop GitHub Comments

2reactions
gaearoncommented, Dec 6, 2016

I can confirm

var addIndex = function addIndex({ index, ...routes } = {}, base) {
};

is not working.

    /Users/gaearon/p/create-react-app/packages/react-scripts/template/src/App.test.js:27
    var addIndex = function addIndex({ index, ...routes } = {}, base) {
                                              ^^^
    SyntaxError: Unexpected token ...
      
      at transformAndBuildScript (../node_modules/jest-runtime/build/transform.js:316:10)
      at process._tickCallback (../../../internal/process/next_tick.js:103:7)
2reactions
gaearoncommented, Dec 6, 2016

I can confirm that commenting out regenerator fixes

it('async test', async () => {
    const {result} = await doSometing(); // Note: MUST have await to reproduce
});

for me.

Before commenting it I was seeing

  /Users/gaearon/p/create-react-app/packages/react-scripts/template/src/App.test.js: Expected type "Expression" with option {}

but not anymore.

One thing to keep in mind is there’s some Jest caching going on so you need to change something in test file every time you try after changing preset.

Read more comments on GitHub >

github_iconTop Results From Across the Web

kafkaserver shutdown hangs indefinitely on unit tests (kafka ...
We are recently upgrading from kafka 0.8.1.1 to 0.8.2.0. Our integrating tests are failing as the tests hang on kafkaServer.shutdown() ...
Read more >
Upgrading Ember - Issues with Tests - Questions
So I took on the task of upgrading our Ember app from 2.16 to 3.26. The application runs fine locally. Got through the...
Read more >
Package Manager Issues (Pop!_OS) - System76 Support
If your system complains about a failed upgrade, package manager conflicts, broken upgrades, or other package-related issues, there are ...
Read more >
Upgrading your build from Gradle 4.x to 5.0
This chapter provides the information you need to migrate your older Gradle 4.x builds to Gradle 5.0. In most cases, you will need...
Read more >
Upgrading your Helm chart
User servers may need be stopped prior to the upgrade, or restarted after it. ... we recommend you test the upgrade out on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found