Cypress error "The automation client disconnected. Cannot continue running tests." when running in Docker - reactjs

I'm getting the following error when running a Cypress test suite in a Docker container:
The automation client disconnected. Cannot continue running tests.
Using this command, running in a cypress/browsers:node12.6.0-chrome75 container:
cypress run --browser=chrome

This seems to occur when running out of shm space.
By default, Docker creates a container with a /dev/shm shared memory space of 64MB.
This is typically too small for Chrome and could cause Chrome to crash.
I have found two options to resolve this:
Disable usage of /dev/shm:
// cypress/plugins/index.js
module.exports = (on, config) => {
// ref: https://docs.cypress.io/api/plugins/browser-launch-api.html#Usage
on('before:browser:launch', (browser = {}, args) => {
if (browser.name === 'chrome') {
args.push('--disable-dev-shm-usage')
return args
}
return args
})
}
Increase the size of /dev/shm in the container:
Run the container with docker run --shm-size=1gb (or whatever size you want)

Related

After test:report:chrome Report generation done, Terminal not closing the instance, it keeps running

I am using protector, selenium for running the UI automation.
For chrome driver I am using webdriver-manager for testing the UI Automation. It run successfully, browser also close but it keeps running the terminal instance can anyone help me on this?
config.directConnect = false;
config.seleniumAddress = "http://127.0.0.1:4444/wd/hub";
config.capabilities.chromeOptions = chromeOptions = {
args: [
"--no-sandbox",
"--disable-infobars",
"--disable-dev-shm-usage",
"--disable-extensions",
"--log-level=3",
"--disable-gpu",
"--start-maximized"
].concat(isCI ? ["--headless"] : []), // run in headless mode on the CI server
prefs: {
"download.default_directory": downloadDir
}
};
config.serenity = {
outputDirectory: `${process.cwd()}/test_reports_chrome`,
runner: "cucumber",
crew: [
ArtifactArchiver.storingArtifactsAt("./test_reports_chrome"),
ConsoleReporter.forDarkTerminals(),
Photographer.whoWill(TakePhotosOfInteractions), // or Photographer.whoWill(TakePhotosOfFailures),
new SerenityBDDReporter()
]
you should add -r for script in package.json
"test:chrome": "npm-run-all -p -r webdriver:chrome execute:chrome",
-p = Run commands in parallel.
-r = Kill all commands when one of them finishes with zero.
Running npm run test:chrome will start Selenium driver, start http server (to serve you files) and run protractor tests. Once all tests are finished, it will close the http server and the selenium driver.

How can I run React in Development mode with .NetCore in IIS?

I've used the Visual Studio template for .NetCore/React web app. By default, it runs in Development mode using IIS Express. However, if I set up a site in IIS, and a launch profile, I get an error in the browser:
AggregateException: One or more errors occurred. (One or more errors
occurred. (The NPM script 'start' exited without indicating that the
create-react-app server was listening for requests. The error output
was: Error: EPERM: operation not permitted, mkdir
'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'
My launchSettings.json has the following for the IIS profile:
"IIS": {
"commandName": "IIS",
"launchBrowser": true,
"launchUrl": "http://localhost",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
From the error, it looks like it may be a permission issue that I need to have the IIS app pool running under, but I can't find any documentation that tells me anything about that.
What am I missing? Again, this is an otherwise unmodified project from the template. The Startup.cs is running React as would be expected with:
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{ spa.UseReactDevelopmentServer(npmScript: "start"); }
});
According to your description, I suggest you could firstly modify the IIS default application pool's identity to make sure it has the permission to run npm.
I suggest you could follow below steps:
1.Open the IIS management console, locate the application pool,find the default application pool and click the advanced setting.
Find the identity setting and modify the build-in account to localsystem
Then I suggest you could add the npm path in the system environment.
Go to Control Panel\System and Security\System and find advanced system settings
2.Click environment variable
3.Find the path inside the system variable and add the npm path as below:
C:\Users\{username}\AppData\Roaming\npm

programmatically or CLI to stop webpack-dev-server

How to stop webpack-dev-server programatically of a CLI command against the port ?
Ctrl-C etc are good for manually stopping the server. We are basically killing it.
Is there a API that the server exposes to issue a STOP command or something ?
Just came across this. Hopefully it's still relevant^^
According to documentation, the server can be opened and closed via node api as follows:
// create instance
const server = new WebpackDevServer(webpack(config), { });
// start
server.listen(8000, "localhost", err => {
console.log("server started")
})
// close/stop
server.close(() => {
console.log("server closed")
})
Docs: https://github.com/webpack/docs/wiki/webpack-dev-server

Error: No network specified. Cannot determine current network

Truffle react-box not working as expected with default setup (with ganache and metamask)
I download and run ganache then I followed the first 4 steps in the readme and when I get to truffle migrate it says 'Error: No network specified. Cannot determine current network.' in the console.
On OSX 10.13.3 I went into the truffle.js file in the root folder and changed it to
module.exports = {
networks: {
development: {
host: '127.0.0.1',
port: 7545,
network_id: '*'
}
}
};
npm run start in the terminal and everything works fine. Make sure you have ganache running in the background though.
Also, make sure that the rpc server in ganache matches the host and port in the truffle file you just updated.

protractor with any headless browser?

I am using protractor and it works when I specify chrome as the browsertype. I am looking for a headless browser sample code, I have looked for phantomJs but I could not run any of them. Is there a working sample available of another headless browser?
No other headless browser out there besides PhantomJS while the latter is a dead-end with Protractor.
You can try docker-selenium or, if you don't like Docker you can do it yourself with ubuntu-headless sample. Both solutions provide Chrome & Firefox by using Xvfb even though there is no real DISPLAY.
UPDATE 2 Seems to be possible to run Xvfb in OSX: http://xquartz.macosforge.org/landing/
UPDATE 1 Mac OSX selenium headless solution:
Enable multi-user remote desktop access to OSX machine
So can test selenium headless on mac. Not headless really but as another user so it doesn't interfere with your current user display.
To do this you need kickstart: http://support.apple.com/en-us/HT201710
Begin using the kickstart utility
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -restart -agent
Activate Remote Desktop Sharing, enable access privileges for all users and restart ARD Agent:
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -restart -agent -privs -all
Apple Remote Desktop 3.2 or later only
Allow access for all users and give all users full access
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -allowAccessFor -allUsers -privs -all
Kickstart help command
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -help
PhantomJS is a dead-end with Protractor on certain websites when there is a div, which is fixed and always visible (due to https://github.com/ariya/phantomjs/issues/11637). Otherwise you can make it work:
using phantomjs:~1.9.0 and protractor: ~1.8.0
inside protractor config file register function:
onPrepare : function() {
var minWindowWidth = 1024,
minWindowHeight = 768,
browserName,
platform,
window = browser.manage().window();
browser.getCapabilities().then(function (capabilities) {
browserName = capabilities.caps_.browserName;
platform = capabilities.caps_.platform;
}).then(function getCurrentWindowSize() {
return window.getSize();
}).then(function setWindowSize(dimensions) {
var windowWidth = Math.max(dimensions.width, minWindowWidth),
windowHeight = Math.max(dimensions.height, minWindowHeight);
return window.setSize(windowWidth, windowHeight);
}).then(function getUpdatedWindowSize() {
return window.getSize();
}).then(function showWindowSize(dimensions) {
console.log('Browser:', browserName, 'on', platform, 'at', dimensions.width + 'x' + dimensions.height);
console.log("Running e2e tests...");
});
},

Resources