-
Hi, I'm having trouble while testing my app, if I start my application it loads the schemas correctly and they're working. The test fails in the before all when creating the configureControllerTest like this describe('Controller: CalculatorController', () => {
let instance: FastifyInstanceWithController<CalculatorController>;
const myService = {someFunction: jest.fn()};
beforeAll(async () => {
instance = await configureControllerTest({
controller: CalculatorController,
mocks: [
{
provide: MyService,
useValue: myService,
},
],
});
});
}); And the controller definition is like this this: @Controller()
export default class CalculatorController {
@GET('/api/lorem/ipsum', {
schema: {
headers: {$ref: 'default.authorization.header#'}
},
})
init() { /*some code*/ }
} Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Hi there! I think you can workaround this issue in tests by using describe('Controller: CalculatorController', () => {
let instance: FastifyInstanceWithController<CalculatorController>;
const myService = {someFunction: jest.fn()};
beforeAll(async () => {
instance = await configureControllerTest({
controller: CalculatorController,
mocks: [
{
provide: MyService,
useValue: myService,
},
],
plugins: [
(instance) => instance.addSchema(authorizationHeaderSchema)
]
});
});
}); If this schema comming from another plugin then you can replace this "self written plugin" with actual one |
Beta Was this translation helpful? Give feedback.
Hi there!
I think you can workaround this issue in tests by using
plugins
option. Something like this I guessIf this schema comming from another plugin then you can replace this "self written plugi…