diff --git a/mitmproxy/tools/web/app.py b/mitmproxy/tools/web/app.py
index 3ac354f0b..e57a7b682 100644
--- a/mitmproxy/tools/web/app.py
+++ b/mitmproxy/tools/web/app.py
@@ -465,7 +465,7 @@ class Commands(RequestHandler):
if result is None:
self.write({"result": ""})
return
- self.write({ "result": result, "type": type(result).__name__ })
+ self.write({"result": result, "type": type(result).__name__})
class Events(RequestHandler):
diff --git a/web/package.json b/web/package.json
index 4133fe65a..595ec274b 100644
--- a/web/package.json
+++ b/web/package.json
@@ -1,6 +1,9 @@
{
"name": "mitmproxy",
"private": true,
+ "jest": {
+ "verbose": true
+ },
"scripts": {
"test": "jest --coverage",
"build": "gulp prod",
@@ -31,6 +34,7 @@
"@types/redux-mock-store": "^1.0.2",
"esbuild": "^0.12.9",
"esbuild-jest": "^0.5.0",
+ "fetch-mock": "^9.11.0",
"gulp": "^4.0.2",
"gulp-clean-css": "^4.3.0",
"gulp-esbuild": "^0.8.2",
@@ -42,6 +46,7 @@
"gulp-replace": "^1.1.3",
"gulp-sourcemaps": "^3.0.0",
"jest": "^27.0.4",
+ "node-fetch": "^2.6.1",
"through2": "^4.0.2"
}
}
diff --git a/web/src/js/__tests__/components/Command/CommandSpec.js b/web/src/js/__tests__/components/Command/CommandSpec.js
index 5f24639b7..7ff6c413f 100644
--- a/web/src/js/__tests__/components/Command/CommandSpec.js
+++ b/web/src/js/__tests__/components/Command/CommandSpec.js
@@ -1,8 +1,11 @@
import React from 'react'
import CommandBar from '../../../components/CommandBar'
import { render } from "../../test-utils"
+import fetchMock from 'fetch-mock';
test('CommandBar Component', async () => {
+ fetchMock.get('./commands.json', {status: 200})
+
const {asFragment, store} = render(