diff --git a/package.json b/package.json
index 57b70b8d361..cb7e08014ee 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,8 @@
"release:windows": "set NODE_ENV=production&& gulp release",
"pretest": "yarn run lint",
"test": "karma start test/karma.conf.js",
+ "TODO": "remove the above test after the migration to vitest is complete",
+ "test:vitest": "vitest",
"lint": "eslint --ext .js,.vue src gulpfile.js gulp-appdmg.js",
"lint:fix": "eslint --fix src gulpfile.js gulp-appdmg.js",
"storybook": "start-storybook -p 6006"
@@ -66,6 +68,7 @@
"jquery-textcomplete": "^1.8.5",
"jquery-touchswipe": "^1.6.19",
"jquery-ui-npm": "^1.12.0",
+ "jsdom": "^21.0.0",
"lru_map": "^0.3.3",
"marked": "^4.1.1",
"multicast-dns": "^7.2.5",
@@ -139,6 +142,8 @@
"temp": "^0.9.4",
"through2": "^4.0.2",
"vinyl-source-stream": "^2.0.0",
+ "vite": "^4.0.4",
+ "vitest": "^0.27.1",
"vue-loader": "^15.9.8",
"vue-template-compiler": "^2.7.10",
"yarn": "^1.22.19"
diff --git a/src/js/gui.js b/src/js/gui.js
index e72eb5566d7..7def9c26b7b 100644
--- a/src/js/gui.js
+++ b/src/js/gui.js
@@ -1,7 +1,9 @@
import { get as getConfig } from './ConfigStorage';
import MSP from './msp';
-window.TABS = {}; // filled by individual tab js file
+const TABS = {};
+
+window.TABS = TABS; // filled by individual tab js file
const GUI_MODES = {
NWJS: "NW.js",
@@ -523,7 +525,7 @@ function GUI_checkOperatingSystem() {
const GUI = new GuiControl();
+export { TABS };
// initialize object into GUI variable
window.GUI = GUI;
-
export default GUI;
diff --git a/test/tabs/cli.js b/test/tabs/cli.js
index 9dcf920a095..073956eb120 100644
--- a/test/tabs/cli.js
+++ b/test/tabs/cli.js
@@ -50,22 +50,6 @@ describe('TABS.cli', () => {
TABS.cli.cliBuffer = "";
});
- it('ambiguous auto-complete results', () => {
- TABS.cli.cliBuffer = 'se';
-
- TABS.cli.read({
- data: toArrayBuffer('\r\x1B[Kserialpassthrough\tservo\r\n# ser'),
- });
-
- // Ambigous auto-complete from firmware is preceded with an \r carriage return
- // which only renders a line break on Mac
- const expectedValue = GUI.operating_system !== "Windows" ?
- 'se
serialpassthrough\tservo
' :
- 'seserialpassthrough\tservo
';
- expect(cliOutput.html()).to.equal(expectedValue);
- expect(cliPrompt.val()).to.equal('ser');
- });
-
it('unambiguous auto-complete result', () => {
TABS.cli.read({
data: toArrayBuffer('serialpassthrough'),
diff --git a/tests/cli.test.js b/tests/cli.test.js
new file mode 100644
index 00000000000..d477aa8f2cc
--- /dev/null
+++ b/tests/cli.test.js
@@ -0,0 +1,73 @@
+import { describe, it, expect, beforeAll, afterAll, beforeEach } from "vitest";
+import CliAutoComplete from "../src/js/CliAutoComplete";
+import { cli } from "../src/js/tabs/cli";
+import $ from "jquery";
+import CONFIGURATOR from "../src/js/data_storage";
+
+class MockAnalytics {
+ sendEvent() {
+ // Empty
+ }
+}
+
+MockAnalytics.prototype.EVENT_CATEGORIES = {};
+
+ function toArrayBuffer(string) {
+ const bufferOut = new ArrayBuffer(string.length);
+ const bufView = new Uint8Array(bufferOut);
+
+ for (let i = 0; i < string.length; i++) {
+ bufView[i] = string.charCodeAt(i);
+ }
+
+ return bufferOut;
+ }
+
+describe("cli", () => {
+ describe("output", () => {
+ let cliTab;
+ let cliOutput;
+ let cliPrompt;
+ let tracking;
+
+ beforeAll(() => {
+ cliTab = $("