summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorSteven Guerrero <stephenguerrero43@gmail.com>2021-12-30 11:18:30 -0500
committerGitHub <noreply@github.com>2021-12-30 17:18:30 +0100
commit39a6c94071ee93642196f1a1952a05b125a55c5c (patch)
tree83775cc34a542230affbc9e3ac647fba03473a2d /cli/tests
parent1adf8ee54529b4e754d4f0513cc7763b3db54199 (diff)
feat(test): Add support for "deno test --compat" (#13235)
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/compat_tests.rs38
-rw-r--r--cli/tests/testdata/compat/test_runner/cjs.js9
-rw-r--r--cli/tests/testdata/compat/test_runner/cjs.out25
-rw-r--r--cli/tests/testdata/compat/test_runner/esm.mjs9
-rw-r--r--cli/tests/testdata/compat/test_runner/esm.out25
-rw-r--r--cli/tests/testdata/compat/test_runner/top_level_assertion_cjs.js4
-rw-r--r--cli/tests/testdata/compat/test_runner/top_level_assertion_cjs.out4
-rw-r--r--cli/tests/testdata/compat/test_runner/top_level_assertion_esm.mjs4
-rw-r--r--cli/tests/testdata/compat/test_runner/top_level_assertion_esm.out4
-rw-r--r--cli/tests/testdata/compat/test_runner/top_level_fail_cjs.js4
-rw-r--r--cli/tests/testdata/compat/test_runner/top_level_fail_cjs.out13
-rw-r--r--cli/tests/testdata/compat/test_runner/top_level_fail_esm.mjs4
-rw-r--r--cli/tests/testdata/compat/test_runner/top_level_fail_esm.out13
13 files changed, 156 insertions, 0 deletions
diff --git a/cli/tests/integration/compat_tests.rs b/cli/tests/integration/compat_tests.rs
index fdd9813f0..714329dc2 100644
--- a/cli/tests/integration/compat_tests.rs
+++ b/cli/tests/integration/compat_tests.rs
@@ -52,6 +52,44 @@ itest!(import_esm_from_cjs {
output_str: Some("function\n"),
});
+itest!(test_runner_cjs {
+ args: "test --compat --unstable -A --quiet compat/test_runner/cjs.js",
+ exit_code: 1,
+ output: "compat/test_runner/cjs.out",
+});
+
+itest!(test_runner_esm {
+ args: "test --compat --unstable -A --quiet compat/test_runner/esm.mjs",
+ exit_code: 1,
+ output: "compat/test_runner/esm.out",
+});
+
+// Top level assertion test mostly just make sure that the test runner finishes correctly on compat mode
+// when there is no tests
+itest!(top_level_assertion_cjs {
+ args: "test --compat --unstable -A --quiet compat/test_runner/top_level_assertion_cjs.js",
+ exit_code: 0,
+ output: "compat/test_runner/top_level_assertion_cjs.out",
+});
+
+itest!(top_level_assertion_esm {
+ args: "test --compat --unstable -A --quiet compat/test_runner/top_level_assertion_esm.mjs",
+ exit_code: 0,
+ output: "compat/test_runner/top_level_assertion_esm.out",
+});
+
+itest!(top_level_fail_cjs {
+ args: "test --compat --unstable -A --quiet compat/test_runner/top_level_fail_cjs.js",
+ exit_code: 1,
+ output: "compat/test_runner/top_level_fail_cjs.out",
+});
+
+itest!(top_level_fail_esm {
+ args: "test --compat --unstable -A --quiet compat/test_runner/top_level_fail_esm.mjs",
+ exit_code: 1,
+ output: "compat/test_runner/top_level_fail_esm.out",
+});
+
#[test]
fn globals_in_repl() {
let (out, _err) = util::run_and_collect_output_with_args(
diff --git a/cli/tests/testdata/compat/test_runner/cjs.js b/cli/tests/testdata/compat/test_runner/cjs.js
new file mode 100644
index 000000000..96a1b5112
--- /dev/null
+++ b/cli/tests/testdata/compat/test_runner/cjs.js
@@ -0,0 +1,9 @@
+const { strictEqual } = require("assert");
+
+Deno.test("Correct assertion", () => {
+ strictEqual(20, 20);
+});
+
+Deno.test("Failed assertion", () => {
+ strictEqual(10, 20);
+});
diff --git a/cli/tests/testdata/compat/test_runner/cjs.out b/cli/tests/testdata/compat/test_runner/cjs.out
new file mode 100644
index 000000000..91298e91e
--- /dev/null
+++ b/cli/tests/testdata/compat/test_runner/cjs.out
@@ -0,0 +1,25 @@
+running 2 tests from [WILDCARD]
+test Correct assertion ... ok ([WILDCARD])
+test Failed assertion ... FAILED ([WILDCARD])
+
+failures:
+
+Failed assertion
+AssertionError [ERR_ASSERTION]: Values are not strictly equal:
+
+
+ [Diff] Actual / Expected
+
+
+- 10
++ 20
+
+[WILDCARD]
+
+failures:
+
+[WILDCARD]Failed assertion
+
+test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
+
+error: Test failed
diff --git a/cli/tests/testdata/compat/test_runner/esm.mjs b/cli/tests/testdata/compat/test_runner/esm.mjs
new file mode 100644
index 000000000..54a9468a4
--- /dev/null
+++ b/cli/tests/testdata/compat/test_runner/esm.mjs
@@ -0,0 +1,9 @@
+import { strictEqual } from "assert";
+
+Deno.test("Correct assertion", () => {
+ strictEqual(20, 20);
+});
+
+Deno.test("Failed assertion", () => {
+ strictEqual(10, 20);
+});
diff --git a/cli/tests/testdata/compat/test_runner/esm.out b/cli/tests/testdata/compat/test_runner/esm.out
new file mode 100644
index 000000000..91298e91e
--- /dev/null
+++ b/cli/tests/testdata/compat/test_runner/esm.out
@@ -0,0 +1,25 @@
+running 2 tests from [WILDCARD]
+test Correct assertion ... ok ([WILDCARD])
+test Failed assertion ... FAILED ([WILDCARD])
+
+failures:
+
+Failed assertion
+AssertionError [ERR_ASSERTION]: Values are not strictly equal:
+
+
+ [Diff] Actual / Expected
+
+
+- 10
++ 20
+
+[WILDCARD]
+
+failures:
+
+[WILDCARD]Failed assertion
+
+test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
+
+error: Test failed
diff --git a/cli/tests/testdata/compat/test_runner/top_level_assertion_cjs.js b/cli/tests/testdata/compat/test_runner/top_level_assertion_cjs.js
new file mode 100644
index 000000000..318e72d86
--- /dev/null
+++ b/cli/tests/testdata/compat/test_runner/top_level_assertion_cjs.js
@@ -0,0 +1,4 @@
+const { notStrictEqual, strictEqual } = require("assert");
+
+notStrictEqual(require.main, module, "The module was loaded as a main module");
+strictEqual(20, 20);
diff --git a/cli/tests/testdata/compat/test_runner/top_level_assertion_cjs.out b/cli/tests/testdata/compat/test_runner/top_level_assertion_cjs.out
new file mode 100644
index 000000000..007d654ab
--- /dev/null
+++ b/cli/tests/testdata/compat/test_runner/top_level_assertion_cjs.out
@@ -0,0 +1,4 @@
+running 0 tests from [WILDCARD]
+
+test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
+
diff --git a/cli/tests/testdata/compat/test_runner/top_level_assertion_esm.mjs b/cli/tests/testdata/compat/test_runner/top_level_assertion_esm.mjs
new file mode 100644
index 000000000..8c217fd55
--- /dev/null
+++ b/cli/tests/testdata/compat/test_runner/top_level_assertion_esm.mjs
@@ -0,0 +1,4 @@
+import assert, { strictEqual } from "assert";
+
+assert(!import.meta.main, "The module was loaded as a main module");
+strictEqual(20, 20);
diff --git a/cli/tests/testdata/compat/test_runner/top_level_assertion_esm.out b/cli/tests/testdata/compat/test_runner/top_level_assertion_esm.out
new file mode 100644
index 000000000..007d654ab
--- /dev/null
+++ b/cli/tests/testdata/compat/test_runner/top_level_assertion_esm.out
@@ -0,0 +1,4 @@
+running 0 tests from [WILDCARD]
+
+test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
+
diff --git a/cli/tests/testdata/compat/test_runner/top_level_fail_cjs.js b/cli/tests/testdata/compat/test_runner/top_level_fail_cjs.js
new file mode 100644
index 000000000..20f809794
--- /dev/null
+++ b/cli/tests/testdata/compat/test_runner/top_level_fail_cjs.js
@@ -0,0 +1,4 @@
+const { notStrictEqual, strictEqual } = require("assert");
+
+notStrictEqual(require.main, module, "The module was loaded as a main module");
+strictEqual(10, 20);
diff --git a/cli/tests/testdata/compat/test_runner/top_level_fail_cjs.out b/cli/tests/testdata/compat/test_runner/top_level_fail_cjs.out
new file mode 100644
index 000000000..2d1471d63
--- /dev/null
+++ b/cli/tests/testdata/compat/test_runner/top_level_fail_cjs.out
@@ -0,0 +1,13 @@
+
+test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
+
+error: Uncaught (in promise) AssertionError: Values are not strictly equal:
+
+
+ [Diff] Actual / Expected
+
+
+- 10
++ 20
+
+[WILDCARD] \ No newline at end of file
diff --git a/cli/tests/testdata/compat/test_runner/top_level_fail_esm.mjs b/cli/tests/testdata/compat/test_runner/top_level_fail_esm.mjs
new file mode 100644
index 000000000..918d8c6a8
--- /dev/null
+++ b/cli/tests/testdata/compat/test_runner/top_level_fail_esm.mjs
@@ -0,0 +1,4 @@
+import assert, { strictEqual } from "assert";
+
+assert(!import.meta.main, "The module was loaded as a main module");
+strictEqual(10, 20);
diff --git a/cli/tests/testdata/compat/test_runner/top_level_fail_esm.out b/cli/tests/testdata/compat/test_runner/top_level_fail_esm.out
new file mode 100644
index 000000000..04baeec2b
--- /dev/null
+++ b/cli/tests/testdata/compat/test_runner/top_level_fail_esm.out
@@ -0,0 +1,13 @@
+
+test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
+
+error: Uncaught AssertionError: Values are not strictly equal:
+
+
+ [Diff] Actual / Expected
+
+
+- 10
++ 20
+
+[WILDCARD] \ No newline at end of file