Getting started is a little confusing #1153
Replies: 4 comments 1 reply
-
It seems like It seems like import { test, expect } from 'vitest';
test('first test', async () => {
expect(true);
}); might be better as a first test, but I still can't get it to work. I installed
as the vitest.config.js file, but that doesn't have my firsttest file hooked up, which I would've guessed would be: /// <reference types="vitest" />
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
firsttest: './test/firsttest.js'
}
}); I changed my config to: import { defineConfig } from 'vite';
import { extractFromSvelteConfig } from 'vitest-svelte-kit';
export default async function () {
const extract = await extractFromSvelteConfig();
return defineConfig({
plugins: extract['plugins'],
test: {
firsttest: './test/firsttest.js'
}
});
} but it still says no test files found. |
Beta Was this translation helpful? Give feedback.
-
Is import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
export default defineConfig({
plugins: [svelte({ hot: !process.env.VITEST })],
test: {
firsttest: './test/firsttest.js'
}
}); and still doesn't find tests and fails. |
Beta Was this translation helpful? Give feedback.
-
Also, I don't know what you are trying to do with this "firsttest" in your config. We dont have that field. Please, refer to documentation for available options. |
Beta Was this translation helpful? Give feedback.
-
I'm experienced with web dev, but not with vitetest, vite, or testing frameworks. I'm using vitest because I'm using svelte kit, and svelte uses vite under the hood.
I was following the getting started guide (https://vitest.dev/guide/) and tried my best to get a simple "hello world" test going.
I installed vitest as a dev dependency and tried my best at copying from your guide:
My package.json has
my vitest.config.js has
(assuming I need to replace the comment)
and I made a test directory and in test/firsttest.js I have
But I have no idea if the test directory should be in src or in the top level, if the test file should be a js file or something special, if I hook up the firsttest file to vite.config.js or in the command in package.json to tell it where the file is, etc.
I saw the example had it as a typescript file but I'm not using typescript.
I think I'll figure this out soon enough by checking other peoples' code, but it would be nice to just set up the user with a working "hello world" out of the box (I don't mean like a CLI utility for starting a boilerplate project that creates the files itself, I just mean in the tutorial, simpler example code and instructions to run your first test, before going into timeouts and skipping docs.
Beta Was this translation helpful? Give feedback.
All reactions