Expressのtest
参考
How to test Express.js with Jest and Supertest | Through the binary
Jest公式からリンクされているページ
#WIP
保留mrsekut.icon
CI上で動く環境を作るのが面倒になった
https://www.albertgao.xyz/2017/05/24/how-to-test-expressjs-with-jest-and-supertest/
supertestというlibraryを使っている
superagentベースのテスト用ツール
DBなどをも意識しないといけないので面倒だな
dockerで管理している場合、github actions上で、dockerを立ち上げないとtestできない?
例
code:ts
import { app } from 'src/server';
import request from 'supertest';
describe('Test the root path', () => {
test('It should response the GET method', async () => {
const response = await request(app).get('/');
expect(response.statusCode).toBe(200);
});
});
SuperTest
https://www.npmjs.com/package/supertest
https://github.com/visionmedia/supertest