@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.
package/dist/util/env/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const
|
1
|
+
export const isTestEnv: boolean;
|
package/dist/util/env/index.js
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
|
2
|
-
export const
|
3
|
-
|
4
|
-
|
5
|
-
|
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 ||
|
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 {
|
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( !
|
184
|
+
if( !isTestEnv )
|
185
185
|
{
|
186
186
|
if (cachedResponse) {
|
187
187
|
console.debug(`http:cache-hit [${url.pathname}]`);
|