Is there an option to show all test descriptions when I run jest tests?

前端 未结 5 1528
伪装坚强ぢ
伪装坚强ぢ 2021-01-31 01:18

I\'m using jest and enzyme with my create-react-app project. When I run npm test, I get an output that shows the names of the test files that passed but I\'d like t

相关标签:
5条回答
  • 2021-01-31 01:36

    Note that, instead of

    jest --verbose
    

    you can also set verbose to true in jest.config.js:

    // jest.config.js
    module.exports = {
      ...
      verbose: true,
    }
    
    0 讨论(0)
  • 2021-01-31 01:40

    The --verbose flag sounds like it might do what you are looking for. According to the docs, it displays individual test results.

    0 讨论(0)
  • 2021-01-31 01:40

    after doing this configuration in package.json( "test": "react-scripts test --env=jsdom --verbose",) try running your test by npm test.

    Note : with npm run test description is not reflecting for me as well.

    0 讨论(0)
  • 2021-01-31 01:41

    I was having the same issue with create-react-app (using both jest and enzyme), but was able to get the tests to appear after appending the existing test script in package.json with --verbose=true. So it now appears "test": "react-scripts test --env=jsdom --verbose=true"

    0 讨论(0)
  • 2021-01-31 01:47

    From Jest's command-line options docs

    --verbose

    Display individual test results with the test suite hierarchy.

    So running

    jest --verbose
    

    Will print all the names in describe, it, test blocks.
    If you're running tests with yarn, you can do

    yarn test --verbose
    

    If you're running tests with npm, you can do

    npm test -- --verbose
    

    If you want to make this default, change your test script in package.json

    "test": "react-scripts test --env=jsdom --verbose",
    

    Now both yarn test and npm test should show all test names.

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