Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

feat: fix up jest tests

Andrew Bastin36246da9e100
diff --git a/packages/hoppscotch-app/babel.config.js b/packages/hoppscotch-app/babel.config.js
new file mode 100644
index 000000000..eae7917d0
--- /dev/null
+++ b/packages/hoppscotch-app/babel.config.js
@@ -0,0 +1,26 @@
+function isBabelLoader(caller) {
+ return caller && caller.name === "babel-loader"
+}
+
+module.exports = function (api) {
+ if (api.env("test") && !api.caller(isBabelLoader)) {
+ return {
+ plugins: [
+ "@babel/plugin-proposal-class-properties",
+ "@babel/plugin-proposal-nullish-coalescing-operator",
+ "@babel/plugin-proposal-optional-chaining",
+ ],
+ presets: [
+ [
+ "@babel/preset-env",
+ {
+ targets: {
+ node: "current",
+ },
+ },
+ ],
+ ],
+ }
+ }
+ return {}
+}
diff --git a/packages/hoppscotch-app/helpers/postwomanTesting.ts b/packages/hoppscotch-app/helpers/postwomanTesting.ts
index efd442a00..8e954c3e0 100644
--- a/packages/hoppscotch-app/helpers/postwomanTesting.ts
+++ b/packages/hoppscotch-app/helpers/postwomanTesting.ts
@@ -47,7 +47,7 @@ export default function runTestScriptWithVariables(
expect(value: any) {
try {
return expect(value, this._testReports)
- } catch (e) {
+ } catch (e: any) {
pw._testReports.push({
result: "ERROR",
message: e.toString(),
@@ -80,7 +80,7 @@ function test(
_testReports.push({ startBlock: descriptor })
try {
func()
- } catch (e) {
+ } catch (e: any) {
_testReports.push({ result: "ERROR", message: e, styles: styles.ERROR })
}
_testReports.push({ endBlock: true })
diff --git a/packages/hoppscotch-app/jest.config.js b/packages/hoppscotch-app/jest.config.js
index 428c4f9c7..d52b88f4f 100644
--- a/packages/hoppscotch-app/jest.config.js
+++ b/packages/hoppscotch-app/jest.config.js
@@ -14,10 +14,6 @@ module.exports = {
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
snapshotSerializers: ["jest-serializer-vue"],
collectCoverage: true,
- collectCoverageFrom: [
- "<rootDir>/components/**/*.vue",
- "<rootDir>/pages/*.vue",
- ],
testURL: "http://localhost/",
preset: "ts-jest/presets/js-with-babel",
testEnvironment: "jsdom",
diff --git a/packages/hoppscotch-app/package.json b/packages/hoppscotch-app/package.json
index 79585320a..4afec6ad8 100644
--- a/packages/hoppscotch-app/package.json
+++ b/packages/hoppscotch-app/package.json
@@ -5,8 +5,8 @@
"author": "Hoppscotch ([email protected])",
"private": true,
"engines": {
- "node": ">=14",
- "pnpm": ">=3"
+ "node": ">=14",
+ "pnpm": ">=3"
},
"scripts": {
"dev": "nuxt",
@@ -36,6 +36,7 @@
"ace-builds": "^1.4.12",
"acorn": "^8.5.0",
"acorn-walk": "^8.2.0",
+ "axios": "^0.21.4",
"core-js": "^3.17.2",
"esprima": "^4.0.1",
"firebase": "^9.0.1",
@@ -65,10 +66,9 @@
"devDependencies": {
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.4",
- "@nuxt/types": "^2.15.8",
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
- "lint-staged": "^11.1.2",
+ "@nuxt/types": "^2.15.8",
"@nuxt/typescript-build": "^2.1.0",
"@nuxtjs/color-mode": "^2.1.1",
"@nuxtjs/dotenv": "^1.4.1",
@@ -93,6 +93,7 @@
"eslint-plugin-vue": "^7.17.0",
"jest": "^27.1.0",
"jest-serializer-vue": "^2.0.2",
+ "lint-staged": "^11.1.2",
"nuxt-windicss": "^1.2.3",
"prettier": "^2.3.2",
"pretty-quick": "^3.1.1",
diff --git a/tsconfig.json b/packages/hoppscotch-app/tsconfig.json
similarity index 100%
rename from tsconfig.json
rename to packages/hoppscotch-app/tsconfig.json
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 87ea80a88..170021252 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -43,6 +43,7 @@ importers:
ace-builds: ^1.4.12
acorn: ^8.5.0
acorn-walk: ^8.2.0
+ axios: ^0.21.4
babel-core: ^7.0.0-bridge.0
babel-jest: ^27.1.0
core-js: ^3.17.2
@@ -104,6 +105,7 @@ importers:
ace-builds: 1.4.12
acorn: 8.5.0
acorn-walk: 8.2.0
+ axios: 0.21.4
core-js: 3.17.3
esprima: 4.0.1
firebase: 9.0.1