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

Reporters don't work properly. (output result two times) #616

Closed
6 tasks done
vovsemenv opened this issue Jan 23, 2022 · 13 comments · Fixed by #618 or #659
Closed
6 tasks done

Reporters don't work properly. (output result two times) #616

vovsemenv opened this issue Jan 23, 2022 · 13 comments · Fixed by #618 or #659

Comments

@vovsemenv
Copy link
Contributor

Describe the bug

json and junit reporters double their output in console. when you use output files everything works just fine.
i think its because onFinished hook work twice instead of one(tested it in custom reporter).

i think onFinished don't should be called twhice on a single run

image

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-qtqq9f?file=vite.config.ts

System Info

System:
    OS: macOS 11.6.1
    CPU: (8) arm64 Apple M1
    Memory: 180.38 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.0/bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  Browsers:
    Chrome: 97.0.4692.71
    Firefox: 96.0.2
    Safari: 15.2
  npmPackages:
    @vitejs/plugin-vue: ^2.0.1 => 2.1.0 
    @vitejs/plugin-vue-jsx: ^1.3.3 => 1.3.3 
    vite: ^2.7.13 => 2.7.13 
    vitest: ^0.2.0 => 0.2.0

Used Package Manager

npm

Validations

@robcaldecott
Copy link
Contributor

robcaldecott commented Jan 24, 2022

OMG I was just about to raise this!

Sample repo here: https://github.com/robcaldecott/vitest-multiple-reporters-bug

 RUN  /Users/caldecor/Projects/vitest-multiple-reporters


 RUN  /Users/caldecor/Projects/vitest-multiple-reporters

 √ src/App.test.tsx > renders
 √ src/App.test.tsx > renders

Test Files  1 passed (1)
     Tests  1 passed (1)
      Time  1.95s (in thread 27ms, 7100.09%)


Test Files  1 passed (1)
     Tests  1 passed (1)
      Time  1.95s (in thread 27ms, 7104.01%)

JUNIT report written to /Users/caldecor/Projects/vitest-multiple-reporters/test-results.xml
JUNIT report written to /Users/caldecor/Projects/vitest-multiple-reporters/test-results.xml

@robcaldecott
Copy link
Contributor

My config looks like this:

/// <reference types="vitest" />

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  test: {
    environment: "jsdom",
    reporters: process.env.CI ? ["default", "junit"] : "default",
    outputFile: "./test-results.xml",
  },
});
npm run test:ci

@vovsemenv
Copy link
Contributor Author

Yes, we have problem with output file too, but file rewite himself

@vovsemenv
Copy link
Contributor Author

@antfu @Demivan Its actually dont fixed i get same two times output on @0.2.5
image

@vovsemenv
Copy link
Contributor Author

same with built in reporters

@Demivan
Copy link
Member

Demivan commented Jan 28, 2022

I think #644 broke it again. Need to add a test so it does not happen again.
@vovsemenv can you check it with 0.2.4?

@Demivan Demivan reopened this Jan 28, 2022
@vovsemenv
Copy link
Contributor Author

yep

@vovsemenv
Copy link
Contributor Author

@Demivan
0.2.4 is ok

only 0.2.5 broken

@vovsemenv
Copy link
Contributor Author

bug happens only when you specify reporter as array

@sheremet-va
Copy link
Member

Maybe we should just replace arrays by default and not merge them? We also get duplicates in deps.inline/exclude.

@Demivan
Copy link
Member

Demivan commented Jan 29, 2022

Yeah. We need a separate method and not a deepMerge for this.

@sheremet-va
Copy link
Member

Yeah. We need a separate method and not a deepMerge for this.

deepMerge didn't have this behaviour before. I've added it when we split deepMerge into two for snapshots. I think we can just revert array merging, since nothing depends on it.

@Demivan
Copy link
Member

Demivan commented Jan 29, 2022

Will do that and rename it to mergeConfig or something.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants