summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration_tests.rs15
-rw-r--r--cli/tests/test/deno_test_only.ts.out5
-rw-r--r--cli/tests/test/deno_test_unresolved_promise.out5
-rw-r--r--cli/tests/test/exit_sanitizer_test.out2
-rw-r--r--cli/tests/test/quiet_test.out4
-rw-r--r--cli/tests/test/quiet_test.ts3
-rw-r--r--cli/tests/test/test_finally_cleartimeout.out2
-rw-r--r--cli/tests/test/test_unresolved_promise.js8
-rw-r--r--cli/tests/test/unhandled_rejection.out6
-rw-r--r--cli/tests/test/unhandled_rejection.ts3
-rw-r--r--cli/tests/unit/filter_function_test.ts52
11 files changed, 41 insertions, 64 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index b5e5d1fa6..9c56396b4 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -34,6 +34,9 @@ fn js_unit_tests_lint() {
fn js_unit_tests() {
let _g = util::http_server();
+ // Note that the unit tests are not safe for concurrency and must be run with a concurrency limit
+ // of one because there are some chdir tests in there.
+ // TODO(caspervonb) split these tests into two groups: parallel and serial.
let mut deno = util::deno_cmd()
.current_dir(util::root_path())
.arg("test")
@@ -2438,11 +2441,23 @@ mod integration {
output: "test/deno_test_unresolved_promise.out",
});
+ itest!(unhandled_rejection {
+ args: "test test/unhandled_rejection.ts",
+ exit_code: 1,
+ output: "test/unhandled_rejection.out",
+ });
+
itest!(exit_sanitizer {
args: "test test/exit_sanitizer_test.ts",
output: "test/exit_sanitizer_test.out",
exit_code: 1,
});
+
+ itest!(quiet {
+ args: "test --quiet test/quiet_test.ts",
+ exit_code: 0,
+ output: "test/quiet_test.out",
+ });
}
#[test]
diff --git a/cli/tests/test/deno_test_only.ts.out b/cli/tests/test/deno_test_only.ts.out
index a23f2505c..25a0b1a0c 100644
--- a/cli/tests/test/deno_test_only.ts.out
+++ b/cli/tests/test/deno_test_only.ts.out
@@ -1,7 +1,8 @@
-[WILDCARD]running 1 tests
+[WILDCARD]
+running 1 tests
test def ... ok ([WILDCARD])
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out ([WILDCARD])
FAILED because the "only" option was used
diff --git a/cli/tests/test/deno_test_unresolved_promise.out b/cli/tests/test/deno_test_unresolved_promise.out
index cc4f2985e..e1ec640ab 100644
--- a/cli/tests/test/deno_test_unresolved_promise.out
+++ b/cli/tests/test/deno_test_unresolved_promise.out
@@ -1,4 +1,5 @@
-Check [WILDCARD]
running 2 tests
-test unresolved promise ... in promise
+test unresolved promise ...
+test result: FAILED. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD]
+
error: Module evaluation is still pending but there are no pending ops or dynamic imports. This situation is often caused by unresolved promise.
diff --git a/cli/tests/test/exit_sanitizer_test.out b/cli/tests/test/exit_sanitizer_test.out
index 351453928..25df34b34 100644
--- a/cli/tests/test/exit_sanitizer_test.out
+++ b/cli/tests/test/exit_sanitizer_test.out
@@ -1,4 +1,4 @@
-Check [WILDCARD]/$deno$test.ts
+Check [WILDCARD]/exit_sanitizer_test.ts
running 3 tests
test exit(0) ... FAILED ([WILDCARD])
test exit(1) ... FAILED ([WILDCARD])
diff --git a/cli/tests/test/quiet_test.out b/cli/tests/test/quiet_test.out
new file mode 100644
index 000000000..4b57c50fe
--- /dev/null
+++ b/cli/tests/test/quiet_test.out
@@ -0,0 +1,4 @@
+running 1 tests
+test log ... ok [WILDCARD]
+
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD]
diff --git a/cli/tests/test/quiet_test.ts b/cli/tests/test/quiet_test.ts
new file mode 100644
index 000000000..e98e6797a
--- /dev/null
+++ b/cli/tests/test/quiet_test.ts
@@ -0,0 +1,3 @@
+Deno.test("log", function () {
+ console.log("log");
+});
diff --git a/cli/tests/test/test_finally_cleartimeout.out b/cli/tests/test/test_finally_cleartimeout.out
index c88b8242b..ddad7cce9 100644
--- a/cli/tests/test/test_finally_cleartimeout.out
+++ b/cli/tests/test/test_finally_cleartimeout.out
@@ -1,4 +1,4 @@
-Check [WILDCARD]/$deno$test.ts
+Check [WILDCARD]/test_finally_cleartimeout.ts
running 2 tests
test error ... FAILED ([WILDCARD])
test success ... ok ([WILDCARD])
diff --git a/cli/tests/test/test_unresolved_promise.js b/cli/tests/test/test_unresolved_promise.js
index 466b18864..8f50e907a 100644
--- a/cli/tests/test/test_unresolved_promise.js
+++ b/cli/tests/test/test_unresolved_promise.js
@@ -1,15 +1,11 @@
Deno.test({
name: "unresolved promise",
fn() {
- return new Promise((_resolve, _reject) => {
- console.log("in promise");
- });
+ return new Promise((_resolve, _reject) => {});
},
});
Deno.test({
name: "ok",
- fn() {
- console.log("ok test");
- },
+ fn() {},
});
diff --git a/cli/tests/test/unhandled_rejection.out b/cli/tests/test/unhandled_rejection.out
new file mode 100644
index 000000000..27b3865a8
--- /dev/null
+++ b/cli/tests/test/unhandled_rejection.out
@@ -0,0 +1,6 @@
+Check [WILDCARD]
+
+test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD]
+
+error: Uncaught (in promise) Error: rejection
+[WILDCARD]
diff --git a/cli/tests/test/unhandled_rejection.ts b/cli/tests/test/unhandled_rejection.ts
new file mode 100644
index 000000000..396e1c09d
--- /dev/null
+++ b/cli/tests/test/unhandled_rejection.ts
@@ -0,0 +1,3 @@
+new Promise((resolve, reject) => {
+ reject(new Error("rejection"));
+});
diff --git a/cli/tests/unit/filter_function_test.ts b/cli/tests/unit/filter_function_test.ts
deleted file mode 100644
index 2c1d9a7c8..000000000
--- a/cli/tests/unit/filter_function_test.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import { assertEquals, unitTest } from "./test_util.ts";
-
-// @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol
-const { createFilterFn } = Deno[Deno.internal];
-
-unitTest(function filterAsString(): void {
- const filterFn = createFilterFn("my-test");
- const tests = [
- {
- fn(): void {},
- name: "my-test",
- },
- {
- fn(): void {},
- name: "other-test",
- },
- ];
- const filteredTests = tests.filter(filterFn);
- assertEquals(filteredTests.length, 1);
-});
-
-unitTest(function filterAsREGEX(): void {
- const filterFn = createFilterFn("/.+-test/");
- const tests = [
- {
- fn(): void {},
- name: "my-test",
- },
- {
- fn(): void {},
- name: "other-test",
- },
- ];
- const filteredTests = tests.filter(filterFn);
- assertEquals(filteredTests.length, 2);
-});
-
-unitTest(function filterAsEscapedREGEX(): void {
- const filterFn = createFilterFn("/\\w+-test/");
- const tests = [
- {
- fn(): void {},
- name: "my-test",
- },
- {
- fn(): void {},
- name: "other-test",
- },
- ];
- const filteredTests = tests.filter(filterFn);
- assertEquals(filteredTests.length, 2);
-});