basic jest + typescript support

ref #17
This commit is contained in:
Philipp Dormann 2020-12-05 18:49:09 +01:00
parent 5c259484ee
commit 8ae5cea631
3 changed files with 25 additions and 2 deletions

4
jest.config.js Normal file
View File

@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};

View File

@ -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"
}
}
}

View File

@ -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);
});
});