Tests are failing after upgrade to 0.8.1
See original GitHub issueIf 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:
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
node -v
:
v6.9.1
npm -v
:
4.0.3
Then, specify:
- Operating system: Ubuntu 16.04.1 LTS
- Browser and version: not applicable
Issue Analytics
- State:
- Created 7 years ago
- Comments:44 (31 by maintainers)
I can confirm
is not working.
I can confirm that commenting out regenerator fixes
for me.
Before commenting it I was seeing
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.