We are currently attempting to execute end-to-end tests using testcafe on BrowserStack triggered by a gitlab CI job. Unfortunately, an error keeps appearing:
Error: spawn /home/user/.browserstack/BrowserStackLocal ENOENT
Our approach involves implementing Option 1 - Utilizing the TestCafe Docker Image as outlined at , which incorporates an end-to-end testing job into our .gitlab-ci.yml
file. In this process, we have set up a job base named .base_e2e
, utilized in the e2e_dev
job (refer to below)
Additionally, we rely on the
testcafe-browser-provider-browserstack
npm dependency to enable the execution of testcafe end-to-end tests on BrowserStack, mentioned here:
Here is a snippet showing the gitlab CI job error encountered:
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
$ /opt/testcafe/docker/testcafe-docker.sh "browserstack:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="87c4eff5e8eae2c7b2b4a9b7">[email protected]</a>:Windows 10" tests/e2e
....
The complete.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:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b9fad1cbd6d4dcf98c8a9789">[email protected]</a>: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 details
When running the command yarn i.e yarn test:e2e_pipeline
, the end-to-end test gets executed flawlessly and a video recording of the automation uploads to BrowserStack without issues.
"scripts": {
"test:e2e_all": "testcafe 'chrome,firefox' tests/e2e",
"test:e2e_pipeline": "testcafe 'browserstack:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2d6e455f4240486d181e031d">[email protected]</a>:Windows 10' tests/e2e"
},
Our package.json
contains the following devDependencies
"devDependencies": {
"testcafe": "^0.23.3",
"testcafe-browser-provider-browserstack": "^1.7.0",
}