Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run tests with React Native 0.56 #20052

Closed
victorlevasseur opened this issue Jul 5, 2018 · 1 comment
Closed

Can't run tests with React Native 0.56 #20052

victorlevasseur opened this issue Jul 5, 2018 · 1 comment
Labels
Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot.

Comments

@victorlevasseur
Copy link

victorlevasseur commented Jul 5, 2018

Environment

React Native Environment Info:
System:
OS: Linux 4.15 Ubuntu 18.04 LTS (Bionic Beaver)
CPU: x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Memory: 3.08 GB / 15.39 GB
Shell: 4.4.19 - /bin/bash
Binaries:
Node: 8.10.0 - /usr/bin/node
Yarn: 1.5.1 - /usr/local/bin/yarn
npm: 6.1.0 - /usr/local/bin/npm
npmPackages:
react: 16.4.1 => 16.4.1
react-native: 0.56.0 => 0.56.0
npmGlobalPackages:
react-native-cli: 2.0.1

Description

When launching the tests with npm test, I get the following output :

JsProject@0.0.1 test /home/victor/Wedoogift/JsProject
> jest

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

    SyntaxError: /home/victor/Wedoogift/JsProject/node_modules/react-native/Libraries/Utilities/Platform.ios.js: Unexpected token, expected "{" (35:17)

      33 |     return constants ? constants.interfaceIdiom === 'tv' : false;
      34 |   },
    > 35 |   get isTesting(): boolean {
         |                  ^
      36 |     const constants = NativeModules.PlatformConstants;
      37 |     return constants && constants.isTesting;
      38 |   },

      at Parser.raise (node_modules/@babel/core/node_modules/babylon/lib/index.js:776:15)
      at Parser.unexpected (node_modules/@babel/core/node_modules/babylon/lib/index.js:2079:16)
      at Parser.expect (node_modules/@babel/core/node_modules/babylon/lib/index.js:2067:28)
      at Parser.parseBlock (node_modules/@babel/core/node_modules/babylon/lib/index.js:4488:10)
      at Parser.parseFunctionBody (node_modules/@babel/core/node_modules/babylon/lib/index.js:3754:24)
      at Parser.parseFunctionBodyAndFinish (node_modules/@babel/core/node_modules/babylon/lib/index.js:3734:10)
      at Parser.parseMethod (node_modules/@babel/core/node_modules/babylon/lib/index.js:3686:10)
      at Parser.parseObjectMethod (node_modules/@babel/core/node_modules/babylon/lib/index.js:3609:12)
      at Parser.parseObjPropValue (node_modules/@babel/core/node_modules/babylon/lib/index.js:3644:21)
      at Parser.parseObj (node_modules/@babel/core/node_modules/babylon/lib/index.js:3555:12)

Test Suites: 1 failed, 1 total
Tests:       0 total

Reproducible Demo

It just consists of the default app obtained with "react-native init" and with an "App.test.js" file containing the following code :

import * as React from 'react';

import renderer from 'react-test-renderer';
import App from "./App";

test('renders correctly', () => {
  const tree = renderer.create(<App />).toJSON();
  expect(tree).toMatchSnapshot();
});

Note: I had to add babel-core^7.0.0-beta3 to be able to start the tests.

@react-native-bot react-native-bot added the Platform: Linux Building on Linux. label Jul 5, 2018
@kelset
Copy link
Contributor

kelset commented Jul 5, 2018

Duplicate of #19859

@kelset kelset marked this as a duplicate of #19859 Jul 5, 2018
@kelset kelset closed this as completed Jul 5, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Jul 18, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants