mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
* Move ReadFile and WriteFile to separate file * Use libuv for Bun.write() * Update windows_event_loop.zig * build * Get bun-write tests to pass. Implement Bun.write with two files. * UPdate * Update * Update failing test list * update * More * More * More * More * Mark the rest * ok * oops * Update bun-write.test.js * Update blob.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Dave Caruso <me@paperdave.net> Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { mkdirSync, realpathSync } from "fs";
|
|
import { bunEnv, bunExe } from "harness";
|
|
import { tmpdir } from "os";
|
|
import { join } from "path";
|
|
|
|
describe("bun -e", () => {
|
|
test("it works", async () => {
|
|
let { stdout } = Bun.spawnSync({
|
|
cmd: [bunExe(), "-e", 'console.log("hello world")'],
|
|
env: bunEnv,
|
|
});
|
|
expect(stdout.toString("utf8")).toEqual("hello world\n");
|
|
});
|
|
|
|
test("import, tsx, require in esm, import.meta", async () => {
|
|
const ref = await import("react");
|
|
let { stdout } = Bun.spawnSync({
|
|
cmd: [
|
|
bunExe(),
|
|
"-e",
|
|
'import {version} from "react"; console.log(JSON.stringify({version,file:import.meta.path,require:require("react").version})); console.log(<hello>world</hello>);',
|
|
],
|
|
env: bunEnv,
|
|
});
|
|
const json = {
|
|
version: ref.version,
|
|
file: join(process.cwd(), "[eval]"),
|
|
require: ref.version,
|
|
};
|
|
expect(stdout.toString("utf8")).toEqual(JSON.stringify(json) + "\n<hello>world</hello>\n");
|
|
});
|
|
|
|
test("error has source map info 1", async () => {
|
|
let { stdout, stderr } = Bun.spawnSync({
|
|
cmd: [bunExe(), "-e", '(throw new Error("hi" as 2))'],
|
|
env: bunEnv,
|
|
});
|
|
expect(stderr.toString("utf8")).toInclude('"hi" as 2');
|
|
expect(stderr.toString("utf8")).toInclude("Unexpected throw");
|
|
});
|
|
});
|