DLO
DLO

Reputation: 11

Error running TestCafe Docker Image on GitLab CI job . Trying to execute automated end-to-end tests on BrowserStack

We're trying to run testcafe end-to-end tests on BrowserStack triggered by a gitlab CI job. However, we see an error:

Error: spawn /home/user/.browserstack/BrowserStackLocal ENOENT

We are following Option 1 - Use TestCafe Docker Image https://devexpress.github.io/testcafe/documentation/continuous-integration/gitlab.html which adds an end-to-end testing job to our .gitlab-ci.yml file. We created a .base_e2e job base that is used in the e2e_dev job (see below)

We're also using the testcafe-browser-provider-browserstack npm dependency which allows our testcafe end-toend tests to be executed on BrowserStack, as mentioned here https://devexpress.github.io/testcafe/documentation/using-testcafe/common-concepts/browsers/browser-support.html#browsers-in-cloud-testing-services

This is a copy of the gitlab CI job error:

Running with gitlab-runner 11.7.0 (8bb608ff)
  on ec2-docker-runner 1c5ac6dc
Using Docker executor with image testcafe/testcafe ...
Pulling docker image testcafe/testcafe ...
Using docker image sha256:f4d0d6abb93c9 for testcafe/testcafe ...
Running on runner-1c5ac6dc-project-7261073-concurrent-0 via ip-10-250-5-194...
Fetching changes...
Removing build/
Removing coverage/
Removing node_modules/
Removing stats.json
HEAD is now at 8574401 Add space before script property
Checking out 8574401c as feature/e2e-on-pipeline...
Skipping Git submodules setup
Downloading artifacts for install_dependencies (150115951)...
Downloading artifacts from coordinator... ok        id=150115951 responseStatus=200 OK token=yMPpwZa1
Downloading artifacts for test (150115953)...
Downloading artifacts from coordinator... ok        id=150115953 responseStatus=200 OK token=pjsisESV
Downloading artifacts for build_dev (150115954)...
Downloading artifacts from coordinator... ok        id=150115954 responseStatus=200 OK token=6hsG8sxx
$ /opt/testcafe/docker/testcafe-docker.sh "browserstack:[email protected]:Windows 10" tests/e2e
Using locally installed version of TestCafe.
Error while trying to execute binary { Error: spawn /home/user/.browserstack/BrowserStackLocal ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
    at onErrorNT (internal/child_process.js:407:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn /home/user/.browserstack/BrowserStackLocal',
  path: '/home/user/.browserstack/BrowserStackLocal',
  spawnargs:
   [ '--daemon',
     'start',
     '--log-file',
     '/dev/null',
     '--key',
     'nyyp6nnWiL2S6Y7HkvrH',
     '--local-identifier',
     1548265103368,
     '--enable-logging-for-api' ],
  cmd:
   '/home/user/.browserstack/BrowserStackLocal --daemon start --log-file /dev/null --key nyyp6nnWiL2S6Y7HkvrH --local-identifier 1548265103368 --enable-logging-for-api' }

Full.gitlab-ci.yml file

image: node:8-alpine

stages:
- e2e

#############
# Job Bases #
#############
.base_e2e:
  stage: e2e
  image:
    name: testcafe/testcafe
    entrypoint: ["/bin/sh", "-c"]
  script:
    - /opt/testcafe/docker/testcafe-docker.sh "browserstack:[email protected]:Windows 10" tests/e2e

#############
# Jobs      #
#############
e2e_dev:
  extends: .base_e2e
  variables:
    ENVIRONMENT: dev
    TEST_E2E_APP_URL: https://$ENVIRONMENT.example.com
  only:
    - /^feature/.*$/
    - /^fix/.*$/
    - /^bug/.*$/
  when: manual

Additional information

When we run the following command yarn i.e yarn test:e2e_pipeline the end-to-end test is executed and a video recording of the automation uploaded to BrowserStack without a problem.

"scripts": {
    "test:e2e_all": "testcafe 'chrome,firefox' tests/e2e",
    "test:e2e_pipeline": "testcafe 'browserstack:[email protected]:Windows 10' tests/e2e"
  },

We have the following devDependencies inside our package.json

"devDependencies": {
    "testcafe": "^0.23.3",
    "testcafe-browser-provider-browserstack": "^1.7.0",
}

Upvotes: 1

Views: 909

Answers (1)

mlosev
mlosev

Reputation: 5227

You don't get to use BrowserStack Local with the official TestCafe docker image. TestCafe docker image is based on the alpine:edge image. BrowserStack Local doesn't support Alpine Linux and it's team doesn't have plans to support this operation system. Please see a discussion about it in this thread https://github.com/browserstack/browserstack-local-nodejs/issues/32. As a workaround, you can try to build your own docker image based on the operation system supported by BrowserStack Local.

Upvotes: 3

Related Questions