Skip to content

Bazel + Jest: Dynamic location for jest-junit's xml file #167

@tidefield

Description

@tidefield

As mentioned in #34 (comment), when we run jest with Bazel, the tests are run in a test sandbox and the directory to the sandbox is not deterministic until the execution phase.

When bazel runs jest, bazel writes test.xml differently from jest-junit. test.xml (generated by bazel) is in written in
/private/var/tmp/[computer_name]/[unconsistent_hash]/execroot/[workspace_name]/bazel-out/darwin-fastbuild/testlogs/package_name/jest/test.log while jest-junit writes to a folder defined by the config or JEST_JUNIT_OUTPUT_DIR env var.

The path to the testlogs (e.g. XML_OUTPUT_FILE) isn't defined until jest is executed by bazel. So we don't know the value to pass in JEST_JUNIT_OUTPUT_DIR or the config statically.

It would be great if we can pass in a global variable name for jest-junit to look at runtime. Something like

"jest-junit": {
  "outputName": "env_var:JEST_JUNIT_OUTPUT_DIR"
}

I'm happy to put up a PR for the proposed feature if you think it's a good idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions