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

[allure-jest] Test start time is incorrect, which leads to incorrect test duration #1002

Open
maks-rafalko opened this issue Jun 11, 2024 · 1 comment
Assignees
Labels
theme:jest Jest related issue

Comments

@maks-rafalko
Copy link

Describe the bug

We are using v2.15.1 and this version incorrectly calculates tests' start time, which leads to incorrectly calculated Duration time on allure report UI.

The instance of AllureTest is created here on Jest's add_test event:

this.handleTestAdd({
testName: event.testName,
concurrent: event.concurrent,
state,

Then, we set time to test.testResult.start:

The root of the bug is that we should save start time on test_start event, not on add_test. Here:

case "test_start":
this.handleTestStart(event.test);
break;

add_test event occures for all the tests cases of the fille at the same time, so this is simply not a correct event to save start time of the test..

To Reproduce

  1. Create a test file with N tests, let's say N=5
  2. in each test() case, add for example sleep for 3 seconds
  3. Result - duration of the test N1 will be 3 seconds, duration of the test N2 will be 6 seconds, of the test N3 9 seconds and so on

Expected behavior

  1. Create a test file with N tests, let's say N=5
  2. in each test() case, add for example sleep for 3 seconds
  3. Result - duration of the test N1 will be 3 seconds, duration of the test N2 will be 3 seconds, of the test N3 3 seconds and so on

Screenshots

Before:

image

After adding a fix:

image


The fix is pretty simple, we just need to save test.testResult.start time somewere here on test_start event:

currentTest.stage = Stage.RUNNING;

If you agree, I can try to provide a PR.

@baev
Copy link
Member

baev commented Jun 11, 2024

Could you please re-check the issue using the latest 3.0.0-beta.3 release? All the integrations were revisited (& reworked) recently, we're about to release 3.0.0. If the issue still occurs, we'll be happy to fix it

@baev baev added the theme:jest Jest related issue label Jun 27, 2024
@epszaw epszaw self-assigned this Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:jest Jest related issue
Projects
None yet
Development

No branches or pull requests

3 participants