Skip to content

Commit c7482b9

Browse files
authored
Merge pull request #1931 from SUI-Components/no-sandbox
feat(packages/sui-test): add flag to use chrome headless w/o sandbox
2 parents 89e7d27 + 5b9969e commit c7482b9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/sui-test/bin/karma/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = async ({
1111
coverage,
1212
coverageInline,
1313
headless,
14+
headlessNoSandbox,
1415
ignorePattern,
1516
pattern,
1617
srcPattern,
@@ -36,6 +37,21 @@ module.exports = async ({
3637
config.browsers = ['ChromeHeadless']
3738
}
3839

40+
/**
41+
* We check the headlessNoSandbox flag after the headless flag
42+
* so we use the HeadlessNoSandbox browser if it's present
43+
* instead ChromeHeadless
44+
*/
45+
if (headlessNoSandbox) {
46+
config.browsers = ['ChromeHeadlessNoSandbox']
47+
config.customLaunchers = {
48+
ChromeHeadlessNoSandbox: {
49+
base: 'ChromeHeadless',
50+
flags: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage']
51+
}
52+
}
53+
}
54+
3955
if (coverage || ci) {
4056
config.reporters = ['coverage'].concat(config.reporters)
4157

packages/sui-test/bin/sui-test-browser.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ program
99
.option('-W, --watch', 'Run in watch mode')
1010
.option('-C, --ci', 'Run a Firefox headless for CI testing')
1111
.option('-H, --headless', 'Run a headless browser for testing')
12+
.option('--headless-no-sandbox', 'Run a headless browser with no sandbox for testing')
1213
.option('-P, --pattern <pattern>', 'Path pattern to include', 'test/**/*Spec.+(js|jsx|ts|tsx)')
1314
.option('-I, --ignore-pattern <ignorePattern>', 'Path pattern to ignore for testing', false)
1415
.option('--src-pattern <srcPattern>', 'Define the source directory', false)
@@ -24,19 +25,22 @@ program
2425
console.log('')
2526
console.log(' $ sui-test browser')
2627
console.log(' $ sui-test browser --headless')
28+
console.log(' $ sui-test browser --headless-no-sandbox')
2729
console.log(' $ sui-test browser --coverage')
2830
console.log(' $ sui-test browser --coverage --no-coverage-inline')
2931
console.log('')
3032
})
3133
.parse(process.argv)
3234

33-
const {ci, coverage, coverageInline, headless, ignorePattern, pattern, srcPattern, timeout, watch} = program.opts()
35+
const {ci, coverage, coverageInline, headless, headlessNoSandbox, ignorePattern, pattern, srcPattern, timeout, watch} =
36+
program.opts()
3437

3538
runner({
3639
ci,
3740
coverage,
3841
coverageInline,
3942
headless,
43+
headlessNoSandbox,
4044
ignorePattern,
4145
pattern,
4246
srcPattern,

0 commit comments

Comments
 (0)