-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The Sociable API fails to function when class constructor is left empty of params #509
Comments
Hey @kostyazgara I reviewed the example repository. I’ve added an additional class named import { Injectable } from '@nestjs/common';
import { FooClass } from './foo-class';
@Injectable()
export class TestSociableService {
public constructor(private readonly foo: FooClass) {}
public return(): boolean {
return true;
}
} This is the spec (test) file: describe('Test', () => {
let testDependService: Mocked<TestDependService>;
let underTest: TestService;
beforeAll(async () => {
const { unit, unitRef } = await TestBed.sociable(TestService)
.expose(TestSociableService)
.compile();
underTest = unit;
testDependService = unitRef.get(TestDependService);
underTest.test();
});
it('should expose sociable service',() => {
expect(testDependService.call).toHaveBeenCalledWith(true);
});
}) When I include import { Injectable } from '@nestjs/common';
import { FooClass } from './foo-class';
@Injectable()
export class TestSociableService {
// When I remove the constructor param, the test fails
public constructor(private readonly foo: FooClass) {}
public return(): boolean {
return true;
}
} We will investigate this further, as it appears to be an edge case. I will provide an update soon, although it may take some time to resolve. Thank you for posting this 🙏🏻 |
Released in |
Is there an existing issue for this?
Current behavior
The new Sociable API is not working properly. I tried to setup a minimal reproducible example in my repo.
Minimum reproduction code
https://github.com/KostyaZgara/suites-expose-reproduce
Steps to reproduce
npm i
npm run test-ts
ornpm run test-swc
Expected behavior
return
method should not be mocked when exposing the class TestSociableService using.expose()
API in sociable test. I'm expecting to have success assert checkexpect(testDependService.call).toHaveBeenCalledWith(true)
Suites version
"@suites/di.nestjs": "3.0.0", "@suites/doubles.jest": "3.0.0", "@suites/unit": "3.0.0",
Node.js version
20.11.1
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: