Files
bun.sh/test/cli/run/run-eval.test.ts
Jarred Sumner e848c3f226 Get Bun.write tests to pass on Windows and bun:sqlite tests to pass (#8393)
* 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>
2024-01-23 20:03:56 -08:00

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");
});
});