1

I have been using SFDX to automate Salesforce development for a little while now with Teamcity. SFDX doesn't always provide the best error messages but the documentation is usually very helpful. Well, or so I thought, until I started working with LTS. Here's the documentation to install LTS - https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/lightning_testing_install.htm. I have read the docs and followed the instructions but I cannot get LTS to work for me. I am able to create a scratch org, and install LTS but I am not able to run the tests.

sfdx force:lightning:test:run -a jasmineTests.app The following command allows you to run the sample Jasmin test. Whenever I try that command I get the following error: ERROR running force:lightning:test:run: Unable to connect to selenium. In the documentation, it doesn't specify the server requiring selenium.

Although the docs don't mention anything about selenium, I have tried downloading selenium-standalone-chrome. I tried running selenium/standalone-chrome as a docker container. But it doesn't work.

Links tried: https://github.com/forcedotcom/LightningTestingService/issues/46 https://github.com/forcedotcom/LightningTestingService/issues/46#issuecomment-457829523 https://github.com/forcedotcom/LightningTestingService/issues/46#issuecomment-347928851

Please help, I have tried almost everything.

mohifleur
  • 315
  • 5
  • 10
  • I got it to work! It turns out that the link I shared above was helpful after all ... LINK: https://github.com/forcedotcom/LightningTestingService/issues/46#issuecomment-457829523 I also had to add a variable ```SELENIUM_REMOTE_URL=http://selenium:4444/wd/hub/``` and create a docker-compose.yml to start up selenium/standalone-chrome:latest ```version: "3" services: selenium: image: selenium/standalone-chrome:latest ports: - "4444:4444"``` – mohifleur Jul 19 '19 at 19:57

2 Answers2

0

You do need Selenium and its associated dependencies (browsers, etc) available in your container environment. Unfortunately, I don't believe any official images or dependency lists are available (and of course, the specific package names will vary by distro). I can tell you that I've had success using the circleci/openjdk:latest-node-browsers image to execute LTS tests in continuous integration.

I have a repository of Salesforce CI examples on GitHub, one of which is a working demo of LTS testing. In abbreviated form, it goes like this.

version: 2
jobs:
  build:
    docker:
        - image: circleci/openjdk:latest-node-browsers
    steps:
        - checkout
        - restore_cache:
            keys:
                - sfdx
        - run:
            name: Install Salesforce DX
            command: |
                if [ ! -d node_modules/sfdx-cli ]; then
                    export SFDX_AUTOUPDATE_DISABLE=true
                    export SFDX_USE_GENERIC_UNIX_KEYCHAIN=true
                    export SFDX_DOMAIN_RETRY=300
                    npm install sfdx-cli
                    node_modules/sfdx-cli/bin/run --version
                    node_modules/sfdx-cli/bin/run plugins --core
                fi
        - save_cache:
            key: sfdx
            paths: 
                - node_modules
        - run: 
            name: Create Scratch Org
            command: |
                openssl aes-256-cbc -k $KEY -in assets/server.key.enc -out assets/server.key -d -md md5
                node_modules/sfdx-cli/bin/run force:auth:jwt:grant --clientid $CONSUMERKEY --jwtkeyfile assets/server.key --username $USERNAME --setdefaultdevhubusername -a DevHub
                node_modules/sfdx-cli/bin/run force:org:create -v DevHub -s -f config/project-scratch-def.json -a scratch
        - run:
            name: Remove Server Key
            when: always
            command: |
                rm assets/server.key
        - run:
            name: Install Lightning Testing Service
            command: |
                node_modules/sfdx-cli/bin/run force:lightning:test:install -t jasmine
        - run: 
            name: Push Source
            command: |
                node_modules/sfdx-cli/bin/run force:source:push -u scratch
        - run:
            name: Run Lightning Tests
            command: | 
                mkdir ~/tests/lightning
                node_modules/sfdx-cli/bin/run force:lightning:test:run -d ~/tests/lightning -r human -a lightningTests.app -o
David Reed
  • 2,522
  • 2
  • 16
  • 16
  • Thank you for replying David. In my previous Docker image I already had a Chrome driver. Regardless, I tried to create an image just like the one from ```circleci/openjdk:latest-node-browsers``` however, I'm still getting the ```Unable to connect to selenium``` error. I'm thinking that my LTS config JSON isn't set up properly. How do you have yout LTS config set up? – mohifleur May 24 '19 at 18:20
  • @M.Firmino Do you mean the driver `.app` for the LTS suite? – David Reed May 24 '19 at 18:41
  • No, I mean the config file...they have an example in the LTS repo. ```https://github.com/forcedotcom/LightningTestingService/blob/master/config/lts-config.json```...I thought this was required for the command to execute. I am using the exact configurations as this file and I get the error -- ```ERROR running force:lightning:test:run: v1.indexOf is not a function``` – mohifleur May 24 '19 at 19:13
  • @M.Firmino I don't have one at all - it's possible that was added after I stopped working much with LTS. I'm sorry this hasn't been very helpful! When I get a minute I'll go try my builds again and see if they still work. – David Reed May 24 '19 at 19:16
0

Updating the answer in case anyone ever runs into this issue... I got it to work! It turns out that the link I shared above was helpful after all LINK: https://github.com/forcedotcom/LightningTestingService/issues/46

  1. I had to add a variable SELENIUM_REMOTE_URL=http://selenium:4444/wd/hub/ to TeamCity
  2. And create a docker-compose.yml to start up selenium/standalone-chrome:latest
version: "3"
services:
  selenium:
    image: selenium/standalone-chrome:latest
    ports:
      - "4444:4444"
mohifleur
  • 315
  • 5
  • 10