selenium-side-runner - Validation Error: Test environment jest-environment-selenium cannot be found

551 Views Asked by At

I run my selenium tests from shell, everything works as it should!

$ selenium-side-runner --server http://chromedriver:4444/wd/hub --capabilities "browserName=chrome" /app/tests/proxy.lucky_app.side
info:    Running /app/tests/proxy.lucky_app.side
 PASS  ./DefaultSuite.test.js
  Default Suite
    ✓ test frontend (1282ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        3.329s
Ran all test suites.

However, if I execute the same command from a shell script test.sh, I get the below error. What causes it and how can I fix it ?

tests.sh

#!/bin/bash

selenium-side-runner --server http://chromedriver:4444/wd/hub --capabilities "browserName=chrome" /app/tests/proxy.lucky_app.side

Error

$ /app/scripts/test.sh
info:    Running /app/tests/proxy.lucky_app.side
● Validation Error:

  Test environment jest-environment-selenium cannot be found. Make sure the testEnvironment configuration option points to an existing node module.

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html
1

There are 1 best solutions below

0
On

Context

The reason for my error and this flaky behavior was explicit reference to the latest release of selenium-webdriver - at the moment of writing this answer, it's [email protected]

package.json - error

    "dependencies": {
        "fs": "^0.0.1-security",
        "jest-environment-selenium": "^2.1.2",
        "selenium-side-runner": "^3.5.4",
        "selenium": "^2.20.0",
        "selenium-webdriver": "^4.1.1"
    }
}

Solution

Fix, was to remove selenium-webdriver from package.json.

package.json - no errors

    "dependencies": {
        "fs": "^0.0.1-security",
        "jest-environment-selenium": "^2.1.2",
        "selenium-side-runner": "^3.5.4",
        "selenium": "^2.20.0"
    }
}