diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-09-22 23:05:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-23 00:05:42 +0200 |
commit | ef3e4a8f74ea65cfed58c1276696f50a8779f816 (patch) | |
tree | 9c7dd09f51087d525c0354962b215fc33febb57e /tests/specs | |
parent | 0cb00a6e89d83d4e16e6616f7af8819bd894b0da (diff) |
feat: Show hints when using `window` global (#25805)
This commit adds better handling for terminal errors when
`window` global is used. This global is removed in Deno 2,
and while we have lints to help with that, an information and
hints are helpful to guide users to working code.
Ref https://github.com/denoland/deno/issues/25797
Diffstat (limited to 'tests/specs')
-rw-r--r-- | tests/specs/run/window/__test__.jsonc | 19 | ||||
-rw-r--r-- | tests/specs/run/window/window1.js | 1 | ||||
-rw-r--r-- | tests/specs/run/window/window1.out | 7 | ||||
-rw-r--r-- | tests/specs/run/window/window2.js | 1 | ||||
-rw-r--r-- | tests/specs/run/window/window2.out | 7 | ||||
-rw-r--r-- | tests/specs/run/window/window3.js | 1 | ||||
-rw-r--r-- | tests/specs/run/window/window3.out | 7 |
7 files changed, 43 insertions, 0 deletions
diff --git a/tests/specs/run/window/__test__.jsonc b/tests/specs/run/window/__test__.jsonc new file mode 100644 index 000000000..1ee4449b5 --- /dev/null +++ b/tests/specs/run/window/__test__.jsonc @@ -0,0 +1,19 @@ +{ + "tests": { + "window1": { + "args": "run window1.js", + "exitCode": 1, + "output": "window1.out" + }, + "window2": { + "args": "run window2.js", + "exitCode": 1, + "output": "window2.out" + }, + "window3": { + "args": "run window3.js", + "exitCode": 1, + "output": "window3.out" + } + } +} diff --git a/tests/specs/run/window/window1.js b/tests/specs/run/window/window1.js new file mode 100644 index 000000000..a480d4c2c --- /dev/null +++ b/tests/specs/run/window/window1.js @@ -0,0 +1 @@ +"TextEncoder" in window; diff --git a/tests/specs/run/window/window1.out b/tests/specs/run/window/window1.out new file mode 100644 index 000000000..4e1674425 --- /dev/null +++ b/tests/specs/run/window/window1.out @@ -0,0 +1,7 @@ +error: Uncaught (in promise) ReferenceError: window is not defined +"TextEncoder" in window; + ^ + at [WILDCARD]window1.js:1:18 + + info: window global is not available in Deno 2. + hint: Replace `window` with `globalThis`. diff --git a/tests/specs/run/window/window2.js b/tests/specs/run/window/window2.js new file mode 100644 index 000000000..0fdf5dcb9 --- /dev/null +++ b/tests/specs/run/window/window2.js @@ -0,0 +1 @@ +window.atob; diff --git a/tests/specs/run/window/window2.out b/tests/specs/run/window/window2.out new file mode 100644 index 000000000..7d00cd7ed --- /dev/null +++ b/tests/specs/run/window/window2.out @@ -0,0 +1,7 @@ +error: Uncaught (in promise) ReferenceError: window is not defined +window.atob; +^ + at [WILDCARD]window2.js:1:1 + + info: window global is not available in Deno 2. + hint: Replace `window` with `globalThis`. diff --git a/tests/specs/run/window/window3.js b/tests/specs/run/window/window3.js new file mode 100644 index 000000000..24fa32b5a --- /dev/null +++ b/tests/specs/run/window/window3.js @@ -0,0 +1 @@ +window.navigator; diff --git a/tests/specs/run/window/window3.out b/tests/specs/run/window/window3.out new file mode 100644 index 000000000..9a157975f --- /dev/null +++ b/tests/specs/run/window/window3.out @@ -0,0 +1,7 @@ +error: Uncaught (in promise) ReferenceError: window is not defined +window.navigator; +^ + at [WILDCARD]window3.js:1:1 + + info: window global is not available in Deno 2. + hint: Replace `window` with `globalThis`. |