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

test(coverage): improve and simplify tests overall #2482

Merged
merged 1 commit into from Dec 12, 2022

Conversation

AriPerkkio
Copy link
Member

@AriPerkkio AriPerkkio commented Dec 11, 2022

  • Simplifies coverage tests
  • Removes duplicate tests from C8 tests
  • Creates generic tests cases used by both coverage providers. This increases covered functionality of C8 provider.
  • Adds snapshot test for C8 provider. This should increase confidence and prevent from breaking stuff without noticing (e.g. fix: correctly resolve filename, when running code #2439).
  • Reduces package.json scripts mess by using testing.mjs script - idea from vitest/test/css/testing.mjs

I started by debugging what those 12 package.json scripts do and the setup was quite unclear:

scripts run by "npm test" in earlier setup
- 1. pnpm run test:c8
  - 1.1. pnpm run test:thread:c8
    - 1.1.1. pnpm run coverage:thread:c8
      - THREAD=true vitest run --coverage.provider c8
    - 1.1.2. pnpm run coverage-test:c8
      - vitest -c vitest.config-c8-coverage.ts run
  - 1.2. pnpm run test:nothread:c8
    - 1.2.1. pnpm run coverage:c8
      - vitest run --coverage.provider c8
    - 1.2.2. pnpm run coverage-test:c8
      - vitest -c vitest.config-c8-coverage.ts run

- 2. pnpm run test:istanbul
  - 2.1. pnpm run test:thread:istanbul
    - 2.1.1. pnpm run coverage:thread:istanbul
      - THREAD=true vitest run --coverage.provider istanbul
    - 2.1.2. pnpm run coverage-test:istanbul
      - vitest -c vitest.config-istanbul-coverage.ts run
  - 2.2. pnpm run test:nothread:istanbul
    - 2.2.1. pnpm run coverage:istanbul
      - vitest run --coverage.provider istanbul
    - 2.2.2. pnpm run coverage-test:istanbul
      - vitest -c vitest.config-istanbul-coverage.ts run

Ends up running:

- THREAD=true vitest run --coverage.provider c8
- vitest -c vitest.config-c8-coverage.ts run
- vitest run --coverage.provider c8
- vitest -c vitest.config-c8-coverage.ts run

- THREAD=true vitest run --coverage.provider istanbul
- vitest -c vitest.config-istanbul-coverage.ts run
- vitest run --coverage.provider istanbul
- vitest -c vitest.config-istanbul-coverage.ts run

Now there is a simpler setup which should quite clearly indicate what actually happens with npm test.

@AriPerkkio AriPerkkio changed the title test(coverage): improve and simplify coverage tests overall test(coverage): improve and simplify tests overall Dec 11, 2022
@sheremet-va sheremet-va merged commit 6aa6cbd into vitest-dev:main Dec 12, 2022
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.

None yet

2 participants