diff options
author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2024-10-15 22:51:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-15 21:51:39 +0000 |
commit | ee904ec06c1a3b3d4e4a87898e777e2f9b587b07 (patch) | |
tree | 87dd34f481c9d35ef9c696599889294269ffff29 /tests | |
parent | 3065dadea3792539f050346c534afc0a7821c2b6 (diff) |
fix: add hint for missing `document` global in terminal error (#26218)
This came up on Discord as a question so I thought it's worth adding a
hint for this as it might be a common pitfall.
---------
Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/specs/run/document/__test__.jsonc | 9 | ||||
-rw-r--r-- | tests/specs/run/document/document.js | 1 | ||||
-rw-r--r-- | tests/specs/run/document/document.out | 8 | ||||
-rw-r--r-- | tests/specs/test/document/__test__.jsonc | 9 | ||||
-rw-r--r-- | tests/specs/test/document/document_test.js | 3 | ||||
-rw-r--r-- | tests/specs/test/document/document_test.out | 22 |
6 files changed, 52 insertions, 0 deletions
diff --git a/tests/specs/run/document/__test__.jsonc b/tests/specs/run/document/__test__.jsonc new file mode 100644 index 000000000..cf20f9e1b --- /dev/null +++ b/tests/specs/run/document/__test__.jsonc @@ -0,0 +1,9 @@ +{ + "tests": { + "document": { + "args": "run document.js", + "exitCode": 1, + "output": "document.out" + } + } +} diff --git a/tests/specs/run/document/document.js b/tests/specs/run/document/document.js new file mode 100644 index 000000000..63e43b72f --- /dev/null +++ b/tests/specs/run/document/document.js @@ -0,0 +1 @@ +document.querySelector("div"); diff --git a/tests/specs/run/document/document.out b/tests/specs/run/document/document.out new file mode 100644 index 000000000..eefedb8f2 --- /dev/null +++ b/tests/specs/run/document/document.out @@ -0,0 +1,8 @@ +error: Uncaught (in promise) ReferenceError: document is not defined +document.querySelector("div"); +^ + at [WILDCARD]document.js:1:1 + + info: document global is not available in Deno. + hint: Use a library like happy-dom, deno_dom, linkedom or JSDom + and setup the document global according to the library documentation. diff --git a/tests/specs/test/document/__test__.jsonc b/tests/specs/test/document/__test__.jsonc new file mode 100644 index 000000000..cf73b4bab --- /dev/null +++ b/tests/specs/test/document/__test__.jsonc @@ -0,0 +1,9 @@ +{ + "tests": { + "document": { + "args": "test document_test.js", + "exitCode": 1, + "output": "document_test.out" + } + } +} diff --git a/tests/specs/test/document/document_test.js b/tests/specs/test/document/document_test.js new file mode 100644 index 000000000..d60d6893c --- /dev/null +++ b/tests/specs/test/document/document_test.js @@ -0,0 +1,3 @@ +Deno.test("document query selector", () => { + document.querySelector("div"); +}); diff --git a/tests/specs/test/document/document_test.out b/tests/specs/test/document/document_test.out new file mode 100644 index 000000000..342cee0e4 --- /dev/null +++ b/tests/specs/test/document/document_test.out @@ -0,0 +1,22 @@ +running 1 test from ./document_test.js +document query selector ... FAILED [WILDCARD] + + ERRORS + +document query selector => ./document_test.js:1:6 +error: ReferenceError: document is not defined + document.querySelector("div"); + ^ + at [WILDCARD]document_test.js:2:3 + + info: document global is not available in Deno. + hint: Use a library like happy-dom, deno_dom, linkedom or JSDom + and setup the document global according to the library documentation. + + FAILURES + +document query selector => ./document_test.js:1:6 + +FAILED | 0 passed | 1 failed ([WILDCARD]) + +error: Test failed |