cli icon indicating copy to clipboard operation
cli copied to clipboard

test: introduce `test-vitest-setup` project to handle test setup for vite tests

Open BioPhoton opened this issue 4 months ago • 3 comments

Introduce test-vitest-setup project to handle test setup for vite tests


PR1

  • [x] Introduce project test-vitest-setup under the testing folder and add configuration. Copy the example linked below and add potential improvements.
    • [x] adjust coverage.reportDirectory to be at project root (packages/<name>/.coverage)
    • [x] add unit tests
    • [x] use existing types see this comment
    • [x] add minimal docs to the test-vitest-setup project on how to use

Example implementation:


PR1.2

  • [x] Extend vitest.{targetName}.config.ts from test-vitest-setup configuration. (consider the changed reportDirectory may be a breaking change for the CI pipeline)
    • [x] unit tests
    • [x] int tests
    • [x] e2e tests

PR2.x - Cleanup and cosmetic cahnges

Preconditions: #1142

Mocks folder

  • [ ] Rename nx-plugin/mock to models/mocks
  • [ ] Rename examples/plugins/src/lighthouse/mockto examples/plugins/src/lighthouse/mocks
  • [ ] After all folders are renamed to mocks adjust inputs in nx.json
    • "!{projectRoot}/@(test|mocks|mock)/**/*"
    • "!{projectRoot}/**/?(*.)mock.[jt]s?(x)"

Mocks creation

  • [ ] unify test folder setup and document it. Use the creation from static files instead of generator
    • e2e/ci-e2e/setup.ts#setupTestReop
    • e2e/ci-e2e/test-folder-setup.ts#restoreNxIgnoredFiles

Test Coverage

  • [ ] improve test coverage config to exclude as much noise as possible and increase coverage
    • src/lib/index.ts - exclude files that only maintain exports e.g. index.ts (in some places index.ts files also contain actual logic. here I would suggest we discuss per case if we can refactor to have all index.ts used for barrel export only)
    • exclude other files that are not relevant for test coverage

Caching

  • [ ] Move zod2md.ts under {projectRoot}/tools and make sure "!{projectRoot}/tools/**/*" is added under nx.json#namedInputs.production
  • [ ] remove vitest executor defaults from nx.json in favour of target name as they are conflicting and only one of them wins.
 "e2e": {
      "cache": true,
      "inputs": ["default", "test-vitest-inputs"],
      "dependsOn": ["^build"]
  },
  "@nx/vite:test": {
    "cache": true,
    "inputs": ["default", "test-vitest-inputs"],
    "options": {
      "passWithNoTests": true,
      "watch": false
    }
  },
  • [ ] To verify: We might have a caching issue with models build.

To Verify

BioPhoton avatar Aug 13 '25 19:08 BioPhoton

@BioPhoton PR1 and PR1.2 are covered ~~and at the moment awaiting for your approval.~~

I'm happy to do next step which is PR2 but I'd need more context what is the actual goal of that

poltorak avatar Nov 05 '25 11:11 poltorak

Thx @poltorak for the headsup! Feel free to check the boxes in the issue and link PRs. I will be able to add more information to PR2 until Friday-

BioPhoton avatar Nov 10 '25 11:11 BioPhoton

Sorry it took a while, notification got lost somewhere

poltorak avatar Nov 18 '25 14:11 poltorak

moved other tasks in #1168

BioPhoton avatar Dec 04 '25 22:12 BioPhoton