@hkdigital/lib-sveltekit 0.1.71 → 0.1.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- export const isTestMode: boolean;
1
+ export const isTestEnv: boolean;
@@ -1,5 +1,9 @@
1
1
 
2
- export const isTestMode =
3
- import.meta.env.MODE === 'test' ||
4
- process.env.NODE_ENV === 'test' ||
5
- process.env.VITEST !== undefined;
2
+ export const isTestEnv = (
3
+ // For Vite environments
4
+ (typeof import.meta !== 'undefined' && import.meta.env?.MODE === 'test') ||
5
+ // For Node environments, safely check process
6
+ (typeof process !== 'undefined' && process?.env?.NODE_ENV === 'test') ||
7
+ // For Vitest specific check
8
+ (typeof process !== 'undefined' && process?.env?.VITEST !== undefined)
9
+ );
@@ -5,6 +5,8 @@ import {
5
5
 
6
6
  import { browser } from '$app/environment';
7
7
 
8
+ import { isTestEnv } from '../env';
9
+
8
10
  let defaultCacheStorage = null;
9
11
 
10
12
  function getCacheStorage()
@@ -13,7 +15,7 @@ function getCacheStorage()
13
15
  {
14
16
  let type;
15
17
 
16
- if( !browser || process.env.NODE_ENV === 'test' )
18
+ if( !browser || isTestEnv )
17
19
  {
18
20
  type = 'memory';
19
21
  }
@@ -13,7 +13,7 @@ import { waitForAndCheckResponse } from './response.js';
13
13
 
14
14
  import { getCachedResponse, storeResponseInCache } from './caching.js';
15
15
 
16
- import { isTestMode } from '../env';
16
+ import { isTestEnv } from '../env';
17
17
 
18
18
  /**
19
19
  * Default configuration for HTTP requests
@@ -181,7 +181,7 @@ export async function httpRequest(options) {
181
181
  const cacheKeyParams = { url, ...headers };
182
182
  const cachedResponse = await getCachedResponse(cacheKeyParams);
183
183
 
184
- if( !isTestMode )
184
+ if( !isTestEnv )
185
185
  {
186
186
  if (cachedResponse) {
187
187
  console.debug(`http:cache-hit [${url.pathname}]`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-sveltekit",
3
- "version": "0.1.71",
3
+ "version": "0.1.72",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"