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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

slowTestThreshold measuring test suite time, not individual test time #10945

Closed
tralston opened this issue Dec 13, 2020 · 5 comments
Closed

slowTestThreshold measuring test suite time, not individual test time #10945

tralston opened this issue Dec 13, 2020 · 5 comments

Comments

@tralston
Copy link

馃悰 Bug Report

@SimenB Thanks for the slowTestThreshold option in #9366. I'm trying it out, but it seems to be only applying to a test suite, not individual tests. The docs say "test", so I was assuming an individual it or test function is what it's measuring. In this setup, package.json specifies:

"jest": {
    "testEnvironment": "node",
    "globalSetup": "./global.setup.js",
    "setupFilesAfterEnv": [
      "./jest.setup.js"
    ],
    "verbose": true,
    "collectCoverageFrom": [
      "src/*.js"
    ],
    "snapshotSerializers": [
      "jest-snapshots-json-rest-api"
    ],
    "slowTestThreshold": 2
  }

Screenshots:

image

Three tests run in this one test suite, all were < 1000 ms (slowTestThreshold = 2), so each test was nice and fast. There was some test suite overhead, which pushed the suite over 2 seconds, which is why it's showing as slow. That's fine, but I'd also like to see if the individual tests are slow. See next image.

image

I know my overall test suite here is super long, that's why I'm hoping to use slowTestThreshold to work on my longer tests incrementally. As you can see, the arrow points to a test that is 2202 ms long, but nothing distinguishes that row from the rest. Only the test suite time is flagged as slow (55.193 s in this case).

To Reproduce

How to reproduce:

  1. Create a test file in a new repo, add a test that goes longer than 1 sec (say a supertest request, or sorting a huge array)
  2. Run npx jest in that repo
  3. See output (see screenshots).

I can't share my code due to confidentiality. But the timing is accurate, and you'll see what I mean in the screenshots.

Expected behavior

I expect that each individual test that is longer than the slowTestThreshold setting in package.json will show that result as slow, not just the test suite as slow. In other words, I want to see all the slow tests highlighted somehow in the runner printout.

Link to repl or repo (highly encouraged)

envinfo

  System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
  Binaries:
    Node: 12.14.0 - ~/.nvm/versions/node/v12.14.0/bin/node
    npm: 6.13.4 - ~/.nvm/versions/node/v12.14.0/bin/npm
  npmPackages:
    jest: ^26.6.3 => 26.6.3
@stdavis
Copy link
Contributor

stdavis commented Dec 22, 2020

Here's a repo for this issue: https://repl.it/@stdavis/jest-repo-for-10945#slow.test.js
image

@tralston
Copy link
Author

Thanks @stdavis

@github-actions
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 17, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2023
@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 Apr 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants