moleculer-template-project-typescript
moleculer-template-project-typescript copied to clipboard
Default tests are not working
Hi,
after generating the project with project-typescript
template and running npm run test
I'm getting errors. Most of them I managed to solve as they were just syntax issues, but one bothers me and I can't figure out what's the problem.
FAIL test/unit/services/products.spec.ts
● Test 'products' service › Test hooks › Test before 'create' hook › should add quantity with zero
expect(jest.fn()).toBeCalledTimes(expected)
Expected number of calls: 1
Received number of calls: 0
179 | });
180 |
> 181 | expect(createActionFn).toBeCalledTimes(1);
| ^
182 | expect(createActionFn.mock.calls[0][0].params).toEqual({
183 | id: "111",
184 | name: "Test product",
at test/unit/services/products.spec.ts:181:32
at fulfilled (test/unit/services/products.spec.ts:5:58)
When I debug it, the method is called with corect values. But when testing it says it's not. I was also trying to debug the parseServiceSchema
and I can't find there where the hooks are applied to the service so I can't really test if the mock function is correctly assigned. Any idea what is the solution?
I see your problem like #35 I was fix it with PR #36 Can you confirm it?
using last version.
which latest version
my tests are not also passing and am getting hard time to fix it
@bashiru98 what's the error that you're getting?
I've done a fresh install and got one like this:
I'm not a TS guy but I think it's related to the https://github.com/moleculerjs/moleculer/pull/980
@AndreMaz yes, I believe that issue should be fixed by the referenced PR.
@AndreMaz I go reinstall and try, but the moleculerjs/moleculer#980 not resolve it
@AndreMaz I go reinstall and try, but the moleculerjs/moleculer#980 not resolve it
I'm guessing that moleculerjs/moleculer#980 isn't working here because the tsconfig
in this repo doesn't appear to have noImplicitThis
set to true. The ThisType
utility type requires that to be turned on in order to function.
@shawnmcknight it's work :)
@bashiru98 what's the error that you're getting?
I've done a fresh install and got one like this:
I'm not a TS guy but I think it's related to the moleculerjs/moleculer#980
exactly same error
I think its a TS config error
Guys about the uncovered lines how do we solve it