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

Configuration file equivalent for --passWithNoTests flag #8896

Open
astorije opened this issue Aug 30, 2019 · 21 comments
Open

Configuration file equivalent for --passWithNoTests flag #8896

astorije opened this issue Aug 30, 2019 · 21 comments

Comments

@astorije
Copy link

🚀 Feature Proposal

Add a passWithNoTests boolean support in the configuration file, to have the same effect as the --passWithNoTests CLI flag.

Motivation

We currently use a shared configuration file across our organization, so that every repo running Jest will have the same default configuration (we do the same for Prettier, TSLint, Webpack, etc.). This ensures consistency, avoids surprises, and lets our teams have a sort of internal "zero conf" set up with the preferences/settings of the engineering organization.

This works really well with Jest, except we are now adding --passWithNoTests to all our new repos, where a configuration file equivalent would let us do it once.

Example

In jest.config.js (if using the JS format):

module.exports = {
  preset: 'ts-jest',
  moduleFileExtensions: ['ts', 'tsx', 'js'],
  globals: { 'ts-jest': { tsConfig: 'tsconfig.json' } },
  testMatch: ['**/test/**/*.test.(ts|tsx)'],
  // ...
  passWithNoTests: true,
};
@Mark1626
Copy link
Contributor

Mark1626 commented Sep 3, 2019

@SimenB I can pick this up, if this feature is needed

@celiamarshall
Copy link

celiamarshall commented Jan 11, 2020

Will this be added? @M4rk9696 Thanks!

@eladchen
Copy link

So... That is not going to happen?

@risen228
Copy link

Any progress?

@bluelovers
Copy link

need this

@pisharodySrikanth
Copy link

+1

7 similar comments
@theomessin
Copy link

+1

@sagiBarkol
Copy link

+1

@ronaldndirangu
Copy link

+1

@humoyun91
Copy link

+1

@noahvarghese
Copy link

+1

@mattsears18
Copy link

+1

@Mikuu
Copy link

Mikuu commented Jan 25, 2022

+1

@fguitton
Copy link

Isn't this something which was addressed in Jest 22 in #4639 ?
You can even read:

This is a weird requirement to get CLI flags to pass through
Originally posted by @SimenB in #4639 (comment)

A quick test in Jest 27 just now seems to show this working properly.
This is via config file, CLI single --config argument, or separate arguments:

$> jest --version
27.4.7

$> jest
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In \repos\project
  14 files checked.
  testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)'] - 0 matches
  testPathIgnorePatterns: \\node_modules\\ - 14 matches
  testRegex:  - 0 matches
Pattern:  - 0 matches


$> jest --config='{\"testMatch\":[\"*.js\"]}'
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In \repos\project
  14 files checked.
  testMatch: *.js - 0 matches
  testPathIgnorePatterns: \\node_modules\\ - 14 matches
  testRegex:  - 0 matches
Pattern:  - 0 matches


$> jest --config='{\"testMatch\":[\"*.js\"]}' --passWithNoTests
No tests found, exiting with code 0

$> jest --config='{\"testMatch\":[\"*.js\"],\"passWithNoTests\":true}'
No tests found, exiting with code 0

$> echo '{"testMatch": ["*.js"],"passWithNoTests": true}' > jest.config.json && jest
No tests found, exiting with code 0

$> echo '{"testMatch": ["*.js"]}' > jest.config.json && jest
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In \repos\project
  14 files checked.
  testMatch: *.js - 0 matches
  testPathIgnorePatterns: \\node_modules\\ - 14 matches
  testRegex:  - 0 matches
Pattern:  - 0 matches

Am I missing something ?

@mikemaccana
Copy link
Contributor

mikemaccana commented May 17, 2022

Quoting:

$> jest --config='{\"testMatch\":[\"*.js\"],\"passWithNoTests\":true}'
No tests found, exiting with code 0

Hrm odd, actually using a config file with passWithNoTests: true, fails with:

 FAIL  src/index.test.ts
  ● Test suite failed to run

    Your test suite must contain at least one test.

$ npx jest --version
27.5.1

@LeonardoRick
Copy link

Needing this too!

@kafir-coder
Copy link

Really needing this too!!!

@Mark1626 any news?

@FrameMuse
Copy link

I mean, I don't know, but I've just tested it and it's working.

image

Before

image

After

image

@moegelin
Copy link

Works for me as well (29.4.3). It seems it was just forgotten to add to the documentation.

Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Feb 24, 2024
@tmtron
Copy link

tmtron commented Feb 25, 2024

+1

@github-actions github-actions bot removed the Stale label Feb 25, 2024
ChALkeR added a commit to ExodusMovement/test that referenced this issue Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests