Testing preparation
This commit is contained in:
parent
287de1f960
commit
5d133de1e9
19
jest.config.ts
Normal file
19
jest.config.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
export default {
|
||||||
|
preset: 'ts-jest',
|
||||||
|
moduleFileExtensions: [
|
||||||
|
'js',
|
||||||
|
'ts',
|
||||||
|
'json',
|
||||||
|
'vue'
|
||||||
|
],
|
||||||
|
transform: {
|
||||||
|
'^.+\\.ts$': 'ts-jest',
|
||||||
|
'^.+\\.vue$': 'vue-jest'
|
||||||
|
},
|
||||||
|
moduleNameMapper: {
|
||||||
|
'^@/(.*)$': '<rootDir>/src/$1',
|
||||||
|
},
|
||||||
|
setupFilesAfterEnv: [
|
||||||
|
'<rootDir>/tests/setup.ts'
|
||||||
|
]
|
||||||
|
}
|
10423
package-lock.json
generated
10423
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vite",
|
"serve": "vite",
|
||||||
"preview": "vite preview --port 8082",
|
"preview": "vite preview --port 8082",
|
||||||
|
"test": "jest",
|
||||||
"build": "vue-tsc --noEmit && vite build --out-dir dist",
|
"build": "vue-tsc --noEmit && vite build --out-dir dist",
|
||||||
"lint": "eslint --ext .ts,.vue src",
|
"lint": "eslint --ext .ts,.vue src",
|
||||||
"lint:fix": "eslint -ext .ts,.vue src --fix",
|
"lint:fix": "eslint -ext .ts,.vue src --fix",
|
||||||
@ -19,20 +20,27 @@
|
|||||||
"vuex": "^4.0"
|
"vuex": "^4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/jest": "^27.0.1",
|
||||||
"@types/leaflet": "1.7.5",
|
"@types/leaflet": "1.7.5",
|
||||||
|
"@types/node": "^16.9.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.31",
|
"@typescript-eslint/eslint-plugin": "^4.31",
|
||||||
"@typescript-eslint/parser": "^4.31",
|
"@typescript-eslint/parser": "^4.31",
|
||||||
"@vitejs/plugin-vue": "^1.6",
|
"@vitejs/plugin-vue": "^1.6",
|
||||||
"@vue/compiler-sfc": "^3.2.10",
|
"@vue/compiler-sfc": "^3.2.10",
|
||||||
"@vue/eslint-config-typescript": "^7.0",
|
"@vue/eslint-config-typescript": "^7.0",
|
||||||
|
"@vue/test-utils": "^2.0.0-rc.14",
|
||||||
"eslint": "^7.32",
|
"eslint": "^7.32",
|
||||||
"eslint-plugin-vue": "^7.17",
|
"eslint-plugin-vue": "^7.17",
|
||||||
|
"jest": "^26.6.3",
|
||||||
"patch-package": "^6.4",
|
"patch-package": "^6.4",
|
||||||
"rollup-plugin-analyzer": "^4.0",
|
"rollup-plugin-analyzer": "^4.0",
|
||||||
"sass": "^1.39",
|
"sass": "^1.39",
|
||||||
|
"ts-jest": "^26.5.6",
|
||||||
|
"ts-node": "^10.2.1",
|
||||||
"typescript": "^4.4",
|
"typescript": "^4.4",
|
||||||
"vite": "^2.5",
|
"vite": "^2.5",
|
||||||
"vite-plugin-svg-sprite-component": "^1.0",
|
"vite-plugin-svg-sprite-component": "^1.0",
|
||||||
|
"vue-jest": "^5.0.0-alpha.10",
|
||||||
"vue-tsc": "0.3.0"
|
"vue-tsc": "0.3.0"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
|
10
src/index.d.ts
vendored
10
src/index.d.ts
vendored
@ -38,6 +38,16 @@ declare global {
|
|||||||
interface Window {
|
interface Window {
|
||||||
liveAtlasConfig: LiveAtlasGlobalConfig,
|
liveAtlasConfig: LiveAtlasGlobalConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare const process : {
|
||||||
|
env: {
|
||||||
|
VITE_VERSION: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProcessEnv {
|
||||||
|
[key: string]: string | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Coordinate {
|
interface Coordinate {
|
||||||
|
@ -91,7 +91,7 @@ export type State = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const state: State = {
|
export const state: State = {
|
||||||
version: (import.meta.env.VITE_VERSION || 'Unknown') as string,
|
version: (process.env.VITE_VERSION || 'Unknown') as string,
|
||||||
servers: new Map(),
|
servers: new Map(),
|
||||||
|
|
||||||
configuration: {
|
configuration: {
|
||||||
|
4
tests/setup.ts
Normal file
4
tests/setup.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
console.warn = jest.fn();
|
||||||
|
|
||||||
|
export {}
|
||||||
|
|
@ -16,7 +16,8 @@
|
|||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"types": [
|
"types": [
|
||||||
"vite/client",
|
"vite/client",
|
||||||
"vue"
|
"vue",
|
||||||
|
"jest"
|
||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": [
|
"@/*": [
|
||||||
@ -32,10 +33,8 @@
|
|||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*.ts",
|
"src/**/*.ts",
|
||||||
"src/**/*.tsx",
|
|
||||||
"src/**/*.vue",
|
"src/**/*.vue",
|
||||||
"tests/**/*.ts",
|
"tests/**/*.ts"
|
||||||
"tests/**/*.tsx"
|
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
|
@ -1,12 +1,26 @@
|
|||||||
// noinspection JSUnusedGlobalSymbols
|
// noinspection JSUnusedGlobalSymbols
|
||||||
|
|
||||||
import { defineConfig } from 'vite';
|
import {defineConfig, loadEnv} from 'vite';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import vue from '@vitejs/plugin-vue';
|
import vue from '@vitejs/plugin-vue';
|
||||||
import svgSpritePlugin from "vite-plugin-svg-sprite-component";
|
import svgSpritePlugin from "vite-plugin-svg-sprite-component";
|
||||||
import analyze from 'rollup-plugin-analyzer';
|
import analyze from 'rollup-plugin-analyzer';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig(({ mode }) => {
|
||||||
|
const env = loadEnv(mode, process.cwd())
|
||||||
|
|
||||||
|
// expose .env as process.env instead of import.meta since jest does not import meta yet
|
||||||
|
const envWithProcessPrefix = Object.entries(env).reduce(
|
||||||
|
(prev, [key, val]) => {
|
||||||
|
return {
|
||||||
|
...prev,
|
||||||
|
['process.env.' + key]: `"${val}"`,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
plugins: [vue(), analyze(), svgSpritePlugin({
|
plugins: [vue(), analyze(), svgSpritePlugin({
|
||||||
symbolId: (name) => `icon--${name}`,
|
symbolId: (name) => `icon--${name}`,
|
||||||
})],
|
})],
|
||||||
@ -26,5 +40,7 @@ export default defineConfig({
|
|||||||
build: {
|
build: {
|
||||||
chunkSizeWarningLimit: 600,
|
chunkSizeWarningLimit: 600,
|
||||||
assetsDir: 'live-atlas/assets'
|
assetsDir: 'live-atlas/assets'
|
||||||
|
},
|
||||||
|
define: envWithProcessPrefix,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user