Skip to content

Commit

Permalink
Add integration test for wildcard path scenario
Browse files Browse the repository at this point in the history
Issue: PayU#59
  • Loading branch information
kdhira committed Mar 8, 2022
1 parent 1ec335e commit b59aa57
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/integration-tests/koa/middleware-test.js
Expand Up @@ -679,6 +679,23 @@ describe('when using koa framework', () => {
});
});
});
describe('when calling wildcard endpoint', function () {
before(() => {
const wildcardPath = '/wild-path/' + Math.floor(Math.random() * 10);
return supertest(app)
.get(wildcardPath)
.expect(200)
.then((res) => {});
});
it('should add it to the histogram', () => {
return supertest(app)
.get('/metrics')
.expect(200)
.then((res) => {
expect(res.text).to.contain('method="GET",route="N/A",code="200"');
});
});
});
it('should get metrics as json', () => {
return supertest(app)
.get('/metrics.json')
Expand Down
6 changes: 6 additions & 0 deletions test/integration-tests/koa/server/koa-server.js
Expand Up @@ -78,4 +78,10 @@ router.post('/test', async (ctx, next) => {
return next();
});

router.get('/wild-path/(.*)', (ctx, next) => {
ctx.status = 200;
ctx.body = { message: 'Wildcard route reached!' };
return next();
});

module.exports = app;

0 comments on commit b59aa57

Please sign in to comment.