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

Use --selectProjects option with Jest #272

Closed
mstelz opened this issue Mar 25, 2021 · 2 comments
Closed

Use --selectProjects option with Jest #272

mstelz opened this issue Mar 25, 2021 · 2 comments

Comments

@mstelz
Copy link

mstelz commented Mar 25, 2021

Using Craco I am attempting to utilize the Jest's selectProjects cli option to invoke a specific defined project within the configuration.

Using this as the craco.config.js

module.exports = {
  jest: {
    configure: {
      projects: [
        {
          name: "unit",
          displayName: "unit",
          testMatch: ["<rootDir>/**/*.test.*"],
        },
        {
          name: "playwright",
          displayName: "playwright",
          testMatch: ["<rootDir>/**/*.uitest.*"],
        },
      ],
      globals: {
        CONFIG: true,
      },
    },
  },
};

And then in my package.json I am defining the following scripts:

{
  ...
    "test": "craco test --watchAll=false --coverage --json --selectProjects unit",
    "test:ui": "craco test --watchAll=false --coverage --json --selectProjects playwright --showConfig"
  ...
}

But it appears it cannot find a configuration as it throws the following error:

Error: Jest: Cannot use configuration as an object without a file path.
at readConfig (/Users/mstelze/Git/react-example/node_modules/jest-config/build/index.js:188:13)
at /Users/mstelze/Git/react-example/node_modules/jest-config/build/index.js:447:18
at Array.map ()
at readConfigs (/Users/mstelze/Git/react-example/node_modules/jest-config/build/index.js:441:10)
at async runCLI (/Users/mstelze/Git/react-example/node_modules/@jest/core/build/cli/index.js:230:59)
at async Object.run (/Users/mstelze/Git/react-example/node_modules/jest-cli/build/cli/index.js:163:37)

Any thoughts? Am I missing something in the configuration or is this function not supported?

@stale
Copy link

stale bot commented Jun 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 2, 2021
@stale stale bot closed this as completed Jun 9, 2021
@bluSCALE4
Copy link

bluSCALE4 commented Dec 8, 2021

I tracked the error to configPath | parentConfigPath returning as null. Not sure this is happening but it's definitely the cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants