onPrepare: async function () {
console.log("onPrepare setup started...");
try {
// make a request to a reliable server
await axios.head("https://www.google.com/", { timeout:
10000 }); // Replace the URL with any reliable server
console.log("Internet is connected. cheers! 👍");
} catch (error) {
console.log("No internet connection or server is
unreachable 🙄");
process.exit(1); // Exit the process with an error code
}
// url to check accessibility
const urlsToCheck = [
"https://www.example.com",
"https://www.example.com",
"https://www.example.com",
"https://www.example.com",
];
for (const urlToCheck of urlsToCheck) {
try {
// Send a GET request to the URL
const response = await axios.get(urlToCheck);
// Check if the response status is in the
success range (e.g., 2xx)
if (response.status >= 200 && response.status < 300)
{
console.log(
`Url ${urlToCheck} is accessible. Status:
${response.status}` + "👍"
);
} else {
console.error(
`Url ${urlToCheck} is not accessible.
Status: ${response.status}` +
"🙄"
);
await browser.close();
process.exit(1); // Exit the process with an
error code
}
} catch (error) {
console.error(
`Error while checking accessibility of Url
${urlToCheck}:`,
error.message
);
await browser.close();
process.exit(1); // Exit the process with an
error code
}
}
//set maxInstances
console.log(
"Set chrome browser maxInstances: " +
CONSTANT.CONFIG_SETTING.MAXINSTANCES_VALUE +
"👍😀"
);
console.log("onPrepare setup completed..." + "👍👍👍😀");
},