Get tests to run without TS1343 error (npm test)

This commit is contained in:
C. Fuhrman 2024-09-14 18:08:18 -04:00
parent d72dd3ba03
commit d01983a514
7 changed files with 19 additions and 6 deletions

View file

@ -3,7 +3,7 @@
module.exports = { module.exports = {
roots: ['<rootDir>/src'], roots: ['<rootDir>/src'],
transform: { transform: {
'^.+\\.(ts|tsx)$': 'ts-jest', '^.+\\.(ts|tsx)$': ['ts-jest', { tsconfig: 'tsconfig.json' }],
'^.+\\.(js|jsx)$': 'babel-jest' '^.+\\.(js|jsx)$': 'babel-jest'
}, },
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$', testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
@ -13,5 +13,5 @@ module.exports = {
moduleNameMapper: { moduleNameMapper: {
'\\.(css|less|scss|sass)$': 'identity-obj-proxy' '\\.(css|less|scss|sass)$': 'identity-obj-proxy'
}, },
transformIgnorePatterns: ['node_modules/(?!nanoid/)'] transformIgnorePatterns: ['node_modules/(?!nanoid/)'],
}; };

View file

@ -58,6 +58,7 @@
"ts-jest": "^29.1.1", "ts-jest": "^29.1.1",
"typescript": "^5.0.2", "typescript": "^5.0.2",
"vite": "^4.4.5", "vite": "^4.4.5",
"vite-plugin-environment": "^1.1.3",
"vite-plugin-rewrite-all": "^1.0.1" "vite-plugin-rewrite-all": "^1.0.1"
} }
}, },
@ -12459,6 +12460,15 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/vite-plugin-environment": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/vite-plugin-environment/-/vite-plugin-environment-1.1.3.tgz",
"integrity": "sha512-9LBhB0lx+2lXVBEWxFZC+WO7PKEyE/ykJ7EPWCq95NEcCpblxamTbs5Dm3DLBGzwODpJMEnzQywJU8fw6XGGGA==",
"dev": true,
"peerDependencies": {
"vite": ">= 2.7"
}
},
"node_modules/vite-plugin-rewrite-all": { "node_modules/vite-plugin-rewrite-all": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/vite-plugin-rewrite-all/-/vite-plugin-rewrite-all-1.0.2.tgz", "resolved": "https://registry.npmjs.org/vite-plugin-rewrite-all/-/vite-plugin-rewrite-all-1.0.2.tgz",

View file

@ -8,7 +8,7 @@
"build": "tsc && vite build", "build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview", "preview": "vite preview",
"test": "jest", "test": "jest --colors",
"test:watch": "jest --watch" "test:watch": "jest --watch"
}, },
"dependencies": { "dependencies": {
@ -62,6 +62,7 @@
"ts-jest": "^29.1.1", "ts-jest": "^29.1.1",
"typescript": "^5.0.2", "typescript": "^5.0.2",
"vite": "^4.4.5", "vite": "^4.4.5",
"vite-plugin-environment": "^1.1.3",
"vite-plugin-rewrite-all": "^1.0.1" "vite-plugin-rewrite-all": "^1.0.1"
} }
} }

View file

@ -1,7 +1,7 @@
// constants.tsx // constants.tsx
const ENV_VARIABLES = { const ENV_VARIABLES = {
MODE: 'production', MODE: 'production',
VITE_BACKEND_URL: import.meta.env.VITE_BACKEND_URL || "" VITE_BACKEND_URL: process.env.VITE_BACKEND_URL || ""
}; };
export { ENV_VARIABLES }; export { ENV_VARIABLES };

View file

@ -3,7 +3,7 @@
"target": "ESNext", "target": "ESNext",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"], "lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext", "module": "ES2020",
"skipLibCheck": true, "skipLibCheck": true,
/* Bundler mode */ /* Bundler mode */

View file

@ -3,7 +3,7 @@
"compilerOptions": { "compilerOptions": {
"composite": true, "composite": true,
"skipLibCheck": true, "skipLibCheck": true,
"module": "ESNext", "module": "ES2020",
"moduleResolution": "bundler", "moduleResolution": "bundler",
"allowSyntheticDefaultImports": true "allowSyntheticDefaultImports": true
}, },

View file

@ -1,6 +1,7 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc'; import react from '@vitejs/plugin-react-swc';
import pluginChecker from 'vite-plugin-checker'; import pluginChecker from 'vite-plugin-checker';
import EnvironmentPlugin from 'vite-plugin-environment';
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
@ -8,6 +9,7 @@ export default defineConfig({
plugins: [ plugins: [
react(), react(),
pluginChecker({ typescript: true }), pluginChecker({ typescript: true }),
EnvironmentPlugin('all'),
], ],
preview: { preview: {
port: 5173, port: 5173,