Giter Club home page Giter Club logo

Comments (4)

tobysmith568 avatar tobysmith568 commented on August 16, 2024 1

When working with an Nx monorepo you don't call the Jest CLI yourself. Instead you call the Nx CLI and it starts multiple Jest processes at once, one for each of the packages in your monorepo.

By default all of these Jest processes share a single Jest base config file, and therefore share a single jest-junit configuration too, meaning their file names can't be hard-coded into their config. That's why I'd like the ability to interpolate the Jest display name into the file name.

If you include jest-junit in an Nx monorepo with its default config in the Jest base config then you get N number of Jest processes all start at once with the same jest-junit config, all writing to the same output file. All 15 processes write to the file ./junit.xml and overwrite each other. You're left with a single file that only contains the output from the longest running process.

Right now I have a jest-junit config that looks something like:

reporters: [
  "default",
  [
    "jest-junit",
    {
      suiteName: "<name of my monorepo>",
      suiteNameTemplate: "{filepath}",
      uniqueOutputName: "true",
      outputName: "junit",
      outputDirectory: "reports"
    }
  ]
]

This is pretty good, I end up with N number of files in a reports directory but there's no way to tie them back to the library in the monorepo that they came from - the names are just random.

I think it would be ideal if a monorepo with a structure like

jest.base.ts
libs/
    project-one/
        package.json
        src/
            index.ts
        test/
            index.spec.ts
    project-two/
        package.json
        src/
            index.ts
        test/
            index.spec.ts

was able to produce a reports directory like

reports/
    project-one-junit.xml
    project-two-junit.xml

Which is what interpolating the display name into the file name would give me.

Does that help explain my situation?
Let me know if you have more questions :)

from jest-junit.

palmerj3 avatar palmerj3 commented on August 16, 2024

Hey!

I like the idea but I'm not sure if it would work in practice.
displayName is used to signify different jest projects, but the jest runner will also run them all by default.

So if multiple jest projects are run then it would get confusing and possibly unpredictable what the filename would be.

from jest-junit.

palmerj3 avatar palmerj3 commented on August 16, 2024

Hey thanks that helps a lot.

My main point in bringing this up is that most of the people who rely on jest-junit don't have that structure. So if you add the feature make sure to make a note in the docs that this is only for situations where jest projects are run independently.

from jest-junit.

tobysmith568 avatar tobysmith568 commented on August 16, 2024

Great yeah OK, can do :)

from jest-junit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.