From 8757c9cbb1c7bb035ce6f4b655e2e90746511cb0 Mon Sep 17 00:00:00 2001
From: Ned Schwartz <ned@theinterned.net>
Date: Mon, 16 May 2022 14:50:52 +0000
Subject: [PATCH] fix karma tests in codespaces not running ddue to missing
 --no-sandbox

Note: there is another issue about `chromedriver: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory`. This does not fix that. I manually installed the missing packages. I will have to fiollow up to see if I can fix that.
---
 .devcontainer/devcontainer.json |  3 ++-
 examples/index.html             | 18 +++++++++---------
 karma.config.cjs                | 12 +++++++++++-
 3 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index bf736f9..eeb8862 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -27,6 +27,7 @@
 	// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
 	"remoteUser": "node",
 	"features": {
-		"git": "latest"
+		"git": "latest",
+		"github-cli": "latest"
 	}
 }
diff --git a/examples/index.html b/examples/index.html
index 524a366..6e181b2 100644
--- a/examples/index.html
+++ b/examples/index.html
@@ -1,14 +1,14 @@
-<!doctype html>
+<!DOCTYPE html>
 <html>
   <head>
     <title>Auto-complete examples</title>
-    <meta charset="utf-8">
+    <meta charset="utf-8" />
     <style>
-      auto-complete [aria-selected="true"],
-      auto-complete [role="option"]:hover {
+      auto-complete [aria-selected='true'],
+      auto-complete [role='option']:hover {
         background-color: lavender;
       }
-      auto-complete [aria-disabled="true"] {
+      auto-complete [aria-disabled='true'] {
         color: grey;
       }
     </style>
@@ -42,7 +42,7 @@
       <label id="robots-label" for="robot">Robots</label>
       <!-- To enable auto-select (select first on Enter), use data-autoselect="true" -->
       <auto-complete src="/demo" for="items-popup" aria-labelledby="robots-label" data-autoselect="true">
-        <input name="robot" type="text" aria-labelledby="robots-label" autofocus>
+        <input name="robot" type="text" aria-labelledby="robots-label" autofocus />
         <!-- if a clear button is passed in, recommended to be *before* UL elements to avoid conflicting with their blur logic -->
         <button id="robot-clear">x</button>
         <ul id="items-popup"></ul>
@@ -60,7 +60,7 @@
       <label id="robots-a-label" for="robot-a">Robots (using Input ID)</label>
       <!-- To enable auto-select (select first on Enter), use data-autoselect="true" -->
       <auto-complete src="/demo" for="items-a-popup" aria-labelledby="robots-a-label" data-autoselect="true">
-        <input id="robot-a" name="robot-a" type="text" aria-labelledby="robots-a-label" autofocus>
+        <input id="robot-a" name="robot-a" type="text" aria-labelledby="robots-a-label" autofocus />
         <!-- if a clear button is passed in, recommended to be *before* UL elements to avoid conflicting with their blur logic -->
         <button id="robot-a-clear">x</button>
         <ul id="items-a-popup"></ul>
@@ -76,8 +76,8 @@
     <!-- example without autoselect -->
     <form>
       <label id="robots-2-label" for="robot-2">Robots (without autoselect on enter)</label>
-      <auto-complete src="/demo" for="items-2-popup" aria-labelledby="robots-2-label" >
-        <input name="robot-2" type="text" aria-labelledby="robots-2-label" autofocus>
+      <auto-complete src="/demo" for="items-2-popup" aria-labelledby="robots-2-label">
+        <input name="robot-2" type="text" aria-labelledby="robots-2-label" autofocus />
         <ul id="items-2-popup"></ul>
         <div id="items-2-popup-feedback" class="sr-only"></div>
       </auto-complete>
diff --git a/karma.config.cjs b/karma.config.cjs
index 5cfe87f..10a9ac8 100644
--- a/karma.config.cjs
+++ b/karma.config.cjs
@@ -1,3 +1,6 @@
+/* eslint-disable filenames/match-regex */
+
+// eslint-disable-next-line import/no-commonjs, no-undef, @typescript-eslint/no-var-requires
 process.env.CHROME_BIN = require('chromium').path
 
 function completer(request, response, next) {
@@ -15,6 +18,7 @@ function completer(request, response, next) {
   next()
 }
 
+// eslint-disable-next-line import/no-commonjs, no-undef
 module.exports = function (config) {
   config.set({
     frameworks: ['mocha', 'chai'],
@@ -29,7 +33,13 @@ module.exports = function (config) {
     port: 9876,
     colors: true,
     logLevel: config.LOG_INFO,
-    browsers: ['ChromeHeadless'],
+    browsers: ['ChromeHeadlessNoSandbox'],
+    customLaunchers: {
+      ChromeHeadlessNoSandbox: {
+        base: 'ChromeHeadless',
+        flags: ['--no-sandbox']
+      }
+    },
     autoWatch: false,
     singleRun: true,
     concurrency: Infinity,
