Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #3055
Closed
Open
Issue created Sep 03, 2017 by Administrator@rootContributor

Strange SyntaxError when running tests, probably transpiler bug

Created by: MOZGIII

Is this a bug report?

Yes.

Can you also reproduce the problem with npm 4.x?

I'm using yarn. Tried npm 4 though. Same.

Which terms did you search for in User Guide?

Did a quick look-through. I searched google for SyntaxError: Unexpected identifier, did not found the solution.

Environment

  1. node -v: v8.4.0
  2. npm -v: 4.6.1 (was 5.x before)
  3. yarn --version: 0.27.5
  4. npm ls react-scripts: react-scripts@1.0.13 (also checked at react-scripts@1.0.11 with yarn)

Switching yarn/npm seems to have no effect.

Then, specify:

  1. Operating system: Ubuntu xenial
  2. Browser and version (if relevant): -

Steps to Reproduce

The issue is really strange.

  1. Create a new project, cd into it.

  2. yarn add flow-bin (flow-bin@0.53.1), then yarn flow init.

  3. Create two files:

src/dummy.js

// @flow
export const dummmmmmmmmmmmmmmmmmy = async (
  response: Response
): Promise<Response> => {
  if (!response.ok) {
    const text = await response.text();
    throw Error(text);
  }
  return response;
};

src/dummy.test.js

// @flow
import { dummmmmmmmmmmmmmmmmmy } from "./dummy";

it("should run", async () => {
  await dummmmmmmmmmmmmmmmmmy(fetch("https://google.com"));
  expect(true);
});
  1. yarn test

Expected Behavior

Tests run successfully or at least fail with some sane error.

Actual Behavior

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

    .../issue/src/dummy.js:6
        const text = await response.text();
                           ^^^^^^^^
    
    SyntaxError: Unexpected identifier
      
      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
      at Object.<anonymous> (src/dummy.test.js:2:14)

Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.517s, estimated 1s
Ran all test suites related to changed files.

Watch Usage
 › Press p to filter by a filename regex pattern.
 › Press t to filter by a test name regex pattern.
 › Press q to quit watch mode.
 › Press Enter to trigger a test run.
Done in 7.55s.

image

Seems to be related to the way code is formatted. 😮

Reproducible Demo

https://github.com/MOZGIII/js-bug-demo-1

Just cone it and yarn install. Run CI=true yarn test. Pretend you're CI to run all tests.

Assignee
Assign to
Time tracking