An error log
In Jenkins CI, running a full Cypress full test case may cause the following error.
We detected that the Chromium Renderer process just crashed. This is the equivalent to seeing the 'sad face' when Chrome dies. This can happen for a number of different reasons: - You wrote an endless loop and you must fix your own code - There is a memory leak in Cypress (unlikely but possible) - You are running Docker (there is an easy fix for this: see link below) - You are running lots of tests on a memory intense application - You are running in a memory starved VM environment - There are problems with your GPU / GPU drivers - There are browser bugs in Chromium You can learn more including how to fix Docker here: https://on.cypress.io/renderer-process-crashedCopy the code
Cypress’s error message is very detailed, and several reasons for the error have been analyzed.
why
The reason for the above error, although most probability is due to Chromium abnormal exit. But we can also optimize from Cypress’s own specifications for writing use cases to reduce the probability of these problems.
The solution
1, when writing JS test cases, try not to have too many embedded context test cases, or a describe or context test case set, do not store too much IT. Try to limit the number of contexts to 3-4, and do not nest the set of context test cases within the context. Try to keep it steps within 10. The above scenario is not a fixed solution, but a pattern I summarized while writing Cypress test cases.
2. When starting the browser, add –disable-dev-shm-usage. This parameter uses local/ TMP instead of /dev/shm as the Chrome runtime space. Local/TMP has more space than /dev/shm, which makes it less likely that Cypress will run out of memory due to the number of test cases in a file.
Add the following code to module.exports in the Cypress /plugins/index.js file at the root of the Cypress project.
Module. exports = (on, exports) config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config on("before:browser:launch", (browser = {}, launchOptions) => { launchOptions.preferences.darkTheme = true if (browser.name === "chrome") { launchOptions.args.push("--disable-dev-shm-usage"); return launchOptions; }})}Copy the code
PS: The above code is tested only in Chrome, but not in Electron and Edge.