mirror of
https://github.com/denoland/deno.git
synced 2025-09-28 13:14:48 +00:00
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.
This commit is contained in:
parent
ac455050ee
commit
11afd071ae
5 changed files with 23 additions and 9 deletions
|
@ -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$/));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue