Skip to content

bug: __mocks__ copied to output target #5781

@mrtnmgs

Description

@mrtnmgs

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature: Want this? Upvote it!This PR or Issue may be a great consideration for a future idea.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions