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 = {
roots: ['<rootDir>/src'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
'^.+\\.(ts|tsx)$': ['ts-jest', { tsconfig: 'tsconfig.json' }],
'^.+\\.(js|jsx)$': 'babel-jest'
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
@ -13,5 +13,5 @@ module.exports = {
moduleNameMapper: {
'\\.(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",
"typescript": "^5.0.2",
"vite": "^4.4.5",
"vite-plugin-environment": "^1.1.3",
"vite-plugin-rewrite-all": "^1.0.1"
}
},
@ -12459,6 +12460,15 @@
"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": {
"version": "1.0.2",
"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",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"test": "jest",
"test": "jest --colors",
"test:watch": "jest --watch"
},
"dependencies": {
@ -62,6 +62,7 @@
"ts-jest": "^29.1.1",
"typescript": "^5.0.2",
"vite": "^4.4.5",
"vite-plugin-environment": "^1.1.3",
"vite-plugin-rewrite-all": "^1.0.1"
}
}

View file

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

View file

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

View file

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

View file

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