summaryrefslogtreecommitdiff
path: root/std/node/process_test.ts
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2020-09-08 23:37:58 +0800
committerGitHub <noreply@github.com>2020-09-08 11:37:58 -0400
commit11afd071aec2d5ea6eb37a934c0835d8f6b1e764 (patch)
treea07d3266da81183cc2f2c8721459d3e84f663c7b /std/node/process_test.ts
parentac455050ee5de10984a9bd9f704e430ac244cb54 (diff)
test(std/node): make tests runnable from any directory (#7397)
This makes std/node tests runnable from any directory by resolving the testdata directory and files relative to the module directory resolved from import.meta.url.
Diffstat (limited to 'std/node/process_test.ts')
-rw-r--r--std/node/process_test.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/std/node/process_test.ts b/std/node/process_test.ts
index 2674b725f..489a112f3 100644
--- a/std/node/process_test.ts
+++ b/std/node/process_test.ts
@@ -1,4 +1,5 @@
import { assert, assertThrows, assertEquals } from "../testing/asserts.ts";
+import * as path from "../path/mod.ts";
import * as all from "./process.ts";
import { env, argv } from "./process.ts";
@@ -27,7 +28,11 @@ Deno.test({
Deno.test({
name: "process.cwd and process.chdir success",
fn() {
- // this should be run like other tests from directory up
+ assertEquals(process.cwd(), Deno.cwd());
+
+ const moduleDir = path.dirname(path.fromFileUrl(import.meta.url));
+ process.chdir(path.resolve(moduleDir, ".."));
+
assert(process.cwd().match(/\Wstd$/));
process.chdir("node");
assert(process.cwd().match(/\Wnode$/));