feat: fix up jest tests
This commit is contained in:
26
packages/hoppscotch-app/babel.config.js
Normal file
26
packages/hoppscotch-app/babel.config.js
Normal file
@@ -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 {}
|
||||||
|
}
|
||||||
@@ -47,7 +47,7 @@ export default function runTestScriptWithVariables(
|
|||||||
expect(value: any) {
|
expect(value: any) {
|
||||||
try {
|
try {
|
||||||
return expect(value, this._testReports)
|
return expect(value, this._testReports)
|
||||||
} catch (e) {
|
} catch (e: any) {
|
||||||
pw._testReports.push({
|
pw._testReports.push({
|
||||||
result: "ERROR",
|
result: "ERROR",
|
||||||
message: e.toString(),
|
message: e.toString(),
|
||||||
@@ -80,7 +80,7 @@ function test(
|
|||||||
_testReports.push({ startBlock: descriptor })
|
_testReports.push({ startBlock: descriptor })
|
||||||
try {
|
try {
|
||||||
func()
|
func()
|
||||||
} catch (e) {
|
} catch (e: any) {
|
||||||
_testReports.push({ result: "ERROR", message: e, styles: styles.ERROR })
|
_testReports.push({ result: "ERROR", message: e, styles: styles.ERROR })
|
||||||
}
|
}
|
||||||
_testReports.push({ endBlock: true })
|
_testReports.push({ endBlock: true })
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ module.exports = {
|
|||||||
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
|
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
|
||||||
snapshotSerializers: ["jest-serializer-vue"],
|
snapshotSerializers: ["jest-serializer-vue"],
|
||||||
collectCoverage: true,
|
collectCoverage: true,
|
||||||
collectCoverageFrom: [
|
|
||||||
"<rootDir>/components/**/*.vue",
|
|
||||||
"<rootDir>/pages/*.vue",
|
|
||||||
],
|
|
||||||
testURL: "http://localhost/",
|
testURL: "http://localhost/",
|
||||||
preset: "ts-jest/presets/js-with-babel",
|
preset: "ts-jest/presets/js-with-babel",
|
||||||
testEnvironment: "jsdom",
|
testEnvironment: "jsdom",
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
"ace-builds": "^1.4.12",
|
"ace-builds": "^1.4.12",
|
||||||
"acorn": "^8.5.0",
|
"acorn": "^8.5.0",
|
||||||
"acorn-walk": "^8.2.0",
|
"acorn-walk": "^8.2.0",
|
||||||
|
"axios": "^0.21.4",
|
||||||
"core-js": "^3.17.2",
|
"core-js": "^3.17.2",
|
||||||
"esprima": "^4.0.1",
|
"esprima": "^4.0.1",
|
||||||
"firebase": "^9.0.1",
|
"firebase": "^9.0.1",
|
||||||
@@ -65,10 +66,9 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.15.5",
|
"@babel/core": "^7.15.5",
|
||||||
"@babel/preset-env": "^7.15.4",
|
"@babel/preset-env": "^7.15.4",
|
||||||
"@nuxt/types": "^2.15.8",
|
|
||||||
"@commitlint/cli": "^13.1.0",
|
"@commitlint/cli": "^13.1.0",
|
||||||
"@commitlint/config-conventional": "^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",
|
"@nuxt/typescript-build": "^2.1.0",
|
||||||
"@nuxtjs/color-mode": "^2.1.1",
|
"@nuxtjs/color-mode": "^2.1.1",
|
||||||
"@nuxtjs/dotenv": "^1.4.1",
|
"@nuxtjs/dotenv": "^1.4.1",
|
||||||
@@ -93,6 +93,7 @@
|
|||||||
"eslint-plugin-vue": "^7.17.0",
|
"eslint-plugin-vue": "^7.17.0",
|
||||||
"jest": "^27.1.0",
|
"jest": "^27.1.0",
|
||||||
"jest-serializer-vue": "^2.0.2",
|
"jest-serializer-vue": "^2.0.2",
|
||||||
|
"lint-staged": "^11.1.2",
|
||||||
"nuxt-windicss": "^1.2.3",
|
"nuxt-windicss": "^1.2.3",
|
||||||
"prettier": "^2.3.2",
|
"prettier": "^2.3.2",
|
||||||
"pretty-quick": "^3.1.1",
|
"pretty-quick": "^3.1.1",
|
||||||
|
|||||||
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
@@ -43,6 +43,7 @@ importers:
|
|||||||
ace-builds: ^1.4.12
|
ace-builds: ^1.4.12
|
||||||
acorn: ^8.5.0
|
acorn: ^8.5.0
|
||||||
acorn-walk: ^8.2.0
|
acorn-walk: ^8.2.0
|
||||||
|
axios: ^0.21.4
|
||||||
babel-core: ^7.0.0-bridge.0
|
babel-core: ^7.0.0-bridge.0
|
||||||
babel-jest: ^27.1.0
|
babel-jest: ^27.1.0
|
||||||
core-js: ^3.17.2
|
core-js: ^3.17.2
|
||||||
@@ -104,6 +105,7 @@ importers:
|
|||||||
ace-builds: 1.4.12
|
ace-builds: 1.4.12
|
||||||
acorn: 8.5.0
|
acorn: 8.5.0
|
||||||
acorn-walk: 8.2.0
|
acorn-walk: 8.2.0
|
||||||
|
axios: 0.21.4
|
||||||
core-js: 3.17.3
|
core-js: 3.17.3
|
||||||
esprima: 4.0.1
|
esprima: 4.0.1
|
||||||
firebase: 9.0.1
|
firebase: 9.0.1
|
||||||
|
|||||||
Reference in New Issue
Block a user