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

specify custom runner on CLI #5382

Closed
jasonkuhrt opened this issue Jan 24, 2018 · 9 comments
Closed

specify custom runner on CLI #5382

jasonkuhrt opened this issue Jan 24, 2018 · 9 comments

Comments

@jasonkuhrt
Copy link

jasonkuhrt commented Jan 24, 2018

Do you want to request a feature or report a bug?
feature

What is the current behavior?
none

What is the expected behavior?
Be able to specify custom runner on the CLI like yarn jest --runner jest-runner-prettier. The alternative I'm seeing is that I will need to create a new file for prettier and tsc runners (my case) while leaving the main config in package.json used for regular tests. Maybe I'm thinking about this wrong and runner on cli is a bad idea! Not sure.

@jasonkuhrt
Copy link
Author

I see one thing I overlooked is that specifying a different runner opens up different config settings that one would use. In that way its probably not really reasonable to specify various runners on cli all sharing the same config.

@SimenB
Copy link
Member

SimenB commented Jan 24, 2018

@jasonkuhrt
Copy link
Author

Ah! I didn’t note the use case for runners there. Going to try it thanks !

@jasonkuhrt
Copy link
Author

@SimenB I got everything working and its much better. The only issue I see now is that the CLI ``--projects` doesn't appear to do anything e.g.:

❯ yarn jest --projects Prettier
yarn run v1.3.2
$ /Users/jason.kuhrt/projects/ssense/experiment/node_modules/.bin/jest --projects Prettier
Error: Can't find a root directory while resolving a config file path.
Provided path to resolve: Prettier
cwd: /Users/jason.kuhrt/projects/ssense/experiment
    at exports.default (/Users/jason.kuhrt/projects/ssense/experiment/node_modules/jest-config/build/resolve_config_path.js:42:11)
    at readConfig (/Users/jason.kuhrt/projects/ssense/experiment/node_modules/jest-config/build/index.js:76:84)
    at getConfigs (/Users/jason.kuhrt/projects/ssense/experiment/node_modules/jest-cli/build/cli/index.js:229:77)
    at /Users/jason.kuhrt/projects/ssense/experiment/node_modules/jest-cli/build/cli/index.js:71:5
    at Generator.next (<anonymous>)
    at step (/Users/jason.kuhrt/projects/ssense/experiment/node_modules/jest-cli/build/cli/index.js:52:2651)
    at /Users/jason.kuhrt/projects/ssense/experiment/node_modules/jest-cli/build/cli/index.js:52:2881
    at new Promise (<anonymous>)
    at /Users/jason.kuhrt/projects/ssense/experiment/node_modules/jest-cli/build/cli/index.js:52:2562
    at runCLI (/Users/jason.kuhrt/projects/ssense/experiment/node_modules/jest-cli/build/cli/index.js:108:53)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The docs state I just project <project1> ... <projectN>. Does that mean displayName?

@SimenB
Copy link
Member

SimenB commented Jan 26, 2018

Using the CLI option you have to point to a file with configuration - you can't use projects to select a project to run.

Maybe that should be possible, though...

@jasonkuhrt
Copy link
Author

jasonkuhrt commented Jan 26, 2018

Using the CLI option you have to point to a file with configuration

@SimenB why is that explicitly needed? Shouldn't it be picking up the default configuration in my package.json?

  "jest": {
    "projects": [
      {
        "displayName": "Test",
        "mapCoverage": true,
        "transform": {
          "^.+\\.ts$": "ts-jest"
        },
        "testRegex": ".*spec.ts$",
        "moduleFileExtensions": ["ts", "js"],
        "collectCoverageFrom": ["**/source/**/*.ts"]
      },
      {
        "displayName": "TypeScript",
        "runner": "jest-runner-tsc",
        "testPathIgnorePatterns": ["/node_modules/", "/build/"],
        "moduleFileExtensions": ["ts", "tsx"],
        "testMatch": ["<rootDir>/**/*.ts"]
      },
      {
        "displayName": "Prettier",
        "runner": "jest-runner-prettier",
        "testPathIgnorePatterns": ["/node_modules/", "/build/", "coverage"],
        "moduleFileExtensions": [
          "js",
          "jsx",
          "json",
          "ts",
          "tsx",
          "css",
          "less",
          "scss",
          "graphql",
          "md",
          "markdown"
        ],
        "testMatch": [
          "**/*.js",
          "**/*.jsx",
          "**/*.json",
          "**/*.ts",
          "**/*.tsx",
          "**/*.css",
          "**/*.less",
          "**/*.scss",
          "**/*.graphql",
          "**/*.md",
          "**/*.markdown"
        ]
      }
    ]
  }

@SimenB
Copy link
Member

SimenB commented Jan 26, 2018

Being able to use inline config is a new feature (#5176), your use case is a new one. As I already said: "Maybe that should be possible, though..."

@jasonkuhrt
Copy link
Author

jasonkuhrt commented Jan 26, 2018

@SimenB ok I misunderstood you sorry.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants