You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
The @suites/unit package does not export the Mocked type as expected. When trying to import the Mocked type from @suites/unit using:
import{TestBed,Mocked}from'@suites/unit';
I receive the following error message:
Module '"@suites/unit"' has no exported member named 'Mocked'.
Minimum reproduction code
no
Steps to reproduce
No response
Expected behavior
Please include the Mocked type in the package's exports, or provide documentation for an alternative way to mock objects if the Mocked type has been deprecated or replaced.
Suites version
3.0.0
Node.js version
20.16.0
In which operating systems have you tested?
macOS
Windows
Linux
Other
No response
Reacted by John Patrick Tobias, Roni Avidov and ₿igto
Try importing Mocked from @suites/doubles.x instead of @suites/unit. (In this case, @suites/doubles.jest).
importtype{Mocked}from'@suites/doubles.jest';
This is a workaround; in order to maintain consistency and library agnostic behavior (mocking library), the Mocked type should essentially be imported from @suites/unit. You may easily modify it back to be imported from @suites/unit after the bug has been fixed.
It works out of the box as expected, but after installing an additional package (e.g yarn add get-port), for some reason, the following is missing:
in /node_modules/@suites/unit/dist/cjs/index.d.ts
Is missing: /// <reference types="@suites/doubles.jest/unit" />
The same triple slash is missing in node_modules/@suites/unit/dist/esm/index.d.ts
Manually adding that to the d.ts file fixes the problem.
I've also noticed that the following is missing from node_modules/@suites/types.di/typings.d.ts, which is export type IdentifierMetadata = import('@suites/di.nestjs').IdentifierMetadata;
Digging through the code, these are all added via post-install scripts of doubles.x and di.x. It looks like the fault is yarn for not running post-install script. this isn't happening in npm for example.
Activity
omermorad commentedon Sep 8, 2024
Hi,
Thank you for submitting this issue. I'll take a look and update here soon!
roniavi commentedon Sep 23, 2024
Plus one on this @omermorad 🙏
qballer commentedon Sep 27, 2024
I will look into this issue in October and try and solve it.
omermorad commentedon Sep 29, 2024
@roniavi @michaelcai - While @qballer works to resolve this problem, please try the following workaround:
Try importing
Mockedfrom@suites/doubles.xinstead of@suites/unit. (In this case,@suites/doubles.jest).This is a workaround; in order to maintain consistency and library agnostic behavior (mocking library), the
Mockedtype should essentially be imported from@suites/unit. You may easily modify it back to be imported from@suites/unitafter the bug has been fixed.Tell me whether it was successful please :)
qballer commentedon Oct 2, 2024
https://github.com/qballer/suites_issue_426
I was able to reconstruct the bug in the above repo relatively easily. I will dig into why this is happening later.
[-] `Mocked` type is missing in '@suites/unit'[/-][+] `Mocked` type is missing in `@suites/unit`[/+]qballer commentedon Oct 4, 2024
I reconstructed the bug in the exact way described in the issue.
https://github.com/qballer/suites_issue_426
It works out of the box as expected, but after installing an additional package (e.g
yarn add get-port), for some reason, the following is missing:in
/node_modules/@suites/unit/dist/cjs/index.d.tsIs missing:
/// <reference types="@suites/doubles.jest/unit" />The same triple slash is missing in
node_modules/@suites/unit/dist/esm/index.d.tsManually adding that to the d.ts file fixes the problem.
I've also noticed that the following is missing from
node_modules/@suites/types.di/typings.d.ts, which isexport type IdentifierMetadata = import('@suites/di.nestjs').IdentifierMetadata;Digging through the code, these are all added via post-install scripts of
doubles.xanddi.x. It looks like the fault is yarn for not running post-install script. this isn't happening in npm for example.Which yarn version is being used?
yarnpkg/yarn#5476
[Questions] Use Hexagonal Architecture (#21)
omermorad commentedon Oct 9, 2024
@michaelcai @jeffrey-jian @roniavi (also related to #439 - @mbrunoviegas)
Due to a known issue with Yarn v1.x's
postinstallscript handling (yarnpkg/yarn#5476), an extra step is required to set up reference types for your project. I've updated the docs, please follow: https://suites.dev/docs/overview/installation#for-yarn-v1x-users.Please, let me know if it worked for you.