Skip to content

Commit

Permalink
Use default VITE_ prefix for Vitest env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
axelboc committed Jul 9, 2024
1 parent 3e13c85 commit 0afc3c6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
6 changes: 3 additions & 3 deletions packages/app/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#####

# URL of h5grove support server
VITEST_H5GROVE_URL=http://localhost:8888
VITE_H5GROVE_URL=http://localhost:8888

# Name of test file
VITEST_H5GROVE_TEST_FILE=sample.h5
VITE_H5GROVE_TEST_FILE=sample.h5

# Set to `true` to skip testing h5grove API
VITEST_H5GROVE_SKIP=
VITE_H5GROVE_SKIP=
6 changes: 3 additions & 3 deletions packages/app/src/providers/h5grove/h5grove-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { assertListeningAt } from '../../test-utils';
import { getValueOrError } from '../utils';
import { H5GroveApi } from './h5grove-api';

const SKIP = import.meta.env.VITEST_H5GROVE_SKIP === 'true';
const H5GROVE_URL = import.meta.env.VITEST_H5GROVE_URL;
const TEST_FILE = import.meta.env.VITEST_H5GROVE_TEST_FILE;
const SKIP = import.meta.env.VITE_H5GROVE_SKIP === 'true';
const H5GROVE_URL = import.meta.env.VITE_H5GROVE_URL;
const TEST_FILE = import.meta.env.VITE_H5GROVE_TEST_FILE;
assertEnvVar(H5GROVE_URL, 'VITE_H5GROVE_URL');
assertEnvVar(TEST_FILE, 'VITE_TEST_FILE');

Expand Down
2 changes: 0 additions & 2 deletions packages/app/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import react from '@vitejs/plugin-react-swc';
import fs from 'fs';
import path from 'path';
import { loadEnv } from 'vite';
import { patchCssModules } from 'vite-css-modules';
import { defineProject } from 'vitest/config';

Expand Down Expand Up @@ -34,7 +33,6 @@ export default defineProject({
test: {
setupFiles: ['src/setupTests.ts'],
environment: 'jsdom',
env: loadEnv('test', import.meta.dirname, 'VITEST_'),
restoreMocks: true,
testTimeout: 15_000,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/h5wasm/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#####

# Path to HDF5 test file, relative to the root of the monorepo
VITEST_H5WASM_TEST_FILE=support/sample/dist/sample.h5
VITE_H5WASM_TEST_FILE=support/sample/dist/sample.h5

# Set to `true` to skip testing h5wasm API
VITEST_H5WASM_SKIP=
VITE_H5WASM_SKIP=
6 changes: 3 additions & 3 deletions packages/h5wasm/src/h5wasm-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { beforeAll, expect, test } from 'vitest';
import { H5WasmApi } from './h5wasm-api';
import remote from './worker';

const SKIP = import.meta.env.VITEST_H5WASM_SKIP === 'true';
const H5WASM_TEST_FILE = import.meta.env.VITEST_H5WASM_TEST_FILE;
assertEnvVar(H5WASM_TEST_FILE, 'VITEST_H5WASM_TEST_FILE');
const SKIP = import.meta.env.VITE_H5WASM_SKIP === 'true';
const H5WASM_TEST_FILE = import.meta.env.VITE_H5WASM_TEST_FILE;
assertEnvVar(H5WASM_TEST_FILE, 'VITE_H5WASM_TEST_FILE');

const TEST_FILE = path.resolve(process.cwd(), H5WASM_TEST_FILE);

Expand Down
4 changes: 0 additions & 4 deletions packages/h5wasm/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import react from '@vitejs/plugin-react-swc';
import fs from 'fs';
import path from 'path';
import { loadEnv } from 'vite';
import { defineProject } from 'vitest/config';

const [pkg, appPkg, sharedPkg] = ['.', '../app', '../shared']
Expand Down Expand Up @@ -29,7 +28,4 @@ export default defineProject({
},
sourcemap: true,
},
test: {
env: loadEnv('test', import.meta.dirname, 'VITEST_'),
},
});

0 comments on commit 0afc3c6

Please sign in to comment.