|
1 | 1 | import { describe, test, expect, vi } from 'vitest' |
2 | | -import { cleanEnv, str, num, testOnly, type ReporterOptions } from '../src' |
| 2 | +import { cleanEnv, str, num, type ReporterOptions } from '../src' |
3 | 3 | import { assertPassthrough } from './utils' |
4 | 4 | import { expectTypeOf } from 'expect-type' |
5 | 5 |
|
@@ -297,49 +297,3 @@ describe('NODE_ENV built-in support', () => { |
297 | 297 | expect(cleanEnv({}, customSpec).isDevelopment).toEqual(false) |
298 | 298 | }) |
299 | 299 | }) |
300 | | - |
301 | | -test('testOnly', () => { |
302 | | - const processEnv = process.env.NODE_ENV |
303 | | - |
304 | | - const reporter = vi.fn(({ errors = {} }: ReporterOptions<any>) => { |
305 | | - if (Object.keys(errors).length) { |
306 | | - throw new Error() |
307 | | - } |
308 | | - }) |
309 | | - |
310 | | - // Create an env spec that has our testOnly value applied as the devDefault, |
311 | | - // and then restore the original NODE_ENV |
312 | | - process.env.NODE_ENV = 'test' |
313 | | - const env = cleanEnv( |
314 | | - { NODE_ENV: 'test' }, |
315 | | - { FOO: str({ devDefault: testOnly('sup') }) }, |
316 | | - { reporter }, |
317 | | - ) |
318 | | - expect(env).toEqual({ FOO: 'sup' }) |
319 | | - expect(reporter).toHaveBeenCalledTimes(1) |
320 | | - vi.clearAllMocks() |
321 | | - |
322 | | - process.env.NODE_ENV = 'production' |
323 | | - expect(() => |
324 | | - cleanEnv( |
325 | | - { NODE_ENV: 'production' }, |
326 | | - { FOO: str({ devDefault: testOnly('sup') }) }, |
327 | | - { reporter }, |
328 | | - ), |
329 | | - ).toThrow() |
330 | | - expect(reporter).toHaveBeenCalledTimes(1) |
331 | | - vi.clearAllMocks() |
332 | | - |
333 | | - process.env.NODE_ENV = 'development' |
334 | | - expect(() => |
335 | | - cleanEnv( |
336 | | - { NODE_ENV: 'development' }, |
337 | | - { FOO: str({ devDefault: testOnly('sup') }) }, |
338 | | - { reporter }, |
339 | | - ), |
340 | | - ).toThrow() |
341 | | - expect(reporter).toHaveBeenCalledTimes(1) |
342 | | - vi.clearAllMocks() |
343 | | - |
344 | | - process.env.NODE_ENV = processEnv |
345 | | -}) |
0 commit comments