refactor: switch from jsdom to happy-dom

This commit is contained in:
master 2025-02-16 23:59:00 +08:00
parent ba13828093
commit 41f2b04c45
8 changed files with 124 additions and 89 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "oidc-client-rx", "name": "oidc-client-rx",
"version": "0.1.0-alpha.1", "version": "0.1.0-alpha.0",
"homepage": "https://github.com/lonelyhentxi/oidc-client-rx", "homepage": "https://github.com/lonelyhentxi/oidc-client-rx",
"author": "lonelyhentxi", "author": "lonelyhentxi",
"description": "ReactiveX enhanced OIDC and OAuth2 protocol support for browser-based JavaScript applications", "description": "ReactiveX enhanced OIDC and OAuth2 protocol support for browser-based JavaScript applications",
@ -60,13 +60,12 @@
"@rslib/core": "^0.4.0", "@rslib/core": "^0.4.0",
"@swc/core": "^1.10.12", "@swc/core": "^1.10.12",
"@tanstack/react-router": "^1.99.6", "@tanstack/react-router": "^1.99.6",
"@types/jsdom": "^21.1.7",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/node": "^22.12.0", "@types/node": "^22.12.0",
"@types/react": "^19.0.8", "@types/react": "^19.0.8",
"@vitest/coverage-v8": "^3.0.4", "@vitest/coverage-v8": "^3.0.4",
"commander": "^13.1.0", "commander": "^13.1.0",
"jsdom": "^26.0.0", "happy-dom": "^17.1.0",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"oxc-parser": "^0.48.1", "oxc-parser": "^0.48.1",
"oxc-walker": "^0.2.2", "oxc-walker": "^0.2.2",

124
pnpm-lock.yaml generated
View File

@ -36,9 +36,6 @@ importers:
'@tanstack/react-router': '@tanstack/react-router':
specifier: ^1.99.6 specifier: ^1.99.6
version: 1.99.6(react-dom@19.0.0(react@19.0.0))(react@19.0.0) version: 1.99.6(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
'@types/jsdom':
specifier: ^21.1.7
version: 21.1.7
'@types/lodash-es': '@types/lodash-es':
specifier: ^4.17.12 specifier: ^4.17.12
version: 4.17.12 version: 4.17.12
@ -54,9 +51,9 @@ importers:
commander: commander:
specifier: ^13.1.0 specifier: ^13.1.0
version: 13.1.0 version: 13.1.0
jsdom: happy-dom:
specifier: ^26.0.0 specifier: ^17.1.0
version: 26.0.0 version: 17.1.0
lodash-es: lodash-es:
specifier: ^4.17.21 specifier: ^4.17.21
version: 4.17.21 version: 4.17.21
@ -98,7 +95,7 @@ importers:
version: 5.1.4(typescript@5.7.3)(vite@6.0.7(@types/node@22.12.0)(jiti@2.4.2)(lightningcss@1.29.1)(tsx@4.19.2)(yaml@2.7.0)) version: 5.1.4(typescript@5.7.3)(vite@6.0.7(@types/node@22.12.0)(jiti@2.4.2)(lightningcss@1.29.1)(tsx@4.19.2)(yaml@2.7.0))
vitest: vitest:
specifier: ^3.0.4 specifier: ^3.0.4
version: 3.0.4(@types/node@22.12.0)(@vitest/browser@3.0.4)(jiti@2.4.2)(jsdom@26.0.0)(lightningcss@1.29.1)(msw@2.7.0(@types/node@22.12.0)(typescript@5.7.3))(tsx@4.19.2)(yaml@2.7.0) version: 3.0.4(@types/node@22.12.0)(@vitest/browser@3.0.4)(happy-dom@17.1.0)(jiti@2.4.2)(jsdom@26.0.0)(lightningcss@1.29.1)(msw@2.7.0(@types/node@22.12.0)(typescript@5.7.3))(tsx@4.19.2)(yaml@2.7.0)
examples/react-tanstack-router: examples/react-tanstack-router:
dependencies: dependencies:
@ -1244,9 +1241,6 @@ packages:
'@types/estree@1.0.6': '@types/estree@1.0.6':
resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==} resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==}
'@types/jsdom@21.1.7':
resolution: {integrity: sha512-yOriVnggzrnQ3a9OKOCxaVuSug3w3/SbOj5i7VwXWZEyUNl3bLF9V3MfxGbZKuwqJOQyRfqXyROBB1CoZLFWzA==}
'@types/lodash-es@4.17.12': '@types/lodash-es@4.17.12':
resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==} resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==}
@ -1991,6 +1985,10 @@ packages:
resolution: {integrity: sha512-AjqGKbDGUFRKIRCP9tCKiIGHyriz2oHEbPIbEtcSLSs4YjReZOIPQQWek4+6hjw62H9QShXHyaGivGiYVLeYFQ==} resolution: {integrity: sha512-AjqGKbDGUFRKIRCP9tCKiIGHyriz2oHEbPIbEtcSLSs4YjReZOIPQQWek4+6hjw62H9QShXHyaGivGiYVLeYFQ==}
engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0}
happy-dom@17.1.0:
resolution: {integrity: sha512-9tUhXyePCjzUMycaHS/IzrIpF69xiq/laAT7golk4MtZ6t8ft5+Rv7U3lfrs2b4NMH0JTL3EhZzjfahrPmOnaQ==}
engines: {node: '>=18.0.0'}
has-flag@4.0.0: has-flag@4.0.0:
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -3190,6 +3188,10 @@ packages:
resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==} resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==}
engines: {node: '>=18'} engines: {node: '>=18'}
whatwg-mimetype@3.0.0:
resolution: {integrity: sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==}
engines: {node: '>=12'}
whatwg-mimetype@4.0.0: whatwg-mimetype@4.0.0:
resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==} resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==}
engines: {node: '>=18'} engines: {node: '>=18'}
@ -3302,6 +3304,7 @@ snapshots:
'@csstools/css-parser-algorithms': 3.0.4(@csstools/css-tokenizer@3.0.3) '@csstools/css-parser-algorithms': 3.0.4(@csstools/css-tokenizer@3.0.3)
'@csstools/css-tokenizer': 3.0.3 '@csstools/css-tokenizer': 3.0.3
lru-cache: 10.4.3 lru-cache: 10.4.3
optional: true
'@babel/code-frame@7.26.2': '@babel/code-frame@7.26.2':
dependencies: dependencies:
@ -3486,12 +3489,14 @@ snapshots:
tough-cookie: 4.1.4 tough-cookie: 4.1.4
optional: true optional: true
'@csstools/color-helpers@5.0.1': {} '@csstools/color-helpers@5.0.1':
optional: true
'@csstools/css-calc@2.1.1(@csstools/css-parser-algorithms@3.0.4(@csstools/css-tokenizer@3.0.3))(@csstools/css-tokenizer@3.0.3)': '@csstools/css-calc@2.1.1(@csstools/css-parser-algorithms@3.0.4(@csstools/css-tokenizer@3.0.3))(@csstools/css-tokenizer@3.0.3)':
dependencies: dependencies:
'@csstools/css-parser-algorithms': 3.0.4(@csstools/css-tokenizer@3.0.3) '@csstools/css-parser-algorithms': 3.0.4(@csstools/css-tokenizer@3.0.3)
'@csstools/css-tokenizer': 3.0.3 '@csstools/css-tokenizer': 3.0.3
optional: true
'@csstools/css-color-parser@3.0.7(@csstools/css-parser-algorithms@3.0.4(@csstools/css-tokenizer@3.0.3))(@csstools/css-tokenizer@3.0.3)': '@csstools/css-color-parser@3.0.7(@csstools/css-parser-algorithms@3.0.4(@csstools/css-tokenizer@3.0.3))(@csstools/css-tokenizer@3.0.3)':
dependencies: dependencies:
@ -3499,12 +3504,15 @@ snapshots:
'@csstools/css-calc': 2.1.1(@csstools/css-parser-algorithms@3.0.4(@csstools/css-tokenizer@3.0.3))(@csstools/css-tokenizer@3.0.3) '@csstools/css-calc': 2.1.1(@csstools/css-parser-algorithms@3.0.4(@csstools/css-tokenizer@3.0.3))(@csstools/css-tokenizer@3.0.3)
'@csstools/css-parser-algorithms': 3.0.4(@csstools/css-tokenizer@3.0.3) '@csstools/css-parser-algorithms': 3.0.4(@csstools/css-tokenizer@3.0.3)
'@csstools/css-tokenizer': 3.0.3 '@csstools/css-tokenizer': 3.0.3
optional: true
'@csstools/css-parser-algorithms@3.0.4(@csstools/css-tokenizer@3.0.3)': '@csstools/css-parser-algorithms@3.0.4(@csstools/css-tokenizer@3.0.3)':
dependencies: dependencies:
'@csstools/css-tokenizer': 3.0.3 '@csstools/css-tokenizer': 3.0.3
optional: true
'@csstools/css-tokenizer@3.0.3': {} '@csstools/css-tokenizer@3.0.3':
optional: true
'@esbuild/aix-ppc64@0.23.1': '@esbuild/aix-ppc64@0.23.1':
optional: true optional: true
@ -4249,12 +4257,6 @@ snapshots:
'@types/estree@1.0.6': {} '@types/estree@1.0.6': {}
'@types/jsdom@21.1.7':
dependencies:
'@types/node': 22.12.0
'@types/tough-cookie': 4.0.5
parse5: 7.2.1
'@types/lodash-es@4.17.12': '@types/lodash-es@4.17.12':
dependencies: dependencies:
'@types/lodash': 4.17.15 '@types/lodash': 4.17.15
@ -4284,7 +4286,8 @@ snapshots:
'@types/statuses@2.0.5': '@types/statuses@2.0.5':
optional: true optional: true
'@types/tough-cookie@4.0.5': {} '@types/tough-cookie@4.0.5':
optional: true
'@types/which@2.0.2': '@types/which@2.0.2':
optional: true optional: true
@ -4309,7 +4312,7 @@ snapshots:
msw: 2.7.0(@types/node@22.12.0)(typescript@5.7.3) msw: 2.7.0(@types/node@22.12.0)(typescript@5.7.3)
sirv: 3.0.0 sirv: 3.0.0
tinyrainbow: 2.0.0 tinyrainbow: 2.0.0
vitest: 3.0.4(@types/node@22.12.0)(@vitest/browser@3.0.4)(jiti@2.4.2)(jsdom@26.0.0)(lightningcss@1.29.1)(msw@2.7.0(@types/node@22.12.0)(typescript@5.7.3))(tsx@4.19.2)(yaml@2.7.0) vitest: 3.0.4(@types/node@22.12.0)(@vitest/browser@3.0.4)(happy-dom@17.1.0)(jiti@2.4.2)(jsdom@26.0.0)(lightningcss@1.29.1)(msw@2.7.0(@types/node@22.12.0)(typescript@5.7.3))(tsx@4.19.2)(yaml@2.7.0)
ws: 8.18.0 ws: 8.18.0
optionalDependencies: optionalDependencies:
playwright: 1.50.0 playwright: 1.50.0
@ -4336,7 +4339,7 @@ snapshots:
std-env: 3.8.0 std-env: 3.8.0
test-exclude: 7.0.1 test-exclude: 7.0.1
tinyrainbow: 2.0.0 tinyrainbow: 2.0.0
vitest: 3.0.4(@types/node@22.12.0)(@vitest/browser@3.0.4)(jiti@2.4.2)(jsdom@26.0.0)(lightningcss@1.29.1)(msw@2.7.0(@types/node@22.12.0)(typescript@5.7.3))(tsx@4.19.2)(yaml@2.7.0) vitest: 3.0.4(@types/node@22.12.0)(@vitest/browser@3.0.4)(happy-dom@17.1.0)(jiti@2.4.2)(jsdom@26.0.0)(lightningcss@1.29.1)(msw@2.7.0(@types/node@22.12.0)(typescript@5.7.3))(tsx@4.19.2)(yaml@2.7.0)
optionalDependencies: optionalDependencies:
'@vitest/browser': 3.0.4(@types/node@22.12.0)(playwright@1.50.0)(typescript@5.7.3)(vite@6.0.7(@types/node@22.12.0)(jiti@2.4.2)(lightningcss@1.29.1)(tsx@4.19.2)(yaml@2.7.0))(vitest@3.0.4)(webdriverio@9.7.2) '@vitest/browser': 3.0.4(@types/node@22.12.0)(playwright@1.50.0)(typescript@5.7.3)(vite@6.0.7(@types/node@22.12.0)(jiti@2.4.2)(lightningcss@1.29.1)(tsx@4.19.2)(yaml@2.7.0))(vitest@3.0.4)(webdriverio@9.7.2)
transitivePeerDependencies: transitivePeerDependencies:
@ -4447,7 +4450,8 @@ snapshots:
acorn@8.14.0: {} acorn@8.14.0: {}
agent-base@7.1.3: {} agent-base@7.1.3:
optional: true
ajv-draft-04@1.0.0(ajv@8.13.0): ajv-draft-04@1.0.0(ajv@8.13.0):
optionalDependencies: optionalDependencies:
@ -4546,7 +4550,8 @@ snapshots:
async@3.2.6: async@3.2.6:
optional: true optional: true
asynckit@0.4.0: {} asynckit@0.4.0:
optional: true
autoprefixer@10.4.20(postcss@8.5.1): autoprefixer@10.4.20(postcss@8.5.1):
dependencies: dependencies:
@ -4732,6 +4737,7 @@ snapshots:
combined-stream@1.0.8: combined-stream@1.0.8:
dependencies: dependencies:
delayed-stream: 1.0.0 delayed-stream: 1.0.0
optional: true
commander@12.1.0: {} commander@12.1.0: {}
@ -4805,6 +4811,7 @@ snapshots:
dependencies: dependencies:
'@asamuzakjp/css-color': 2.8.3 '@asamuzakjp/css-color': 2.8.3
rrweb-cssom: 0.8.0 rrweb-cssom: 0.8.0
optional: true
csstype@3.1.3: {} csstype@3.1.3: {}
@ -4818,6 +4825,7 @@ snapshots:
dependencies: dependencies:
whatwg-mimetype: 4.0.0 whatwg-mimetype: 4.0.0
whatwg-url: 14.1.0 whatwg-url: 14.1.0
optional: true
debug@4.4.0: debug@4.4.0:
dependencies: dependencies:
@ -4826,7 +4834,8 @@ snapshots:
decamelize@6.0.0: decamelize@6.0.0:
optional: true optional: true
decimal.js@10.5.0: {} decimal.js@10.5.0:
optional: true
deep-eql@5.0.2: {} deep-eql@5.0.2: {}
@ -4840,7 +4849,8 @@ snapshots:
esprima: 4.0.1 esprima: 4.0.1
optional: true optional: true
delayed-stream@1.0.0: {} delayed-stream@1.0.0:
optional: true
dequal@2.0.3: dequal@2.0.3:
optional: true optional: true
@ -4919,7 +4929,8 @@ snapshots:
once: 1.4.0 once: 1.4.0
optional: true optional: true
entities@4.5.0: {} entities@4.5.0:
optional: true
error-stack-parser@2.1.4: error-stack-parser@2.1.4:
dependencies: dependencies:
@ -5082,6 +5093,7 @@ snapshots:
asynckit: 0.4.0 asynckit: 0.4.0
combined-stream: 1.0.8 combined-stream: 1.0.8
mime-types: 2.1.35 mime-types: 2.1.35
optional: true
formdata-polyfill@4.0.10: formdata-polyfill@4.0.10:
dependencies: dependencies:
@ -5180,6 +5192,11 @@ snapshots:
graphql@16.10.0: graphql@16.10.0:
optional: true optional: true
happy-dom@17.1.0:
dependencies:
webidl-conversions: 7.0.0
whatwg-mimetype: 3.0.0
has-flag@4.0.0: {} has-flag@4.0.0: {}
hasown@2.0.2: hasown@2.0.2:
@ -5192,6 +5209,7 @@ snapshots:
html-encoding-sniffer@4.0.0: html-encoding-sniffer@4.0.0:
dependencies: dependencies:
whatwg-encoding: 3.1.1 whatwg-encoding: 3.1.1
optional: true
html-entities@2.5.2: {} html-entities@2.5.2: {}
@ -5214,6 +5232,7 @@ snapshots:
debug: 4.4.0 debug: 4.4.0
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
optional: true
https-proxy-agent@7.0.6: https-proxy-agent@7.0.6:
dependencies: dependencies:
@ -5221,10 +5240,12 @@ snapshots:
debug: 4.4.0 debug: 4.4.0
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
optional: true
iconv-lite@0.6.3: iconv-lite@0.6.3:
dependencies: dependencies:
safer-buffer: 2.1.2 safer-buffer: 2.1.2
optional: true
ieee754@1.2.1: ieee754@1.2.1:
optional: true optional: true
@ -5271,7 +5292,8 @@ snapshots:
is-plain-obj@4.1.0: is-plain-obj@4.1.0:
optional: true optional: true
is-potential-custom-element-name@1.0.1: {} is-potential-custom-element-name@1.0.1:
optional: true
is-stream@2.0.1: is-stream@2.0.1:
optional: true optional: true
@ -5353,6 +5375,7 @@ snapshots:
- bufferutil - bufferutil
- supports-color - supports-color
- utf-8-validate - utf-8-validate
optional: true
jsesc@3.1.0: {} jsesc@3.1.0: {}
@ -5512,11 +5535,13 @@ snapshots:
braces: 3.0.3 braces: 3.0.3
picomatch: 2.3.1 picomatch: 2.3.1
mime-db@1.52.0: {} mime-db@1.52.0:
optional: true
mime-types@2.1.35: mime-types@2.1.35:
dependencies: dependencies:
mime-db: 1.52.0 mime-db: 1.52.0
optional: true
minimatch@3.0.8: minimatch@3.0.8:
dependencies: dependencies:
@ -5607,7 +5632,8 @@ snapshots:
boolbase: 1.0.0 boolbase: 1.0.0
optional: true optional: true
nwsapi@2.2.16: {} nwsapi@2.2.16:
optional: true
object-assign@4.1.1: {} object-assign@4.1.1: {}
@ -5685,6 +5711,7 @@ snapshots:
parse5@7.2.1: parse5@7.2.1:
dependencies: dependencies:
entities: 4.5.0 entities: 4.5.0
optional: true
path-key@3.1.1: {} path-key@3.1.1: {}
@ -5822,7 +5849,8 @@ snapshots:
once: 1.4.0 once: 1.4.0
optional: true optional: true
punycode@2.3.1: {} punycode@2.3.1:
optional: true
query-selector-shadow-dom@1.0.1: query-selector-shadow-dom@1.0.1:
optional: true optional: true
@ -5938,7 +5966,8 @@ snapshots:
'@rollup/rollup-win32-x64-msvc': 4.30.1 '@rollup/rollup-win32-x64-msvc': 4.30.1
fsevents: 2.3.3 fsevents: 2.3.3
rrweb-cssom@0.8.0: {} rrweb-cssom@0.8.0:
optional: true
rsbuild-plugin-dts@0.4.0(@microsoft/api-extractor@7.49.2(@types/node@22.12.0))(@rsbuild/core@1.2.4)(typescript@5.7.3): rsbuild-plugin-dts@0.4.0(@microsoft/api-extractor@7.49.2(@types/node@22.12.0))(@rsbuild/core@1.2.4)(typescript@5.7.3):
dependencies: dependencies:
@ -5967,11 +5996,13 @@ snapshots:
safe-buffer@5.2.1: safe-buffer@5.2.1:
optional: true optional: true
safer-buffer@2.1.2: {} safer-buffer@2.1.2:
optional: true
saxes@6.0.0: saxes@6.0.0:
dependencies: dependencies:
xmlchars: 2.2.0 xmlchars: 2.2.0
optional: true
scheduler@0.25.0: {} scheduler@0.25.0: {}
@ -6124,7 +6155,8 @@ snapshots:
supports-preserve-symlinks-flag@1.0.0: {} supports-preserve-symlinks-flag@1.0.0: {}
symbol-tree@3.2.4: {} symbol-tree@3.2.4:
optional: true
tailwindcss@3.4.17: tailwindcss@3.4.17:
dependencies: dependencies:
@ -6212,11 +6244,13 @@ snapshots:
tinyspy@3.0.2: {} tinyspy@3.0.2: {}
tldts-core@6.1.75: {} tldts-core@6.1.75:
optional: true
tldts@6.1.75: tldts@6.1.75:
dependencies: dependencies:
tldts-core: 6.1.75 tldts-core: 6.1.75
optional: true
to-regex-range@5.0.1: to-regex-range@5.0.1:
dependencies: dependencies:
@ -6236,10 +6270,12 @@ snapshots:
tough-cookie@5.1.0: tough-cookie@5.1.0:
dependencies: dependencies:
tldts: 6.1.75 tldts: 6.1.75
optional: true
tr46@5.0.0: tr46@5.0.0:
dependencies: dependencies:
punycode: 2.3.1 punycode: 2.3.1
optional: true
ts-interface-checker@0.1.13: {} ts-interface-checker@0.1.13: {}
@ -6394,7 +6430,7 @@ snapshots:
tsx: 4.19.2 tsx: 4.19.2
yaml: 2.7.0 yaml: 2.7.0
vitest@3.0.4(@types/node@22.12.0)(@vitest/browser@3.0.4)(jiti@2.4.2)(jsdom@26.0.0)(lightningcss@1.29.1)(msw@2.7.0(@types/node@22.12.0)(typescript@5.7.3))(tsx@4.19.2)(yaml@2.7.0): vitest@3.0.4(@types/node@22.12.0)(@vitest/browser@3.0.4)(happy-dom@17.1.0)(jiti@2.4.2)(jsdom@26.0.0)(lightningcss@1.29.1)(msw@2.7.0(@types/node@22.12.0)(typescript@5.7.3))(tsx@4.19.2)(yaml@2.7.0):
dependencies: dependencies:
'@vitest/expect': 3.0.4 '@vitest/expect': 3.0.4
'@vitest/mocker': 3.0.4(msw@2.7.0(@types/node@22.12.0)(typescript@5.7.3))(vite@6.0.7(@types/node@22.12.0)(jiti@2.4.2)(lightningcss@1.29.1)(tsx@4.19.2)(yaml@2.7.0)) '@vitest/mocker': 3.0.4(msw@2.7.0(@types/node@22.12.0)(typescript@5.7.3))(vite@6.0.7(@types/node@22.12.0)(jiti@2.4.2)(lightningcss@1.29.1)(tsx@4.19.2)(yaml@2.7.0))
@ -6419,6 +6455,7 @@ snapshots:
optionalDependencies: optionalDependencies:
'@types/node': 22.12.0 '@types/node': 22.12.0
'@vitest/browser': 3.0.4(@types/node@22.12.0)(playwright@1.50.0)(typescript@5.7.3)(vite@6.0.7(@types/node@22.12.0)(jiti@2.4.2)(lightningcss@1.29.1)(tsx@4.19.2)(yaml@2.7.0))(vitest@3.0.4)(webdriverio@9.7.2) '@vitest/browser': 3.0.4(@types/node@22.12.0)(playwright@1.50.0)(typescript@5.7.3)(vite@6.0.7(@types/node@22.12.0)(jiti@2.4.2)(lightningcss@1.29.1)(tsx@4.19.2)(yaml@2.7.0))(vitest@3.0.4)(webdriverio@9.7.2)
happy-dom: 17.1.0
jsdom: 26.0.0 jsdom: 26.0.0
transitivePeerDependencies: transitivePeerDependencies:
- jiti - jiti
@ -6437,6 +6474,7 @@ snapshots:
w3c-xmlserializer@5.0.0: w3c-xmlserializer@5.0.0:
dependencies: dependencies:
xml-name-validator: 5.0.0 xml-name-validator: 5.0.0
optional: true
wait-port@1.1.0: wait-port@1.1.0:
dependencies: dependencies:
@ -6512,13 +6550,18 @@ snapshots:
whatwg-encoding@3.1.1: whatwg-encoding@3.1.1:
dependencies: dependencies:
iconv-lite: 0.6.3 iconv-lite: 0.6.3
optional: true
whatwg-mimetype@4.0.0: {} whatwg-mimetype@3.0.0: {}
whatwg-mimetype@4.0.0:
optional: true
whatwg-url@14.1.0: whatwg-url@14.1.0:
dependencies: dependencies:
tr46: 5.0.0 tr46: 5.0.0
webidl-conversions: 7.0.0 webidl-conversions: 7.0.0
optional: true
which@2.0.2: which@2.0.2:
dependencies: dependencies:
@ -6556,11 +6599,14 @@ snapshots:
wrappy@1.0.2: wrappy@1.0.2:
optional: true optional: true
ws@8.18.0: {} ws@8.18.0:
optional: true
xml-name-validator@5.0.0: {} xml-name-validator@5.0.0:
optional: true
xmlchars@2.2.0: {} xmlchars@2.2.0:
optional: true
y18n@5.0.8: y18n@5.0.8:
optional: true optional: true

View File

@ -61,12 +61,11 @@ describe('RefreshSessionIframeService ', () => {
); );
(refreshSessionIframeService as any).initSilentRenewRequest(); (refreshSessionIframeService as any).initSilentRenewRequest();
expect(dispatchEventSpy).toHaveBeenCalledOnce();
expect(dispatchEventSpy).toHaveBeenCalledExactlyOnceWith( expect(dispatchEventSpy.mock.calls[0][0]).toBeInstanceOf(CustomEvent);
new CustomEvent('oidc-silent-renew-init', { expect(
detail: expect.any(Number), (dispatchEventSpy.mock.calls[0][0] as CustomEvent).detail
}) ).toBeTypeOf('number');
);
}); });
}); });
}); });

View File

@ -31,7 +31,7 @@ export abstract class AbstractRouter<
} }
export class VanillaLocationRouter extends AbstractRouter { export class VanillaLocationRouter extends AbstractRouter {
private document = inject(DOCUMENT); protected document = inject(DOCUMENT);
private get location(): Location { private get location(): Location {
const location = this.document.defaultView?.window?.location; const location = this.document.defaultView?.window?.location;

View File

@ -2,6 +2,10 @@ import { TestBed } from '@/testing';
import { vi } from 'vitest'; import { vi } from 'vitest';
import { DefaultLocalStorageService } from './default-localstorage.service'; import { DefaultLocalStorageService } from './default-localstorage.service';
/**
* if use jsdom, then use Storage.prototype, https://github.com/jsdom/jsdom/issues/2318
*/
describe('DefaultLocalStorageService', () => { describe('DefaultLocalStorageService', () => {
let service: DefaultLocalStorageService; let service: DefaultLocalStorageService;
@ -18,8 +22,7 @@ describe('DefaultLocalStorageService', () => {
describe('read', () => { describe('read', () => {
it('should call localstorage.getItem', () => { it('should call localstorage.getItem', () => {
// https://github.com/jsdom/jsdom/issues/2318 const spy = vi.spyOn(localStorage, 'getItem');
const spy = vi.spyOn(Storage.prototype, 'getItem');
service.read('henlo'); service.read('henlo');
@ -29,8 +32,7 @@ describe('DefaultLocalStorageService', () => {
describe('write', () => { describe('write', () => {
it('should call localstorage.setItem', () => { it('should call localstorage.setItem', () => {
// https://github.com/jsdom/jsdom/issues/2318 const spy = vi.spyOn(localStorage, 'setItem');
const spy = vi.spyOn(Storage.prototype, 'setItem');
service.write('henlo', 'furiend'); service.write('henlo', 'furiend');
@ -40,8 +42,7 @@ describe('DefaultLocalStorageService', () => {
describe('remove', () => { describe('remove', () => {
it('should call localstorage.removeItem', () => { it('should call localstorage.removeItem', () => {
// https://github.com/jsdom/jsdom/issues/2318 const spy = vi.spyOn(localStorage, 'removeItem');
const spy = vi.spyOn(Storage.prototype, 'removeItem');
service.remove('henlo'); service.remove('henlo');
@ -51,8 +52,7 @@ describe('DefaultLocalStorageService', () => {
describe('clear', () => { describe('clear', () => {
it('should call localstorage.clear', () => { it('should call localstorage.clear', () => {
// https://github.com/jsdom/jsdom/issues/2318 const spy = vi.spyOn(localStorage, 'clear');
const spy = vi.spyOn(Storage.prototype, 'clear');
service.clear(); service.clear();

View File

@ -2,6 +2,9 @@ import { TestBed } from '@/testing';
import { vi } from 'vitest'; import { vi } from 'vitest';
import { DefaultSessionStorageService } from './default-sessionstorage.service'; import { DefaultSessionStorageService } from './default-sessionstorage.service';
/**
* if use jsdom, then use Storage.prototype, https://github.com/jsdom/jsdom/issues/2318
*/
describe('DefaultSessionStorageService', () => { describe('DefaultSessionStorageService', () => {
let service: DefaultSessionStorageService; let service: DefaultSessionStorageService;
@ -18,8 +21,7 @@ describe('DefaultSessionStorageService', () => {
describe('read', () => { describe('read', () => {
it('should call sessionstorage.getItem', () => { it('should call sessionstorage.getItem', () => {
// https://github.com/jsdom/jsdom/issues/2318 const spy = vi.spyOn(sessionStorage, 'getItem');
const spy = vi.spyOn(Storage.prototype, 'getItem');
service.read('henlo'); service.read('henlo');
@ -29,8 +31,7 @@ describe('DefaultSessionStorageService', () => {
describe('write', () => { describe('write', () => {
it('should call sessionstorage.setItem', () => { it('should call sessionstorage.setItem', () => {
// https://github.com/jsdom/jsdom/issues/2318 const spy = vi.spyOn(sessionStorage, 'setItem');
const spy = vi.spyOn(Storage.prototype, 'setItem');
service.write('henlo', 'furiend'); service.write('henlo', 'furiend');
@ -40,8 +41,7 @@ describe('DefaultSessionStorageService', () => {
describe('remove', () => { describe('remove', () => {
it('should call sessionstorage.removeItem', () => { it('should call sessionstorage.removeItem', () => {
// https://github.com/jsdom/jsdom/issues/2318 const spy = vi.spyOn(sessionStorage, 'removeItem');
const spy = vi.spyOn(Storage.prototype, 'removeItem');
service.remove('henlo'); service.remove('henlo');
@ -51,8 +51,7 @@ describe('DefaultSessionStorageService', () => {
describe('clear', () => { describe('clear', () => {
it('should call sessionstorage.clear', () => { it('should call sessionstorage.clear', () => {
// https://github.com/jsdom/jsdom/issues/2318 const spy = vi.spyOn(sessionStorage, 'clear');
const spy = vi.spyOn(Storage.prototype, 'clear');
service.clear(); service.clear();

View File

@ -1,29 +1,13 @@
import type { Provider } from '@outposts/injection-js'; import type { Provider } from '@outposts/injection-js';
import { JSDOM } from 'jsdom'; import {
import { AbstractRouter, type Navigation, type UrlTree } from 'oidc-client-rx'; AbstractRouter,
type UrlTree,
VanillaLocationRouter,
} from 'oidc-client-rx';
export class MockRouter extends AbstractRouter { export class MockRouter extends VanillaLocationRouter {
dom = new JSDOM('', {
url: 'http://localhost',
});
navigation: Navigation = {
extractedUrl: this.parseUrl(this.dom.window.location.href),
};
navigateByUrl(url: string): void {
this.dom.reconfigure({
url: new URL(url, this.dom.window.location.href).href,
});
this.navigation = {
extractedUrl: this.parseUrl(this.dom.window.location.href),
};
}
getCurrentNavigation(): Navigation {
return this.navigation;
}
parseUrl(url: string): UrlTree { parseUrl(url: string): UrlTree {
const u = new URL(url, this.dom.window.location.href); const u = new URL(url, this.document.baseURI);
return `${u.pathname}${u.search}${u.hash}`; return `${u.pathname}${u.search}${u.hash}`;
} }
} }

View File

@ -6,7 +6,7 @@ export default defineConfig({
cacheDir: '.vitest', cacheDir: '.vitest',
test: { test: {
setupFiles: ['src/testing/init-test.ts'], setupFiles: ['src/testing/init-test.ts'],
environment: 'jsdom', environment: 'happy-dom',
include: ['src/**/*.spec.ts'], include: ['src/**/*.spec.ts'],
globals: true, globals: true,
restoreMocks: true, restoreMocks: true,
@ -15,6 +15,14 @@ export default defineConfig({
reporter: ['text', 'json-summary', 'json'], reporter: ['text', 'json-summary', 'json'],
// If you want a coverage reports even if your tests are failing, include the reportOnFailure option // If you want a coverage reports even if your tests are failing, include the reportOnFailure option
reportOnFailure: true, reportOnFailure: true,
exclude: [
'vitest.config.ts',
'playwright.config.ts',
'rslib.config.ts',
'scripts/**',
'examples/**',
'dist/**',
],
}, },
}, },
plugins: [ plugins: [