Skip to content

Commit d8217f4

Browse files
committed
Automatically set necessary arguments to run in AWS lambda
1 parent 1357778 commit d8217f4

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/CommandWrapper.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ export default class CommandWrapper {
105105
CYPRESS_LOCAL_HISTORY: this.config.isLocalHistoryEnabled() ? '1' : '0',
106106
TZ: this.getTimezone(),
107107
...npmRunPath.env({ env: process.env }),
108+
// if running in AWS lambda, set the necessary args so that cypress can start
109+
...(process.env.AWS_LAMBDA === '1'
110+
? {
111+
ELECTRON_EXTRA_LAUNCH_ARGS: '--no-zygote --disable-gpu --single-process',
112+
}
113+
: {}),
108114
},
109115
});
110116

src/Plugins/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,28 @@ const plugin = (on: (task: string, config: unknown) => void): void => {
55
on('task', {
66
storeLocalHistory,
77
});
8+
9+
// if running in AWS lambda, set the necessary args so that cypress can start a chromium based browser
10+
if (process.env.AWS_LAMBDA === '1') {
11+
on(
12+
'before:browser:launch',
13+
(browser: Cypress.Browser, browserLaunchOptions: Cypress.BeforeBrowserLaunchOptions) => {
14+
if (browser.family === 'chromium') {
15+
browserLaunchOptions.args.push(
16+
'--no-sandbox',
17+
'--no-zygote',
18+
'--disable-setuid-sandbox',
19+
'--disable-web-security',
20+
'--disable-gpu',
21+
'--disable-software-rasterizer',
22+
'--disable-dev-shm-usage',
23+
);
24+
}
25+
26+
return browserLaunchOptions;
27+
},
28+
);
29+
}
830
};
931

1032
export default plugin;

0 commit comments

Comments
 (0)