mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 21:01:52 +00:00
* start this * commit * mark all failing tests as todo * fasdfad * bundler tests * tests * adjust failing tests to todo * comment out some more tests * png as test
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { expect, test } from "bun:test";
|
|
import { mkdirSync, realpathSync } from "fs";
|
|
import { bunEnv, bunExe } from "harness";
|
|
import { tmpdir } from "os";
|
|
import { join } from "path";
|
|
|
|
test.todo("running a commonjs module works", async () => {
|
|
const dir = join(realpathSync(tmpdir()), "bun-run-test1");
|
|
mkdirSync(dir, { recursive: true });
|
|
await Bun.write(join(dir, "index1.js"), "module.exports = 1; console.log('hello world');");
|
|
let { stdout } = Bun.spawnSync({
|
|
cmd: [bunExe(), join(dir, "index1.js")],
|
|
cwd: dir,
|
|
env: bunEnv,
|
|
});
|
|
expect(stdout.toString("utf8")).toEqual("hello world\n");
|
|
});
|
|
|
|
test("not running with export default class", async () => {
|
|
const dir = join(realpathSync(tmpdir()), "bun-run-test2");
|
|
mkdirSync(dir, { recursive: true });
|
|
await Bun.write(
|
|
join(dir, "index1.js"),
|
|
`// @bun
|
|
class Foo {
|
|
constructor() {
|
|
console.log('hello world');
|
|
}
|
|
};
|
|
Foo[Symbol.for("CommonJS")] = true;
|
|
export default Foo
|
|
`,
|
|
);
|
|
let { stdout } = Bun.spawnSync({
|
|
cmd: [bunExe(), join(dir, "index1.js")],
|
|
cwd: dir,
|
|
env: bunEnv,
|
|
});
|
|
expect(stdout.toString("utf8")).toEqual("");
|
|
});
|