Running CRA Jest in non-interactive mode

后端 未结 3 1392
感动是毒
感动是毒 2021-02-02 04:53

Update: my use case is mainly to run tests at CI, but overriding default CRA Jest parameters is something I\'m generally wondering about.


I\'m run

相关标签:
3条回答
  • 2021-02-02 05:39

    You should use Jests --watchAll=false flag.

    eg:

    npm test -- --watchAll=false

    Note: this is for react-scripts > 3.00

    For older versions:

    • react-scripts >= 2.1.4 < 3.00

    For non-ci, eg running tests locally, you can pass a --no-watch flag:

    npm test --no-watch

    • react-scripts <= 2.1.3

    CRA looks for a CI environment variable, if its present it doesn't run in watch mode.

    CI=true npm test should do what you are looking for

    See the User Guide -> Running Tests -> On your own environment

    0 讨论(0)
  • 2021-02-02 05:41

    non-interactive solution:

    npm test a --watchAll=false
    

    or

    yarn test a --watchAll=false
    
    0 讨论(0)
  • 2021-02-02 05:46

    In your package.json scripts:

    "test": "react-scripts test --watchAll=false"

    Or npm test -- --watchAll=false

    Or yarn test --watchAll=false

    Note: the flag used to be called --no-watch in react-scripts < 3.0: https://github.com/facebook/create-react-app/blob/master/CHANGELOG.md#remove---no-watch-flag

    0 讨论(0)
提交回复
热议问题