Skip to content

Commit

Permalink
tests(@nestjs/swagger): update express
Browse files Browse the repository at this point in the history
  • Loading branch information
destyk committed Jul 31, 2023
1 parent 05c8c78 commit 5d2938b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion e2e/express.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as request from 'supertest';
import * as SwaggerParser from 'swagger-parser';
import { DocumentBuilder, SwaggerModule } from '../lib';
import { ApplicationModule } from './src/app.module';
import * as path from 'path';

describe('Express Swagger', () => {
let app: NestExpressApplication;
Expand Down Expand Up @@ -83,7 +84,10 @@ describe('Express Swagger', () => {
app,
builder.build()
);
SwaggerModule.setup(SWAGGER_RELATIVE_URL, app, swaggerDocument);
SwaggerModule.setup(SWAGGER_RELATIVE_URL, app, swaggerDocument, {
// to showcase that in new implementation u can use custom swagger-ui path. Useful when using e.g. webpack
customSwaggerUiPath: path.resolve(`./node_modules/swagger-ui-dist`),
});

await app.init();
});
Expand All @@ -100,6 +104,14 @@ describe('Express Swagger', () => {
expect(response.status).toEqual(200);
expect(Object.keys(response.body).length).toBeGreaterThan(0);
});

it('content type of served static should be available', async () => {
const response = await request(app.getHttpServer()).get(
`${SWAGGER_RELATIVE_URL}/swagger-ui-bundle.js`
);

expect(response.status).toEqual(200);
});
});

describe('custom documents endpoints', () => {
Expand Down

0 comments on commit 5d2938b

Please sign in to comment.