Hi guys,
I had Electron 1.7.5 running the tests with the codeception/codecepjs 1.0.1 image and chromedriver 2.38.3 normal but when I updated to electron 3.1.13 it started to break the tests.
I updated the codepcetion image to codeception/codecepjs 2.0.4 and started the chromedriver for 2.40.0 because it is compatible with electron chrominium but now I keep getting error in chromedriver:
Cannot find module ‘chromedriver’
I’ve tried to import in all ways but without success, follow the codes used. Help-me please
Dockerfile:
FROM codeception/codeceptjs:2.0.4
RUN npm install chromedriver@2.40.0 node-fetch@2.6.0 chai@4.2.0 --save-dev
codecept.conf.js:
exports.config = {
tests: './features/*.feature.js',
timeout: 10000,
output: './reports',
helpers: {
WebDriver: {
smartWait: 10000,
waitForTimeout: 10000,
browser: 'chrome',
url: 'localhost',
host: 'localhost',
port: 9515,
uniqueScreenshotNames: true,
manualStart: true,
desiredCapabilities: {
browserName: 'chrome',
chromeOptions: {
binary: '/gateway/node_modules/.bin/electron',
args: [
'app=/gateway/',
'--whitelisted-ips',
'--headless',
'--no-sandbox',
'--disable-extensions'
]
}
},
timeouts: {
script: 10000,
pageLoad: 10000,
implicit: 10000
}
},
Simulator: {
require: "./simulator.js"
},
App: {
require: "./app.js"
}
},
include: {
I: './actor.js'
},
bootstrap: './bootstrap.js',
teardown: './teardown.js',
mocha: {},
name: 'rilix-gateway'
};
Bootstrap(Where i used chromedriver):
const fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
const chromedriver = require('chromedriver');
const args = [
'--url-base=wd/hub',
'--port=9515'
];
module.exports = function (done) {
chromedriver.start(args);
(new Promise((resolve) => waitServer('http://api:9000', resolve)))
.then(() => done());
};
function waitServer(url, done) {
fetch(url)
.then(() => done())
.catch(() => setTimeout(() => waitServer(url, done), 1000));
}
App.js (startbrowser):
class App extends codecept_helper {
constructor() {
super();
this.openTheApp = this.openTheApp.bind(this);
}
openTheApp() {
return this.helpers["WebDriver"]._startBrowser();
}
}
module.exports = App;
When I try run the tests(With Docker) i received this error:
Cannot find module 'chromedriver'
Error:
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/tests/bootstrap.js:2:22)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)