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

Add vinxi test #174

Open
atk opened this issue Jan 30, 2024 · 2 comments
Open

Add vinxi test #174

atk opened this issue Jan 30, 2024 · 2 comments

Comments

@atk
Copy link

atk commented Jan 30, 2024

Currently, testing needs to be set up manually, since we use the vite config for our own configuration, which does not really work with vitest. It would also be useful to be able to configure which parts of the system should be available during testing (static assets, ssr, client, etc.). In order to do this, we should also wrap vitest (as the preferred way to test vinxi apps and optional peer dependency) in a vinxi test cli functionality.

@nksaraf
Copy link
Owner

nksaraf commented Feb 2, 2024

Yeah okay let me put my ideas down and I think I probably need your help sifting through them.

Approach 1:

I expose a vinxi test command that knows how to run vitest tests and maybe playwright tests for integration testing. Will probably need to figure out how the file can tell us which env it needs to run in. Because the difference is not just vitest/playwright, its also server/client, etc. So a specific test file should annotate itself as to how it needs to be run,

eg.

// @test-runner vitest
// @test-env ssr

import {} from "vinxi/test"
// @test-runner playwright

import {} from "vinxi/test"

Approach 2:

I expose a defineVitestConfig exported from vinxi/test that can be used in a vitest.config.ts to derive a vitest config out of vinxi app config. It will take options to drive the config, and then will also probably need to respond to environmet variables. Though then you can probably use vitest to run your tests.

import { defineVitestConfig } from "vinxi/test"
import app from './app.config.js'

export default defineVitestConfig(app)

@atk
Copy link
Author

atk commented Feb 2, 2024

Let me add a few thoughts:

  • You may want to expose other routers to the tests based on global and per-file configuration, e.g. // @vinxi-routers ssr, client, public
  • Even if you have a vinxi test command, you can run normal vite tests by temporarily creating a config for vitest, so you don't need to export anything except the CLI command
  • I would very much prefer as few extra configuration for testing as necessary; ideally, tests should run out of the box without any extra configuration

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

No branches or pull requests

2 participants