add test and docs config
All checks were successful
Build Docker Image Front / run (push) Successful in 21s
Build Docker Image Back / run (push) Successful in 20s
Build Docker Image Front / run (pull_request) Successful in 22s
Build Docker Image Back / run (pull_request) Successful in 21s

This commit is contained in:
Clement 2024-05-03 17:09:34 +02:00
parent 94b2ce2d16
commit 120ed8182a
6 changed files with 1645 additions and 13 deletions

View File

@ -0,0 +1,13 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
collectCoverage: true,
coverageDirectory: 'coverage',
collectCoverageFrom: [
'**/*.ts',
'!/nodemodules/',
'!/jest.config.js/',
'!/coverage/',
],
};

View File

@ -0,0 +1,15 @@
{
"opts": {
"template": "node_modules/better-docs"
},
"tags": {
"allowUnknownTags": ["optional"]
},
"plugins": [
"node_modules/better-docs/typescript"
],
"source": {
"include": ["./src"],
"includePattern": "\\.(jsx|js|ts|tsx)$"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +1,33 @@
{ {
"main": "dist/server.js",
"scripts": { "scripts": {
"build": "rimraf dist && npx tsc", "build": "rimraf dist && npx tsc",
"start": "node dist/index.js", "start": "node dist/index.js",
"predev": "npm run build", "predev": "npm run build",
"dev": "npx tsc -w & nodemon dist/index.js" "dev": "npx tsc -w & nodemon dist/server.js",
"docs": "jsdoc -c jsdoc.json",
"test": "jest"
}, },
"dependencies": { "dependencies": {
"@types/express": "^4.17.21", "@types/express": "^4.17.21",
"@types/node": "^20.12.7", "@types/node": "^20.12.7",
"dotenv": "^16.4.5", "dotenv": "^16.4.5",
"express": "^4.19.2", "express": "^4.19.2",
"rimraf": "^5.0.5", "rimraf": "^5.0.5"
"typescript": "^5.4.5"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.12",
"@types/supertest": "^6.0.2",
"babel-cli": "^6.26.0", "babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0", "babel-preset-env": "^1.7.0",
"better-docs": "^2.7.3",
"jest": "^29.7.0", "jest": "^29.7.0",
"jsdoc": "^4.0.3",
"nodemon": "^3.1.0", "nodemon": "^3.1.0",
"superagent": "^9.0.2", "superagent": "^9.0.2",
"supertest": "^7.0.0" "supertest": "^7.0.0",
"ts-jest": "^29.1.2",
"typedoc": "^0.25.13",
"typescript": "^5.4.5"
} }
} }

View File

@ -0,0 +1,39 @@
import request from "supertest";
import app from "../src/app";
import { Server, IncomingMessage, ServerResponse } from "http";
const port = 3000;
let serveur : Server<typeof IncomingMessage, typeof ServerResponse>
describe("Test the root path", () => {
beforeEach(() => {
serveur = app.listen(port, () =>{
console.log(`serveur running in ${port}`)
})
})
afterEach((done) => {
serveur.close(done)
})
test("It should response the GET method", done => {
request(app)
.get("/")
.then(response => {
expect(response.statusCode).toBe(200);
done();
});
});
test("It should response the GET method", done => {
request(app)
.get("/")
.then(response => {
console.log(response)
expect(response.text).toEqual("helloworld form dev")
done();
});
});
});

View File

@ -28,9 +28,9 @@
"module": "commonjs", /* Specify what module code is generated. */ "module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */ // "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ "baseUrl": "src", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ "rootDirs": ["./src"], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */