deno/cli/tests/unit
Luca Casonato 43b6390629
fix(ext/fetch): handle errors in req body stream (#17081)
Right now an error in a request body stream causes an uncatchable
global promise rejection. This PR fixes this to instead propagate the
error correctly into the promise returned from `fetch`.

It additionally fixes errored readable stream bodies being treated as
successfully completed bodies by Rust.
2022-12-19 12:49:00 +01:00
..
abort_controller_test.ts
blob_test.ts
body_test.ts
broadcast_channel_test.ts
buffer_test.ts
build_test.ts
cache_api_test.ts
chmod_test.ts
chown_test.ts
command_test.ts fix: default to "inherit" for Deno.Command#spawn()'s stdout & stderr (#17025) 2022-12-13 05:12:19 +01:00
console_test.ts
copy_file_test.ts
custom_event_test.ts
dir_test.ts
dom_exception_test.ts
error_stack_test.ts
error_test.ts
esnext_test.ts
event_target_test.ts
event_test.ts
fetch_test.ts fix(ext/fetch): handle errors in req body stream (#17081) 2022-12-19 12:49:00 +01:00
ffi_test.ts
file_test.ts
filereader_test.ts
files_test.ts
flash_test.ts
flock_test.ts fix: default to "inherit" for Deno.Command#spawn()'s stdout & stderr (#17025) 2022-12-13 05:12:19 +01:00
fs_events_test.ts
get_random_values_test.ts
globals_test.ts
headers_test.ts
http_test.ts fix: default to "inherit" for Deno.Command#spawn()'s stdout & stderr (#17025) 2022-12-13 05:12:19 +01:00
internals_test.ts
intl_test.ts
io_test.ts
link_test.ts
make_temp_test.ts
message_channel_test.ts
metrics_test.ts
mkdir_test.ts
navigator_test.ts
net_test.ts chore: fix flaky netListenUnrefAndRef (#16892) 2022-12-02 12:41:52 -05:00
network_interfaces_test.ts
opcall_test.ts
os_test.ts fix(runtime): Deno.memoryUsage().rss should return correct value (#17088) 2022-12-17 23:25:51 +01:00
path_from_url_test.ts
performance_test.ts
permissions_test.ts
process_test.ts
progressevent_test.ts
promise_hooks_test.ts
read_dir_test.ts
read_file_test.ts
read_link_test.ts
read_text_file_test.ts
README.md chore: fix flaky netListenUnrefAndRef (#16892) 2022-12-02 12:41:52 -05:00
real_path_test.ts
ref_unref_test.ts
remove_test.ts
rename_test.ts
request_test.ts
resources_test.ts
response_test.ts
signal_test.ts
stat_test.ts
stdio_test.ts
streams_deprecated.ts
structured_clone_test.ts
symlink_test.ts
sync_test.ts
test_util.ts chore: fix flaky netListenUnrefAndRef (#16892) 2022-12-02 12:41:52 -05:00
testing_test.ts
text_encoding_test.ts
timers_test.ts
tls_test.ts
truncate_test.ts
tty_color_test.ts
tty_test.ts
umask_test.ts
url_search_params_test.ts
url_test.ts
urlpattern_test.ts
utime_test.ts
version_test.ts fix: upgrade to TS 4.9.4 (#17048) 2022-12-14 13:00:51 -05:00
wasm_test.ts
webcrypto_test.ts
webgpu_test.ts
websocket_test.ts
webstorage_test.ts
worker_permissions_test.ts
worker_types.ts
write_file_test.ts feat: support createNew in Deno.writeFile (#17023) 2022-12-13 05:12:49 +01:00
write_text_file_test.ts

Deno runtime tests

Files in this directory are unit tests for Deno runtime.

Testing Deno runtime code requires checking API under different runtime permissions. To accomplish this all tests exercised are created using Deno.test() function.

import {} from "./test_util.ts";

Deno.test(function simpleTestFn(): void {
  // test code here
});

Deno.test(
  {
    ignore: Deno.build.os === "windows",
    permissions: { read: true, write: true },
  },
  function complexTestFn(): void {
    // test code here
  },
);

Running tests

There are two ways to run unit_test_runner.ts:

# Run all tests.
cargo run --bin deno -- test --allow-all --unstable --location=http://js-unit-tests/foo/bar cli/tests/unit/

# Run a specific test module
cargo run --bin deno -- test --allow-all --unstable --location=http://js-unit-tests/foo/bar cli/tests/unit/files_test.ts

Http server

target/debug/test_server is required to run when one's running unit tests. During CI it's spawned automatically, but if you want to run tests manually make sure that server is spawned otherwise there'll be cascade of test failures.