Skip to content

Apply appropriate configs for different tests ran as different projects #7268

Description

@deser

Hi Guys.
Seems projects doesn't work as intended. I have jest config which is intended to run all my type of tests:

module.exports = {
    projects: ['./jest.config.ui.js', './jest.config.unit.js']
};

It is impossible that file of unit tests would be grabbed by ui tests, see regex:
ui: testRegex: '/__tests__/.*-test\\.js?$',
unit: testMatch: ['**/__tests__/**/?(*.)+(spec).js']

These ui and unit configs have different setups. For example for ui tests I need to resolve all css files successfully, I do this via:

 moduleNameMapper: {
        '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
            './resources/__mocks__/fileMock.js',
        '\\.(css|sass|scss|less)$': 'identity-obj-proxy'
    },

unit tests config doesn't have this setup.

So, when I run ui and unit tests separately - all good.
When I try to run all tests config - I see that moduleNameMapper doesn't work for ui tests.

3

In total, expected behaviour:
File which is found for UI test should be executed with the help of appropriate config.

UPD: DEMO
To see behavior please clone repo https://github.com/deser/jest_issue-7268 and follow steps in README.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions