Skip to content

[v3] Automatically inherit common test config in inline projects #7225

Description

@silvenon

Clear and concise description of the problem

Project configurations can be repetitive, it would be nice for us and for Vitest to have a clear path towards defining what is common and what is specific to that project in one place. Inline projects are a great tool for that, I'm so thankful they made it into Vitest.

However, extending doesn't quite work as I expected, here I expected the project to inherit globals: true:

{
  test: {
    globals: true,
    workspace: [
      {
        test: {
          name: "node",
          environment: "node",
        },
      },
    ],
  },
}

because otherwise any config defined at the root test is a noop when workspace exists, right?

Next I tried setting extends: true on the project to get it to work, but it didn't. I don't really know what it does by default, I suppose it's looking up the directory tree.

What did work was configuring extends: "./vitest.config.ts".

Suggested solution

I would like not having to configure extends on projects, I would like inheritance to just happen. If that makes sense for the direction of v3.

Alternative

Type definitions could be altered in a way that prohibits noop root configs in case workspace is defined, using a discriminated union.

Additional context

No response

Validations

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-nice-to-haveNot breaking anything but nice to have (priority)

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Sponsor
    SponsoredKunjungi sekarang
    Promo