Эх сурвалжийг харах

playing around with jest and typescript configs.

Tomi Cvetic 4 жил өмнө
parent
commit
d6cecaffd2

+ 3 - 3
frontend/initial-data.ts

@@ -1,6 +1,6 @@
-import { ITraining } from './src/training/types'
+import { TTraining } from './src/training/types'
 
-const data: { trainings: ITraining[]; polls: any } = {
+const data: { trainings: any[]; polls: any } = {
   trainings: [
     {
       id: 'training0',
@@ -20,7 +20,7 @@ const data: { trainings: ITraining[]; polls: any } = {
       blocks: [
         {
           id: 'block0',
-          sequence: 0,
+          order: 0,
           title: 'Drop Sets',
           repetitions: 1,
           rest: 25,

+ 10 - 0
frontend/jest.config.js

@@ -0,0 +1,10 @@
+module.exports = {
+  testEnvironment: 'node',
+  preset: 'ts-jest',
+  setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
+  transform: { '^.+\\.(t|j)sx?$': 'ts-jest' },
+  testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
+  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
+  testPathIgnorePatterns: ['<rootDir>/.next/', '<rootDir>/node_modules/'],
+  globals: { 'ts-jest': { 'ts-config': '<rootDir>/tsconfig.jest.json' } }
+}

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 309 - 264
frontend/package-lock.json


+ 23 - 20
frontend/package.json

@@ -8,26 +8,29 @@
     "start": "next start",
     "test": "jest",
     "test:watch": "npm run test -- --watchAll",
+    "test:coverage": "npm run test -- --coverage",
     "type-check": "tsc"
   },
   "dependencies": {
-    "@apollo/client": "3.0.0-beta.41",
-    "@apollo/react-ssr": "^3.1.3",
+    "@apollo/client": "3.0.0-beta.43",
+    "@apollo/react-ssr": "^3.1.4",
+    "@fortawesome/fontawesome-svg-core": "^1.2.28",
+    "@fortawesome/free-solid-svg-icons": "^5.13.0",
+    "@fortawesome/react-fontawesome": "^0.1.9",
     "@types/howler": "^2.1.2",
-    "@types/jest": "24.9.1",
     "@types/lodash": "^4.14.149",
     "@types/react-onclickoutside": "^6.7.3",
     "@types/styled-jsx": "^2.2.8",
-    "@types/video.js": "7.3.6",
+    "@types/video.js": "7.3.7",
     "apollo-boost": "0.4.7",
-    "apollo-link": "^1.2.13",
-    "apollo-link-error": "^1.1.12",
+    "apollo-link": "^1.2.14",
+    "apollo-link-error": "^1.1.13",
     "array-move": "^2.2.1",
-    "date-fns": "^2.11.1",
+    "date-fns": "^2.12.0",
     "dotenv": "^8.2.0",
     "formik": "2.1.4",
-    "fuse.js": "3.4.5",
-    "graphql": "14.6.0",
+    "fuse.js": "5.1.0",
+    "graphql": "15.0.0",
     "howler": "^2.1.3",
     "isomorphic-unfetch": "^3.0.0",
     "lodash": "^4.17.15",
@@ -41,26 +44,29 @@
     "react-sortable-hoc": "^1.11.0",
     "standard": "14.3.3",
     "video.js": "^7.7.5",
-    "yup": "^0.27.0"
+    "yup": "^0.28.3"
   },
   "devDependencies": {
-    "@apollo/react-testing": "^3.1.3",
+    "@apollo/react-testing": "^3.1.4",
     "@babel/core": "7.9.0",
-    "@babel/preset-env": "7.9.0",
+    "@babel/preset-env": "7.9.5",
     "@babel/preset-react": "7.9.4",
-    "@testing-library/react": "9.5.0",
+    "@testing-library/react": "10.0.2",
     "@testing-library/react-hooks": "^3.2.1",
     "@types/enzyme": "^3.10.5",
-    "@types/react": "16.9.31",
-    "@types/yup": "0.26.34",
+    "@types/jest": "^25.2.1",
+    "@types/react": "16.9.34",
+    "@types/yup": "0.26.35",
     "@zeit/next-typescript": "^1.1.1",
     "babel-eslint": "10.1.0",
-    "babel-jest": "^24.9.0",
+    "babel-jest": "^25.3.0",
     "enzyme": "^3.11.0",
     "enzyme-adapter-react-16": "^1.15.2",
-    "jest": "^24.9.0",
+    "jest": "^25.3.0",
     "jest-transform-graphql": "^2.1.0",
+    "npm-check-updates": "^4.1.2",
     "react-test-renderer": "16.13.1",
+    "ts-jest": "^25.3.1",
     "typescript": "3.8.3"
   },
   "jest": {
@@ -76,8 +82,5 @@
       ".*": "babel-jest",
       "^.+\\.js?$": "babel-jest"
     }
-  },
-  "standard": {
-    "parser": "babel-eslint"
   }
 }

+ 6 - 0
frontend/tsconfig.jest.json

@@ -0,0 +1,6 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "jsx": "react"
+  }
+}

+ 3 - 1
frontend/tsconfig.json

@@ -1,7 +1,8 @@
 {
   "compilerOptions": {
-    "target": "ESNext",
+    "target": "es5",
     "module": "ESNext",
+    "declaration": true,
     "jsx": "preserve",
     "moduleResolution": "Node",
     "allowSyntheticDefaultImports": true,
@@ -11,6 +12,7 @@
     "skipLibCheck": true,
     "forceConsistentCasingInFileNames": true,
     "noEmit": true,
+    "outDir": "./tsout",
     "esModuleInterop": true,
     "resolveJsonModule": true,
     "isolatedModules": true

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно