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

testResultsProcessor and multi-project #4406

Closed
palmerj3 opened this issue Sep 1, 2017 · 7 comments · Fixed by #4408
Closed

testResultsProcessor and multi-project #4406

palmerj3 opened this issue Sep 1, 2017 · 7 comments · Fixed by #4408

Comments

@palmerj3
Copy link
Contributor

palmerj3 commented Sep 1, 2017

Do you want to request a feature or report a bug?

Feature

What is the current behavior?

If the same testResultsProcessor is used for all projects then the resulting JSON data does not provide any reference to what project a particular suite/test belongs to.

I have created a sample project which shows the output that a testResultsProcessor receives in a jest multi-project environment as of now.

https://github.com/palmerj3/jest-multi-project-testResultProcessor

You can see the output here.

What is the expected behavior?

I would like it if jest updated the JSON results that are sent to testResultsProcessor so a "project" variable is available indicating the "rootDir" of the project the test/suite is associated with.

I propose that jest adds a new variable to the posted results that associates a test suite with a jest project. E.g.

  "testResults": [
    {
      project: "/home/travis/build/palmerj3/jest-multi-project-testResultProcessor/p1/"
    }]

The project path would be the directory that contains the jest.config.js file and/or package.json file that defines a given jest project.

This would give testResultsProcessors the ability to more easily provide multiple outputs per project. In the case of jest-junit (a project I maintain) I would like to be able to generate a junit.xml file for unit tests and integration tests for projects that I use this on.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

Jest: v20.0.4
Yarn: 0.27.5
Node: v8.4.0

@cpojer
Copy link
Member

cpojer commented Sep 1, 2017

Oh yeah, that's missing. @rogeliog just added a displayName field to ProjectConfig. Do you wanna thread it all the way through to the AggregatedTestResult and send a PR?

@palmerj3
Copy link
Contributor Author

palmerj3 commented Sep 1, 2017

@cpojer sure that sounds reasonable - I'll give it a shot. Thanks!

One thing though... if someone does not specify a displayName for multiple projects then I'm still left with no precise way to differentiate what tests belong to what project.

Is it also reasonable to pass along the project base dir to the testResultsProcessor for each test suite?

@cpojer
Copy link
Member

cpojer commented Sep 1, 2017

I think it's reasonable to expect the displayName to be there, or are you talking about the use case where you are not in control of your packages?

@palmerj3
Copy link
Contributor Author

palmerj3 commented Sep 1, 2017

Just thinking of edge cases since displayName is not a required field.

I'll work on the PR for bringing displayName to the aggregated results.

@palmerj3
Copy link
Contributor Author

palmerj3 commented Sep 1, 2017

@cpojer I put together a PR which seems to fit the requirements. #4408

@cpojer
Copy link
Member

cpojer commented Sep 1, 2017

Cool, closing this one now.

@cpojer cpojer closed this as completed Sep 1, 2017
@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 May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants