How do I use a custom environment by specifying a file path to it #3921
-
|
In the Custom Environment documentation, it says that I can "specify a path to a valid JS file (supported since 0.34.0)". However, I'm not able to get that working. I have the following import { configDefaults, defineConfig } from "vitest/config";
export default defineConfig({
test: {
exclude: [...configDefaults.exclude, "data"],
globals: true,
environment: "./recipeamigo-test-environment.js",
},
});When I then try to run I'm using the latest version of Vitest on Linux: Here's the contents of import { execSync } from "child_process";
const RecipeamigoTestEnvironment = {
name: "recipeamigo",
transformMode: "ssr",
setup: () => {
execSync("npm run test:start_database");
return {
teardown: () => {
execSync("npm run test:stop_database");
},
};
},
};
export default RecipeamigoTestEnvironment; |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Looks like it's a Vitest bug. But what you are doing in the env doesn't look appropriate for an environment. If you need to run command once, use |
Beta Was this translation helpful? Give feedback.


Looks like it's a Vitest bug. But what you are doing in the env doesn't look appropriate for an environment. If you need to run command once, use
globalSetupinstead