The Gitlab CI does not find the chromedriver installation (even though it’s installed in the node_modules)
We followed this guide to start with end-2-end testing on Gitlab using WebdriverIO: End-to-end testing with GitLab CI/CD and WebdriverIO | GitLab
In our Pipeline Logs we can see the following Error:
Running with gitlab-runner 13.11.0-rc1 (286f7013)
on docker-auto-scale fa6cab46
feature flags: FF_GITLAB_REGISTRY_HELPER_IMAGE:true, FF_SKIP_DOCKER_MACHINE_PROVISION_ON_CREATION_FAILURE:true
Preparing the "docker+machine" executor
00:45
Using Docker executor with image node:alpine ...
Starting service selenium/standalone-chrome:latest ...
Pulling docker image selenium/standalone-chrome:latest ...
Using docker image sha256:3e0cfbb817a8452654f15dd45b828cf2d40bcc9909fc6604bfca24245485e834 for selenium/standalone-chrome:latest with digest selenium/standalone-chrome@sha256:4a590fc95d67a8eb13464799583991daa6a8548c9a9e2e7f234a92c9c4fa8f29 ...
Waiting for services to be up and running...
Pulling docker image node:alpine ...
Using docker image sha256:cf39b70292b88534886751605dc7a516b0aa67abafa6f4dfe99f6d08dfb4966d for node:alpine with digest node@sha256:fabc6adac6dba5e150130e10acfc11a81447be93f4bf384076abdb63dbd34033 ...
Preparing environment
00:02
Running on runner-fa6cab46-project-13022679-concurrent-0 via runner-fa6cab46-srm-1619702482-d2336011...
Getting source from Git repository
00:03
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/parkhere/pcs/frontend/corporate-app/.git/
Created fresh repository.
Checking out 924e2b34 as PCS_1537-spike...
Skipping Git submodules setup
Restoring cache
00:01
Checking cache for pcs-1537-spike-1...
Downloading cache.zip from https://storage.googleapis.com/gitlab-com-runners-cache/project/13022679/pcs-1537-spike-1
Successfully extracted cache
Executing "step_script" stage of the job script
03:15
Using docker image sha256:cf39b70292b88534886751605dc7a516b0aa67abafa6f4dfe99f6d08dfb4966d for node:alpine with digest node@sha256:fabc6adac6dba5e150130e10acfc11a81447be93f4bf384076abdb63dbd34033 ...
$ yarn install
yarn install v1.22.5
[1/4] Resolving packages...
[2/4] Fetching packages...
warning mini-css-extract-plugin@0.5.0: Invalid bin field for "mini-css-extract-plugin".
info fsevents@1.2.13: The platform "linux" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.3.2: The platform "linux" is incompatible with this module.
info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > @testing-library/jest-native@3.4.3" has unmet peer dependency "react-test-renderer@*".
warning "aws-amplify > @aws-amplify/api@2.2.1" has incorrect peer dependency "@aws-amplify/pubsub@^1.2.4".
warning "expo > @unimodules/react-native-adapter@5.7.0" has incorrect peer dependency "react-native-web@~0.13.7".
warning " > expo-localization@9.1.0" has unmet peer dependency "@unimodules/core@~5.1.2".
warning " > react-native-qrcode-svg@6.0.6" has incorrect peer dependency "react-native-svg@^9.6.4".
warning " > react-native-web@0.15.0" has incorrect peer dependency "react@>=17.0.1".
warning " > react-native-web@0.15.0" has incorrect peer dependency "react-dom@>=17.0.1".
warning " > @testing-library/react-native@7.1.0" has unmet peer dependency "react-test-renderer@>=16.0.0".
warning " > jest-expo@40.0.2" has incorrect peer dependency "react-native-web@~0.13.7".
warning " > react-hooks-testing-library@0.6.0" has unmet peer dependency "react-test-renderer@^16.8.0".
warning "react-hooks-testing-library > @testing-library/react-hooks@1.0.4" has unmet peer dependency "react-test-renderer@>=16.8.0".
warning " > redux-devtools-extension@2.13.5" has unmet peer dependency "redux@^3.1.0 || ^4.0.0".
[4/4] Building fresh packages...
Done in 188.58s.
$ ls /builds/parkhere/pcs/frontend/corporate-app/node_modules/chromedriver/lib/chromedriver
chromedriver
chromedriver_linux64.zip
$ npm run test:wdio
> test:wdio
> npx wdio run ./wdio.conf.ts --host=selenium__standalone-chrome
Execution of 1 spec files started at 2021-04-29T13:26:27.511Z
2021-04-29T13:26:27.514Z DEBUG @wdio/utils:initialiseServices: initialise service "chromedriver" as NPM package
2021-04-29T13:26:27.585Z INFO @wdio/cli:launcher: Run onPrepare hook
Error: spawn /builds/parkhere/pcs/frontend/corporate-app/node_modules/chromedriver/lib/chromedriver/chromedriver ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
at onErrorNT (node:internal/child_process:480:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
Probably helpful to post our config files (wdio.conf.ts):
export const config: WebdriverIO.Config = {
// https://webdriver.io/docs/options
specs: ['./test/specs/**/*.ts'],
exclude: [],
maxInstances: 10,
capabilities: [
{
maxInstances: 5,
browserName: 'chrome',
acceptInsecureCerts: true,
},
],
services: ['chromedriver'],
logLevel: 'debug',
bail: 0,
baseUrl: 'http://localhost',
port: 4444,
path: '/wd/hub',
waitforTimeout: 10000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
framework: 'jasmine',
reporters: ['spec'],
jasmineOpts: {
defaultTimeoutInterval: 60000,
expectationResultHandler: function (passed, assertion) {
// do something
if (passed) {
return;
}
browser.saveScreenshot(
`./assertions_error/${assertion.error.message}.png`
);
},
},
};
Also the .gitlab-ci.yml (part):
e2e:chrome:
stage: test:wdio
services:
- selenium/standalone-chrome:latest
script:
- ls /builds/parkhere/pcs/frontend/corporate-app/node_modules/chromedriver/lib/chromedriver
- npm run test:wdio
only:
- PCS_1537-spike
The package.json script is: "test:wdio": "npx wdio run ./wdio.conf.ts --host=selenium__standalone-chrome",
We spend the whole day trying to debug this error, but it looks like we cannot find the mistake on our side. We also tried the Gitlab Runner locally, and this one works!
Thank you so much for your help!