Skip to content

Mocked type is missing in @suites/unit #426

Closed

Description

@michaelcai

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

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

Activity

  1. omermorad commented on Sep 8, 2024

    @omermorad
    Collaborator

    Hi,

    Thank you for submitting this issue. I'll take a look and update here soon!

  2. roniavi commented on Sep 23, 2024

    @roniavi

    Plus one on this @omermorad 🙏

  3. qballer commented on Sep 27, 2024

    @qballer
    Collaborator

    I will look into this issue in October and try and solve it.

  4. self-assigned this
    on Sep 27, 2024
  5. omermorad commented on Sep 29, 2024

    @omermorad
    Collaborator

    @roniavi @michaelcai - While @qballer works to resolve this problem, please try the following workaround:

    Try importing Mocked from @suites/doubles.x instead of @suites/unit. (In this case, @suites/doubles.jest).

    import type { 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.

    Tell me whether it was successful please :)

  6. qballer commented on Oct 2, 2024

    @qballer
    Collaborator

    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.

  7. changed the title [-] `Mocked` type is missing in '@suites/unit'[/-] [+] `Mocked` type is missing in `@suites/unit`[/+] on Oct 4, 2024
  8. qballer commented on Oct 4, 2024

    @qballer
    Collaborator

    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.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.

    Which yarn version is being used?

    yarnpkg/yarn#5476

  9. deleted a comment from qballer on Oct 9, 2024
  10. omermorad commented on Oct 9, 2024

    @omermorad
    Collaborator

    @michaelcai @jeffrey-jian @roniavi (also related to #439 - @mbrunoviegas)

    Due to a known issue with Yarn v1.x's postinstall script 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.

  11. locked and limited conversation to collaborators on Oct 18, 2024
  12. converted this issue into a discussion #473 on Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghacktoberfestHacktoberfest

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions