Hi!
I have versioned endpoints like this using the @Version(‘<version>’) decorator:
/api/v1/auth/<endpoint>
/api/v2/auth/<endpoint>
However, when writing E2E tests using the docs, adding /api/v1 to the URL causes everything to return 404s. Removing it and testing only auth/<endpoint> makes the tests pass. However, when it comes to our versioned endpoints, it always points to the first instance of that endpoint in the controller file.
I’ve tried searching online and haven’t found anything regarding how to access the different versioned endpoints in the E2E tests. Below is my current test bootstrapping
beforeAll(async () => {
const moduleRef = await Test.createTestingModule({
imports: [AppModule],
}).compile()
app = moduleRef.createNestApplication()
await app.init()
httpServer = app.getHttpServer()
})
Example endpoint to test
@Version('2')
@Get('')
async getDisplayNamesV2(): Promise<DisplayNamesResponseDtoV2> {
return ...
}
@Get('')
async getDisplayNames(
@Res({ passthrough: true }) res: Response,
): Promise<DisplayNamesResponseDto> {
return ....
}