aboutsummaryrefslogtreecommitdiff
path: root/test/cli
diff options
context:
space:
mode:
authorGravatar dave caruso <me@paperdave.net> 2023-06-01 17:37:35 -0400
committerGravatar GitHub <noreply@github.com> 2023-06-01 14:37:35 -0700
commit4378ef8e97839f950ddfa180e466d0a8db187681 (patch)
tree2d99f2bbdd7cd38c0194fe4034f02945e37afb65 /test/cli
parent2c1694f63bc4eb279aa708f216037d2e6204eaf1 (diff)
downloadbun-4378ef8e97839f950ddfa180e466d0a8db187681.tar.gz
bun-4378ef8e97839f950ddfa180e466d0a8db187681.tar.zst
bun-4378ef8e97839f950ddfa180e466d0a8db187681.zip
mark currently known test fails as `.todo` (#3052)
* 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
Diffstat (limited to 'test/cli')
-rw-r--r--test/cli/run/env.test.ts15
-rw-r--r--test/cli/run/preload-test.test.js41
-rw-r--r--test/cli/run/run-cjs.test.ts21
3 files changed, 26 insertions, 51 deletions
diff --git a/test/cli/run/env.test.ts b/test/cli/run/env.test.ts
index 1a4ca7cb7..03d24e93f 100644
--- a/test/cli/run/env.test.ts
+++ b/test/cli/run/env.test.ts
@@ -93,10 +93,10 @@ describe(".env file is loaded", () => {
const dir = tempDirWithFiles("dotenv", {
".env": "FAILED=false\n",
".env.local": "FAILED=true\n",
- "index.test.ts": "console.log(process.env.FAILED, process.env.NODE_ENV);",
+ "index.test.ts": "console.log(process.env.FAILED);",
});
const { stdout } = bunTest(`${dir}/index.test.ts`, {});
- expect(stdout).toBe("false test");
+ expect(stdout).toBe("false");
});
test(".env.development and .env.production ignored when bun test", () => {
const dir = tempDirWithFiles("dotenv", {
@@ -105,10 +105,17 @@ describe(".env file is loaded", () => {
".env.development.local": "FAILED=development.local\n",
".env.production": "FAILED=production\n",
".env.production.local": "FAILED=production.local\n",
- "index.test.ts": "console.log(process.env.FAILED, process.env.NODE_ENV);",
+ "index.test.ts": "console.log(process.env.FAILED);",
});
const { stdout } = bunTest(`${dir}/index.test.ts`);
- expect(stdout).toBe("false test");
+ expect(stdout).toBe("false");
+ });
+ test.todo("NODE_ENV is automatically set to test within bun test", () => {
+ const dir = tempDirWithFiles("dotenv", {
+ "index.test.ts": "console.log(process.env.NODE_ENV);",
+ });
+ const { stdout } = bunTest(`${dir}/index.test.ts`);
+ expect(stdout).toBe("test");
});
});
describe("dotenv priority", () => {
diff --git a/test/cli/run/preload-test.test.js b/test/cli/run/preload-test.test.js
index e0e068f9a..3fa73956c 100644
--- a/test/cli/run/preload-test.test.js
+++ b/test/cli/run/preload-test.test.js
@@ -15,13 +15,7 @@ plugin({
namespace: 'boop'
}
});
- build.onResolve({ namespace: "boop", filter: /.*/ }, async (args) => {
- return {
- path: args.path,
- namespace: 'boop'
- }
- });
- build.onLoad({ namespace: "boop", filter: /.*/ }, async (args) => {
+ build.onLoad({ namespace: "boop", filter: /.*/ }, async (args) => {
return {
contents: '"hello world"',
loader: 'json'
@@ -31,21 +25,20 @@ plugin({
});
`;
-const mainModule = `
- import hey from './hey.txt';
+const mainModule = `import hey from './hey.txt';
- if (hey !== 'hello world') {
- throw new Error('preload test failed');
- }
+if (hey !== 'hello world') {
+ throw new Error('preload test failed, got ' + hey);
+}
- console.log('Test passed');
- process.exit(0);
+console.log('Test passed');
+process.exit(0);
`;
const bunfig = `preload = ["./preload.js"]`;
describe("preload", () => {
- test("works", async () => {
+ test.todo("works", async () => {
const preloadDir = join(realpathSync(tmpdir()), "bun-preload-test");
mkdirSync(preloadDir, { recursive: true });
const preloadPath = join(preloadDir, "preload.js");
@@ -69,13 +62,13 @@ describe("preload", () => {
env: bunEnv,
});
- expect(exitCode).toBe(0);
expect(stderr.toString()).toBe("");
expect(stdout.toString()).toContain("Test passed");
+ expect(exitCode).toBe(0);
}
});
- test("works from CLI", async () => {
+ test.todo("works from CLI", async () => {
const preloadDir = join(realpathSync(tmpdir()), "bun-preload-test4");
mkdirSync(preloadDir, { recursive: true });
const preloadPath = join(preloadDir, "preload.js");
@@ -97,16 +90,16 @@ describe("preload", () => {
env: bunEnv,
});
- expect(exitCode).toBe(0);
expect(stderr.toString()).toBe("");
expect(stdout.toString()).toContain("Test passed");
+ expect(exitCode).toBe(0);
}
});
describe("as entry point", () => {
const preloadModule = `
import {plugin} from 'bun';
-
+console.log('preload')
plugin({
setup(build) {
build.onResolve({ filter: /.*\.txt$/, }, async (args) => {
@@ -115,13 +108,7 @@ plugin({
namespace: 'boop'
}
});
- build.onResolve({ namespace: "boop", filter: /.*/ }, async (args) => {
- return {
- path: args.path,
- namespace: 'boop'
- }
- });
- build.onLoad({ namespace: "boop", filter: /.*/ }, async (args) => {
+ build.onLoad({ namespace: "boop", filter: /.*/ }, async (args) => {
return {
contents: 'console.log("Test passed")',
loader: 'js'
@@ -131,7 +118,7 @@ plugin({
});
`;
- test("works from CLI", async () => {
+ test.todo("works from CLI", async () => {
const preloadDir = join(realpathSync(tmpdir()), "bun-preload-test6");
mkdirSync(preloadDir, { recursive: true });
const preloadPath = join(preloadDir, "preload.js");
diff --git a/test/cli/run/run-cjs.test.ts b/test/cli/run/run-cjs.test.ts
index c957e0d26..5b70f8384 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("running a commonjs module works", async () => {
+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');");
@@ -16,25 +16,6 @@ test("running a commonjs module works", async () => {
expect(stdout.toString("utf8")).toEqual("hello world\n");
});
-test("running with Symbol.for(CommonJS)", async () => {
- const dir = join(realpathSync(tmpdir()), "bun-run-test2");
- mkdirSync(dir, { recursive: true });
- await Bun.write(
- join(dir, "index1.js"),
- `// @bun
-const fn = () => console.log('hello world');
-fn[Symbol.for("CommonJS")] = true;
-export default fn;
-`,
- );
- 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 });