feat: prepare jest upgrade and ts testing

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
pull/38806/head
John Molakvoæ 1 year ago
parent 8b5ef98495
commit f8e697ce4d
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
  1. 15
      __mocks__/@nextcloud/auth.js
  2. 1
      __mocks__/svg.js
  3. 0
      __tests__/jest-setup.ts
  4. 5
      custom.d.ts
  5. 42
      jest.config.ts
  6. 389
      package-lock.json
  7. 2
      package.json

@ -0,0 +1,15 @@
import { c } from "tar"
export const getCurrentUser = function() {
return {
uid: 'test',
displayName: 'Test',
isAdmin: false,
}
}
export const getRequestToken = function() {
return 'test-token-1234'
}
export const onRequestTokenUpdate = function() {}

@ -0,0 +1 @@
module.exports = 'SvgMock'

5
custom.d.ts vendored

@ -24,6 +24,11 @@ declare module '*.svg?raw' {
export default content
}
declare module '*.svg' {
const content: any
export default content
}
declare module '*.vue' {
import Vue from 'vue'
export default Vue

@ -1,4 +1,4 @@
/*
/**
* @copyright Copyright (c) 2020 Marco Ambrosini <marcoambrosini@pm.me>
*
* @author Marco Ambrosini <marcoambrosini@pm.me>
@ -19,42 +19,52 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import type { Config } from 'jest'
// TODO: find a way to consolidate this in one place, with webpack.common.js
const ignorePatterns = [
'vue-material-design-icons',
'@juliushaertl',
'tributejs',
'@mdi/svg',
'@nextcloud/vue',
'ansi-regex',
'char-regex',
'splitpanes',
'string-length',
'strip-ansi',
'ansi-regex',
'char-regex',
'tributejs',
'vue-material-design-icons',
]
module.exports = {
testMatch: ['<rootDir>/apps/*/src/**/*.(spec|test).(ts|js)'],
modulePathIgnorePatterns: ["<rootDir>/apps-extra/"],
const config: Config = {
testMatch: ['<rootDir>/**/*.(spec|test).(ts|js)'],
modulePathIgnorePatterns: [
'<rootDir>/apps2/',
'<rootDir>/apps-extra/',
],
transformIgnorePatterns: [
'node_modules/(?!(' + ignorePatterns.join('|') + ')/)',
],
setupFilesAfterEnv: ['<rootDir>/tests/jestSetup.js'],
resetMocks: false,
clearMocks: true,
collectCoverageFrom: [
'<rootDir>/apps/*/src/**/*.{js,vue}',
'<rootDir>/**/*.{js,vue}',
],
setupFilesAfterEnv: ['<rootDir>/__tests__/jest-setup.ts'],
testEnvironment: 'jest-environment-jsdom',
preset: 'ts-jest/presets/js-with-ts',
moduleFileExtensions: [
'js',
'vue',
],
// Allow mocking svg files
moduleDirectories: ['node_modules', '<rootDir>/'],
moduleNameMapper: {
'^.+\\.svg(\\?raw)?$': '<rootDir>/__mocks__/svg.js',
},
transform: {
// process `*.js` files with `babel-jest`
'.*\\.(js)$': 'babel-jest',
'^.+\\.js$': 'babel-jest',
'^.+\\.vue$': '@vue/vue2-jest',
},
}
export default config

389
package-lock.json generated

@ -128,7 +128,6 @@
"jest": "^29.0.3",
"jest-environment-jsdom": "^29.5.0",
"jsdoc": "^4.0.2",
"jsdom": "^22.0.0",
"karma": "^6.4.2",
"karma-chrome-launcher": "^3.1.1",
"karma-coverage": "2.2.0",
@ -144,6 +143,7 @@
"sinon": "<= 5.0.7",
"style-loader": "^3.3.1",
"tar": "^6.1.15",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"tslib": "^2.5.3",
@ -7039,6 +7039,18 @@
"version": "1.0.0",
"license": "ISC"
},
"node_modules/bs-logger": {
"version": "0.2.6",
"resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz",
"integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==",
"dev": true,
"dependencies": {
"fast-json-stable-stringify": "2.x"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/bser": {
"version": "2.1.1",
"dev": true,
@ -8201,17 +8213,6 @@
"dev": true,
"license": "MIT"
},
"node_modules/cssstyle": {
"version": "3.0.0",
"dev": true,
"license": "MIT",
"dependencies": {
"rrweb-cssom": "^0.6.0"
},
"engines": {
"node": ">=14"
}
},
"node_modules/csstype": {
"version": "3.1.2",
"license": "MIT"
@ -8452,19 +8453,6 @@
"node": ">= 12"
}
},
"node_modules/data-urls": {
"version": "4.0.0",
"dev": true,
"license": "MIT",
"dependencies": {
"abab": "^2.0.6",
"whatwg-mimetype": "^3.0.0",
"whatwg-url": "^12.0.0"
},
"engines": {
"node": ">=14"
}
},
"node_modules/date-format": {
"version": "4.0.14",
"dev": true,
@ -15301,77 +15289,6 @@
"node": ">= 12"
}
},
"node_modules/jsdom": {
"version": "22.0.0",
"dev": true,
"license": "MIT",
"dependencies": {
"abab": "^2.0.6",
"cssstyle": "^3.0.0",
"data-urls": "^4.0.0",
"decimal.js": "^10.4.3",
"domexception": "^4.0.0",
"form-data": "^4.0.0",
"html-encoding-sniffer": "^3.0.0",
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.1",
"is-potential-custom-element-name": "^1.0.1",
"nwsapi": "^2.2.4",
"parse5": "^7.1.2",
"rrweb-cssom": "^0.6.0",
"saxes": "^6.0.0",
"symbol-tree": "^3.2.4",
"tough-cookie": "^4.1.2",
"w3c-xmlserializer": "^4.0.0",
"webidl-conversions": "^7.0.0",
"whatwg-encoding": "^2.0.0",
"whatwg-mimetype": "^3.0.0",
"whatwg-url": "^12.0.1",
"ws": "^8.13.0",
"xml-name-validator": "^4.0.0"
},
"engines": {
"node": ">=16"
},
"peerDependencies": {
"canvas": "^2.5.0"
},
"peerDependenciesMeta": {
"canvas": {
"optional": true
}
}
},
"node_modules/jsdom/node_modules/punycode": {
"version": "2.3.0",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/jsdom/node_modules/tough-cookie": {
"version": "4.1.2",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
"psl": "^1.1.33",
"punycode": "^2.1.1",
"universalify": "^0.2.0",
"url-parse": "^1.5.3"
},
"engines": {
"node": ">=6"
}
},
"node_modules/jsdom/node_modules/universalify": {
"version": "0.2.0",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 4.0.0"
}
},
"node_modules/jsesc": {
"version": "2.5.2",
"dev": true,
@ -19863,11 +19780,6 @@
"node": ">=8"
}
},
"node_modules/rrweb-cssom": {
"version": "0.6.0",
"dev": true,
"license": "MIT"
},
"node_modules/run-parallel": {
"version": "1.2.0",
"dev": true,
@ -21993,25 +21905,6 @@
"node": ">=6"
}
},
"node_modules/tr46": {
"version": "4.1.1",
"dev": true,
"license": "MIT",
"dependencies": {
"punycode": "^2.3.0"
},
"engines": {
"node": ">=14"
}
},
"node_modules/tr46/node_modules/punycode": {
"version": "2.3.0",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/tributejs": {
"version": "5.1.3",
"license": "MIT"
@ -22041,6 +21934,97 @@
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/ts-jest": {
"version": "29.1.0",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.0.tgz",
"integrity": "sha512-ZhNr7Z4PcYa+JjMl62ir+zPiNJfXJN6E8hSLnaUKhOgqcn8vb3e537cpkd0FuAfRK3sR1LSqM1MOhliXNgOFPA==",
"dev": true,
"dependencies": {
"bs-logger": "0.x",
"fast-json-stable-stringify": "2.x",
"jest-util": "^29.0.0",
"json5": "^2.2.3",
"lodash.memoize": "4.x",
"make-error": "1.x",
"semver": "7.x",
"yargs-parser": "^21.0.1"
},
"bin": {
"ts-jest": "cli.js"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
},
"peerDependencies": {
"@babel/core": ">=7.0.0-beta.0 <8",
"@jest/types": "^29.0.0",
"babel-jest": "^29.0.0",
"jest": "^29.0.0",
"typescript": ">=4.3 <6"
},
"peerDependenciesMeta": {
"@babel/core": {
"optional": true
},
"@jest/types": {
"optional": true
},
"babel-jest": {
"optional": true
},
"esbuild": {
"optional": true
}
}
},
"node_modules/ts-jest/node_modules/lodash.memoize": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",
"integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==",
"dev": true
},
"node_modules/ts-jest/node_modules/lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dev": true,
"dependencies": {
"yallist": "^4.0.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/ts-jest/node_modules/semver": {
"version": "7.5.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.2.tgz",
"integrity": "sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
},
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/ts-jest/node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
},
"node_modules/ts-jest/node_modules/yargs-parser": {
"version": "21.1.1",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
"dev": true,
"engines": {
"node": ">=12"
}
},
"node_modules/ts-loader": {
"version": "9.4.2",
"dev": true,
@ -23914,18 +23898,6 @@
"node": ">=12"
}
},
"node_modules/whatwg-url": {
"version": "12.0.1",
"dev": true,
"license": "MIT",
"dependencies": {
"tr46": "^4.1.1",
"webidl-conversions": "^7.0.0"
},
"engines": {
"node": ">=14"
}
},
"node_modules/which": {
"version": "2.0.2",
"dev": true,
@ -29016,6 +28988,15 @@
}
}
},
"bs-logger": {
"version": "0.2.6",
"resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz",
"integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==",
"dev": true,
"requires": {
"fast-json-stable-stringify": "2.x"
}
},
"bser": {
"version": "2.1.1",
"dev": true,
@ -29766,13 +29747,6 @@
"version": "0.5.0",
"dev": true
},
"cssstyle": {
"version": "3.0.0",
"dev": true,
"requires": {
"rrweb-cssom": "^0.6.0"
}
},
"csstype": {
"version": "3.1.2"
},
@ -29933,15 +29907,6 @@
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
"optional": true
},
"data-urls": {
"version": "4.0.0",
"dev": true,
"requires": {
"abab": "^2.0.6",
"whatwg-mimetype": "^3.0.0",
"whatwg-url": "^12.0.0"
}
},
"date-format": {
"version": "4.0.14",
"dev": true
@ -34346,55 +34311,6 @@
"dev": true,
"peer": true
},
"jsdom": {
"version": "22.0.0",
"dev": true,
"requires": {
"abab": "^2.0.6",
"cssstyle": "^3.0.0",
"data-urls": "^4.0.0",
"decimal.js": "^10.4.3",
"domexception": "^4.0.0",
"form-data": "^4.0.0",
"html-encoding-sniffer": "^3.0.0",
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.1",
"is-potential-custom-element-name": "^1.0.1",
"nwsapi": "^2.2.4",
"parse5": "^7.1.2",
"rrweb-cssom": "^0.6.0",
"saxes": "^6.0.0",
"symbol-tree": "^3.2.4",
"tough-cookie": "^4.1.2",
"w3c-xmlserializer": "^4.0.0",
"webidl-conversions": "^7.0.0",
"whatwg-encoding": "^2.0.0",
"whatwg-mimetype": "^3.0.0",
"whatwg-url": "^12.0.1",
"ws": "^8.13.0",
"xml-name-validator": "^4.0.0"
},
"dependencies": {
"punycode": {
"version": "2.3.0",
"dev": true
},
"tough-cookie": {
"version": "4.1.2",
"dev": true,
"requires": {
"psl": "^1.1.33",
"punycode": "^2.1.1",
"universalify": "^0.2.0",
"url-parse": "^1.5.3"
}
},
"universalify": {
"version": "0.2.0",
"dev": true
}
}
},
"jsesc": {
"version": "2.5.2",
"dev": true
@ -37253,10 +37169,6 @@
}
}
},
"rrweb-cssom": {
"version": "0.6.0",
"dev": true
},
"run-parallel": {
"version": "1.2.0",
"dev": true,
@ -38647,19 +38559,6 @@
}
}
},
"tr46": {
"version": "4.1.1",
"dev": true,
"requires": {
"punycode": "^2.3.0"
},
"dependencies": {
"punycode": {
"version": "2.3.0",
"dev": true
}
}
},
"tributejs": {
"version": "5.1.3"
},
@ -38674,6 +38573,60 @@
"trough": {
"version": "2.1.0"
},
"ts-jest": {
"version": "29.1.0",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.0.tgz",
"integrity": "sha512-ZhNr7Z4PcYa+JjMl62ir+zPiNJfXJN6E8hSLnaUKhOgqcn8vb3e537cpkd0FuAfRK3sR1LSqM1MOhliXNgOFPA==",
"dev": true,
"requires": {
"bs-logger": "0.x",
"fast-json-stable-stringify": "2.x",
"jest-util": "^29.0.0",
"json5": "^2.2.3",
"lodash.memoize": "4.x",
"make-error": "1.x",
"semver": "7.x",
"yargs-parser": "^21.0.1"
},
"dependencies": {
"lodash.memoize": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",
"integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==",
"dev": true
},
"lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dev": true,
"requires": {
"yallist": "^4.0.0"
}
},
"semver": {
"version": "7.5.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.2.tgz",
"integrity": "sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ==",
"dev": true,
"requires": {
"lru-cache": "^6.0.0"
}
},
"yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
},
"yargs-parser": {
"version": "21.1.1",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
"dev": true
}
}
},
"ts-loader": {
"version": "9.4.2",
"dev": true,
@ -39873,14 +39826,6 @@
"version": "3.0.0",
"dev": true
},
"whatwg-url": {
"version": "12.0.1",
"dev": true,
"requires": {
"tr46": "^4.1.1",
"webidl-conversions": "^7.0.0"
}
},
"which": {
"version": "2.0.2",
"dev": true,

@ -153,7 +153,6 @@
"jest": "^29.0.3",
"jest-environment-jsdom": "^29.5.0",
"jsdoc": "^4.0.2",
"jsdom": "^22.0.0",
"karma": "^6.4.2",
"karma-chrome-launcher": "^3.1.1",
"karma-coverage": "2.2.0",
@ -169,6 +168,7 @@
"sinon": "<= 5.0.7",
"style-loader": "^3.3.1",
"tar": "^6.1.15",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"tslib": "^2.5.3",

Loading…
Cancel
Save