appiumcalabashxamarin.uitestmobile-centervisual-studio-app-center

Mobile Center CLI, "SyntaxError: Unexpected token" When Uploading Tests


How to solve this error that appears when using the Mobile Center Command-Line Interface to upload tests to Mobile Center?

SyntaxError: Unexpected token ...

enter image description here


Solution

  • This error appears because you have an earlier version of Node installed on your machine.

    The Mobile Center CLI, mobile-center, requires the latest version of Node.

    Here's the steps I used to fix this error:

    1. Install HomeBrew
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    1. Update to the latest version of Node by entering these commands into your Terminal

      sudo brew uninstall node
      brew update
      brew upgrade
      brew cleanup
      brew install node
      sudo chown -R $(whoami) /usr/local
      brew link --overwrite node
      sudo brew postinstall node
    2. Uninstall/Reinstall mobile-center-cli to ensure you have the most recent version of the Mobile Center CLI by entering these commands into your terminal

      npm uninstall -g mobile-center-cli
      npm install -g mobile-center-cli
    3. Log into Mobile Center via CLI by entering this command into your terminal*

      mobile-center login
    4. You are now able to upload your UITests to Mobile Center using the CLI

      mobile-center test run uitest --app [appname] --devices [deviceID] --app-path [LocationOfYourAppOnYour]  --test-series "master" --locale "en_US" --assembly-dir [FolderContainingUITestDLL]

    *If you have not yet created a password for your Mobile Center login, navigate to mobile.azure.com, logout of your account if you are currently logged in, then click "Forgot Password?" to create a password for your Mobile Center Account.

    Mobile Center Forgot Password