machine:
  environment:
    YARN_VERSION: 0.18.1
    PATH: "${PATH}:${HOME}/.yarn/bin"
  node:
    version: "stable"
dependencies:
  pre:
    - |
      if [[ ! -e ~/.yarn/bin/yarn || $(yarn --version) != "${YARN_VERSION}" ]]; then
        echo "Download and install Yarn."
        curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION
      else
        echo "The correct version of Yarn is already installed."
      fi
    - npm install -g bower
    - sudo apt-get update; sudo apt-get install -y --only-upgrade google-chrome-stable
  override:
    - yarn install
    - bower install
  cache_directories:
    - ~/.yarn
    - ~/.yarn-cache
test:
  override:
    - yarn test

machine:
  environment:
    PATH: "${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"
  node:
    version: "stable"
dependencies:
  pre:
    - npm install -g bower
    - sudo apt-get update; sudo apt-get install -y --only-upgrade google-chrome-stable
  override:
    - yarn
    - bower install
  cache_directories:
    - ~/.cache/yarn
test:
  override:
    - yarn test

Use preinstalled Yarn on CircleCI
Use preinstalled Yarn on CircleCI
