Skip to content

Comments

fix: prevent duplicating config.test entries#101

Merged
ryansolid merged 1 commit intosolidjs:masterfrom
AriPerkkio:fix/duplicated-config-test
Oct 10, 2023
Merged

fix: prevent duplicating config.test entries#101
ryansolid merged 1 commit intosolidjs:masterfrom
AriPerkkio:fix/duplicated-config-test

Conversation

@AriPerkkio
Copy link
Contributor

Do not duplicate config.test entries on config plugin hook. Vite will merge these and the user provided configurations are duplicated.

Minimal reproduction:

import { defineConfig } from "vitest/config";
import solidPlugin from "vite-plugin-solid";

export default defineConfig({
  plugins: [
    solidPlugin({}),
    {
      name: "log-config",
      enforce: "post",
      config(config) {
        console.log("config.test", config.test);
        console.log("config.esbuild", config.esbuild);
      },
    },
  ],

  esbuild: {
    include: [/\.js$/], // Just to demonstrate that this is also merged automatically
  },

  test: {
    reporters: ["verbose", "hanging-process"],
    coverage: {
      reporter: ["text-summary"],
    },
  },
});

Without fix, see how config.test is duplicated. Also note how config.esbuild is automatically merged even when this plugin does not merge those manually:

config.test {
  reporters: [ 'verbose', 'hanging-process', 'verbose', 'hanging-process' ],
  coverage: { reporter: [ 'text-summary', 'text-summary' ] },
  globals: true,
  environment: 'jsdom',
  transformMode: { web: [ /\.[jt]sx?$/ ] },
  deps: { registerNodeLoader: true }
}
config.esbuild {
  include: [ /\.js$/, /\.ts$/ ],
  sourcemap: 'external',
  legalComments: 'inline'
}

With fix:

config.test {
  reporters: [ 'verbose', 'hanging-process' ],
  coverage: { reporter: [ 'text-summary' ] },
  globals: true,
  environment: 'jsdom',
  transformMode: { web: [ /\.[jt]sx?$/ ] },
  deps: { registerNodeLoader: true }
}
config.esbuild {
  include: [ /\.js$/, /\.ts$/ ],
  sourcemap: 'external',
  legalComments: 'inline'
}

@GitMurf
Copy link

GitMurf commented Aug 30, 2023

Oh my gosh I think I finally found my problem!! This has been driving me nuts for a while now but all my unit tests are running twice when I have the vite solid plugin enabled. @AriPerkkio is this likely the same issue?

Details: when using vitest, whenever I have the vite solid plugin enabled, all my unit tests (whether the tests use solidjs or not) run twice! It is super odd and frustrating that I cannot get to the bottom of it.

See here: #112 (comment)

cc @ryansolid is there any way we can get this PR merged? 🙏 Thanks!

@GitMurf
Copy link

GitMurf commented Oct 12, 2023

Thank you!

@jtmueller
Copy link

This PR definitely caused bug #120

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate text-summary or text coverage report

4 participants