diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/bun.lockb | bin | 163146 -> 162926 bytes | |||
-rw-r--r-- | test/cli/run/run-cjs.test.ts | 2 | ||||
-rw-r--r-- | test/cli/run/run-extensionless.test.ts | 31 | ||||
-rw-r--r-- | test/js/third_party/yargs/package.json | 7 | ||||
-rw-r--r-- | test/js/third_party/yargs/yargs-cjs.test.js | 4 | ||||
-rw-r--r-- | test/package.json | 2 |
6 files changed, 44 insertions, 2 deletions
diff --git a/test/bun.lockb b/test/bun.lockb Binary files differindex f4097bda9..8abf35b6f 100755 --- a/test/bun.lockb +++ b/test/bun.lockb diff --git a/test/cli/run/run-cjs.test.ts b/test/cli/run/run-cjs.test.ts index 34c77d106..4c0d37002 100644 --- a/test/cli/run/run-cjs.test.ts +++ b/test/cli/run/run-cjs.test.ts @@ -4,7 +4,7 @@ import { bunEnv, bunExe } from "harness"; import { tmpdir } from "os"; import { join } from "path"; -test.todo("running a commonjs module works", async () => { +test("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');"); diff --git a/test/cli/run/run-extensionless.test.ts b/test/cli/run/run-extensionless.test.ts new file mode 100644 index 000000000..642c274d9 --- /dev/null +++ b/test/cli/run/run-extensionless.test.ts @@ -0,0 +1,31 @@ +import { expect, test } from "bun:test"; +import { mkdirSync, realpathSync } from "fs"; +import { bunEnv, bunExe } from "harness"; +import { writeFileSync } from "fs"; +import { tmpdir } from "os"; +import { join } from "path"; + +test("running extensionless file works", async () => { + const dir = join(realpathSync(tmpdir()), "bun-run-test1"); + mkdirSync(dir, { recursive: true }); + await Bun.write(join(dir, "cool"), "const x: Test = 2; console.log('hello world');"); + let { stdout } = Bun.spawnSync({ + cmd: [bunExe(), join(dir, "./cool")], + cwd: dir, + env: bunEnv, + }); + expect(stdout.toString("utf8")).toEqual("hello world\n"); +}); + +test("running shebang typescript file works", async () => { + const dir = join(realpathSync(tmpdir()), "bun-run-test2"); + mkdirSync(dir, { recursive: true }); + writeFileSync(join(dir, "cool"), `#!${bunExe()}\nconst x: Test = 2; console.log('hello world');`, { mode: 0o777 }); + + let { stdout } = Bun.spawnSync({ + cmd: [join(dir, "./cool")], + cwd: dir, + env: bunEnv, + }); + expect(stdout.toString("utf8")).toEqual("hello world\n"); +}); diff --git a/test/js/third_party/yargs/package.json b/test/js/third_party/yargs/package.json new file mode 100644 index 000000000..dd7ab02b0 --- /dev/null +++ b/test/js/third_party/yargs/package.json @@ -0,0 +1,7 @@ +{ + "name": "yargs-test", + "version": "1.0.0", + "dependencies": { + "yargs": "17.7.2" + } +} diff --git a/test/js/third_party/yargs/yargs-cjs.test.js b/test/js/third_party/yargs/yargs-cjs.test.js new file mode 100644 index 000000000..06e4d9cb8 --- /dev/null +++ b/test/js/third_party/yargs/yargs-cjs.test.js @@ -0,0 +1,4 @@ +test("yargs/yargs works", () => { + const yargs = require("yargs/yargs"); + expect(yargs).toBeFunction(); +}); diff --git a/test/package.json b/test/package.json index 9e55cc543..07bb9fc37 100644 --- a/test/package.json +++ b/test/package.json @@ -38,7 +38,7 @@ "vitest": "0.32.2", "webpack": "5.88.0", "webpack-cli": "4.7.2", - "mongodb": "6.0.0" + "yargs": "17.7.2" }, "private": true, "scripts": { |