Skip to content
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

bug: __mocks__ copied to output target #5781

Closed
3 tasks done
mrtnmgs opened this issue May 20, 2024 · 4 comments · Fixed by #5899
Closed
3 tasks done

bug: __mocks__ copied to output target #5781

mrtnmgs opened this issue May 20, 2024 · 4 comments · Fixed by #5899
Labels
Feature: Want this? Upvote it! This PR or Issue may be a great consideration for a future idea.

Comments

@mrtnmgs
Copy link

mrtnmgs commented May 20, 2024

Prerequisites

Stencil Version

4.18.0

Current Behavior

Stencil copies over mocks directories to dist and throws warnings about duplicate mocks.
The mocks are ./src/global/services/__mocks__ and ./src/global/__mocks__
Stencil's console warning:

jest-haste-map: duplicate manual mock found: functions
  The following files share their name; please delete one of them:
    * <rootDir>\src\global\__mocks__\functions.tsx
    * <rootDir>\dist\collection\global\__mocks__\functions.js
    * 
jest-haste-map: duplicate manual mock found: http-service
  The following files share their name; please delete one of them:
    * <rootDir>\src\global\services\__mocks__\http-service.tsx
    * <rootDir>\dist\collection\global\services\__mocks__\http-service.js

I wondered if I wasn't supposed to write the mocks in TypeScript, but same thing with .js files:

jest-haste-map: duplicate manual mock found: functions
  The following files share their name; please delete one of them:
    * <rootDir>\src\global\__mocks__\functions.js
    * <rootDir>\dist\collection\global\__mocks__\functions.js

jest-haste-map: duplicate manual mock found: http-service
  The following files share their name; please delete one of them:
    * <rootDir>\src\global\services\__mocks__\http-service.js
    * <rootDir>\dist\collection\global\services\__mocks__\http-service.js

I couldn't find a config option that would allow to explicitly exclude these directories.

Expected Behavior

__mocks__ directories should be excluded when copying files to build directories

System Info

Windows, npm 9.7.2

Steps to Reproduce

create file src/global/functions.tsx and matching mock src/global/__mocks__/functions.tsx. run npm test.

Code Reproduction URL

https://github.com/mrtnmgs/mockbug

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label May 20, 2024
@alicewriteswrongs
Copy link
Contributor

Hey @mrtnmgs thanks for reporting this, I was just able to confirm that the files in the __mocks__ directory are being copied over. This isn't specific behavior to that directory though - any code in src/ will be copied to the dist output target by Stencil actually. So I think in order to change this behavior we'd need to add an ignore option or something.

I'm going to label this a feature request so we can gauge community interest in such a feature!

@alicewriteswrongs alicewriteswrongs added the Feature: Want this? Upvote it! This PR or Issue may be a great consideration for a future idea. label May 20, 2024
@ionitron-bot ionitron-bot bot removed the triage label May 20, 2024
@mrtnmgs
Copy link
Author

mrtnmgs commented May 20, 2024

Thanks @alicewriteswrongs. That feature sounds nice, but right now things don't work properly by default. There's no reason to copy __mocks__ directories over, and it creates an issue. It doesn't sound right to me to ask the user to configure something in order to fix it... Shouldn't __mocks__ directories be ignored by default?

@mrtnmgs
Copy link
Author

mrtnmgs commented May 22, 2024

Closing as this is part of a larger issue, see #5788

@christian-bromann
Copy link
Member

A fix for this bug has been published in Stencil v4.21.0!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Want this? Upvote it! This PR or Issue may be a great consideration for a future idea.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants