feat: fix up jest tests

This commit is contained in:
Andrew Bastin
2021-09-10 17:50:22 +05:30
parent 05a07dc4a1
commit 36246da9e1
6 changed files with 35 additions and 10 deletions

View 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 {}
}

View File

@@ -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 })

View File

@@ -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",

View File

@@ -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",

2
pnpm-lock.yaml generated
View File

@@ -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