From f742e178e94b5e8f933b50cb1d22cda4bd08e7e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guillaume=20Perr=C3=A9al?= <guillaume.perreal@irstea.fr>
Date: Tue, 16 Feb 2021 16:36:49 +0100
Subject: [PATCH] ts: installe est configure jest.

---
 .eslintrc.js       |  4 +++-
 jest.config.js     |  3 +++
 package.json       |  5 ++++-
 tsconfig.base.json | 14 ++++++++++++++
 tsconfig.ci.json   | 20 ++++++--------------
 tsconfig.lib.json  | 14 ++++++++++++++
 6 files changed, 44 insertions(+), 16 deletions(-)
 create mode 100644 jest.config.js
 create mode 100644 tsconfig.base.json
 create mode 100644 tsconfig.lib.json

diff --git a/.eslintrc.js b/.eslintrc.js
index 3dfa577..81e656b 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -10,5 +10,7 @@ module.exports = {
         // Doit rester en dernier :
         'plugin:prettier/recommended',
     ],
-    rules: {},
+    rules: {
+        '@typescript-eslint/no-explicit-any': 0,
+    },
 };
diff --git a/jest.config.js b/jest.config.js
new file mode 100644
index 0000000..e4a9178
--- /dev/null
+++ b/jest.config.js
@@ -0,0 +1,3 @@
+module.exports = {
+    preset: 'ts-jest',
+};
diff --git a/package.json b/package.json
index f94920f..e862ef0 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,7 @@
   "directories": {},
   "scripts": {
     "lint": "eslint --fix '{src,tests}/**/*.{js,ts}' --quiet --fix",
-    "test": "echo \"Error: no test specified\" && exit 1",
+    "test": "jest",
     "test:compile-generated": "tsc --project tsconfig.ci.json --pretty --noEmit",
     "test:lint": "eslint '{src,tests}/**/*.{js,ts}'"
   },
@@ -32,13 +32,16 @@
   "devDependencies": {
     "@angular/common": "^7",
     "@angular/core": "^7",
+    "@types/jest": "^26.0.20",
     "@typescript-eslint/eslint-plugin": "^4.15.1",
     "@typescript-eslint/parser": "^4.15.1",
     "eslint": "^7.20.0",
     "eslint-config-prettier": "^7.2.0",
     "eslint-plugin-prettier": "^3.3.1",
+    "jest": "^26.6.3",
     "prettier": "^2.2.1",
     "rxjs-marbles": "^5.0.3",
+    "ts-jest": "^26.5.1",
     "typescript": "^3.7.2",
     "zone.js": "~0.8.26"
   }
diff --git a/tsconfig.base.json b/tsconfig.base.json
new file mode 100644
index 0000000..0d01d28
--- /dev/null
+++ b/tsconfig.base.json
@@ -0,0 +1,14 @@
+{
+  "$schema": "https://json.schemastore.org/tsconfig",
+
+  "extends": "@tsconfig/node10/tsconfig.json",
+
+  "compileOnSave": false,
+  "compilerOptions": {
+    "noEmit": true,
+    "rootDir": "src/ts"
+  },
+
+  "include": ["src/ts/**/*.ts"],
+  "exclude": ["node_modules"]
+}
diff --git a/tsconfig.ci.json b/tsconfig.ci.json
index f228d50..44a4c47 100644
--- a/tsconfig.ci.json
+++ b/tsconfig.ci.json
@@ -1,16 +1,8 @@
 {
-  "extends": "./node_modules/irstea-typescript-config/tsconfig.json",
-  "compileOnSave": false,
-  "compilerOptions": {
-    "outDir": "out-tsc/test",
-    "target": "es2015",
-    "declaration": true,
-    "sourceMap": true,
-    "inlineSources": false,
-    "experimentalDecorators": true,
-    "typeRoots": ["node_modules/@types"],
-    "moduleResolution": "node",
-    "lib": ["dom","es2018"]
-  },
-  "include": ["output/**/*.ts"]
+  "$schema": "https://json.schemastore.org/tsconfig",
+
+  "extends": "./tsconfig.base.json",
+
+  "include": ["src/ts/**/*.ts", "output/**/*.ts"],
+  "exclude": ["node_modules", "**/*.spec.ts"]
 }
diff --git a/tsconfig.lib.json b/tsconfig.lib.json
new file mode 100644
index 0000000..ffad58a
--- /dev/null
+++ b/tsconfig.lib.json
@@ -0,0 +1,14 @@
+{
+  "$schema": "https://json.schemastore.org/tsconfig",
+
+  "extends": "./tsconfig.base.json",
+
+  "compilerOptions": {
+    "noEmit": false,
+    "outDir": "./dist",
+    "sourceMap": true,
+    "declaration": true,
+    "removeComments": true
+  },
+  "exclude": ["node_modules", "**/*.spec.ts"]
+}
-- 
GitLab