diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..91a2d2c --- /dev/null +++ b/jest.config.js @@ -0,0 +1,4 @@ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', +}; \ No newline at end of file diff --git a/package.json b/package.json index afc485d..8674353 100644 --- a/package.json +++ b/package.json @@ -47,14 +47,18 @@ "@types/cors": "^2.8.8", "@types/dotenv-safe": "^8.1.1", "@types/express": "^4.17.9", + "@types/jest": "^26.0.16", "@types/jsonwebtoken": "^8.5.0", "@types/multer": "^1.4.4", "@types/node": "^14.14.9", "@types/swagger-ui-express": "^4.1.2", "@types/uuid": "^8.3.0", + "axios": "^0.21.0", "dotenv-safe": "^8.2.0", + "jest": "^26.6.3", "nodemon": "^2.0.6", "sqlite3": "^5.0.0", + "ts-jest": "^26.4.4", "ts-node": "^9.0.0", "typedoc": "^0.19.2", "typescript": "^4.1.2" @@ -62,6 +66,7 @@ "scripts": { "dev": "nodemon src/app.ts", "build": "tsc", - "docs": "typedoc --out docs src" + "docs": "typedoc --out docs src", + "test": "jest" } -} \ No newline at end of file +} diff --git a/src/tests/firsttest.spec.ts b/src/tests/firsttest.spec.ts new file mode 100644 index 0000000..3e67076 --- /dev/null +++ b/src/tests/firsttest.spec.ts @@ -0,0 +1,14 @@ +import axios from 'axios'; + +describe('GET /api/openapi.json', () => { + it('is http 200', async () => { + const res = await axios.get('http://localhost:4010/api/openapi.json'); + expect(res.status).toEqual(200); + }); +}); +describe('GET /', () => { + it('is http 404', async () => { + const res = await axios.get('http://localhost:4010/', { validateStatus: undefined }); + expect(res.status).toEqual(404); + }); +});