[ ] Regression
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
This is based on the 01-cats example cats create with sequelize, when executing a unit test in related the cats controller, it seems the Validation pipe is ignored, as well as a error is shown "Model not initialized".
When the test in related to trigger the validation should show the validation error message, as well as the create unit test should insert the data
https://github.com/opiuq/unittest-nestjs-cats-app-help
It would be great to have a reference on the docs on how to run unit test on pipes as we as controllers which are dependent on model's.
Nest version: 4.3.0
This is not a bug. Unit testing is useful for testing classes without any bounded dynamic metadata (in this case, without pipes). You shouldn't test pipe logic inside your controller .spec
files. 馃檪
@kamilmysliwiec righty looks like my mistake, thanks for the clarification
@kamilmysliwiec, hi.
Can you show some examples(may be link?) for e2e test for controller with Pipe(), which makes external requests
I mean whether it is possible to somehow change(replace) the pipe through the DI ?
@kamilmysliwiec, hi.
Can you show some examples(may be link?) for e2e test for controller with Pipe(), which makes external requests
I mean whether it is possible to somehow change(replace) the pipe through the DI ?
This is how I mock pipe.
const mockSomeService = () => ({
create: jest.fn(),
});
const mockSomePipe = jest.fn();
const module = await Test.createTestingModule({
providers: [
SomeResolver,
{
provide: SomeService,
useFactory: mockSomeService,
},
],
})
.overridePipe(SomePipe)
.useValue(mockSomePipe)
.compile();
Most helpful comment
This is not a bug. Unit testing is useful for testing classes without any bounded dynamic metadata (in this case, without pipes). You shouldn't test pipe logic inside your controller
.spec
files. 馃檪