aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Colin McDonnell <colinmcd94@gmail.com> 2023-06-02 17:43:51 -0700
committerGravatar GitHub <noreply@github.com> 2023-06-02 17:43:51 -0700
commitc4f237572d87fea2de1a3cc307e4df176c48a769 (patch)
tree359bac8c7b660ee1f8515770c0f02c10b2fcdb84
parente20e6957751dbc4a8ff84f25b86ca579eb8d000d (diff)
downloadbun-c4f237572d87fea2de1a3cc307e4df176c48a769.tar.gz
bun-c4f237572d87fea2de1a3cc307e4df176c48a769.tar.zst
bun-c4f237572d87fea2de1a3cc307e4df176c48a769.zip
Update macro/test docs (#3180)
* Add test and fix plugin type * Update docs and config pages
-rw-r--r--docs/cli/test.md11
-rw-r--r--docs/runtime/configuration.md7
-rw-r--r--packages/bun-types/bun.d.ts2
-rw-r--r--test/bundler/bundler_plugin.test.ts28
4 files changed, 39 insertions, 9 deletions
diff --git a/docs/cli/test.md b/docs/cli/test.md
index e76f37cdc..74a241ef2 100644
--- a/docs/cli/test.md
+++ b/docs/cli/test.md
@@ -1,8 +1,9 @@
Bun ships with a fast built-in test runner. Tests are executed with the Bun runtime, and support the following features.
- TypeScript and JSX
-- Snapshot testing
- Lifecycle hooks
+- Snapshot testing
+- UI & DOM testing
- Watch mode with `--watch`
- Script pre-loading with `--preload`
@@ -68,6 +69,14 @@ See [Test > Lifecycle](/docs/test/lifecycle) for complete documentation.
Snapshots are supported by `bun test`. See [Test > Snapshots](/docs/test/snapshots) for complete documentation.
+## UI & DOM testing
+
+Bun is compatible with popular UI testing libraries:
+
+- [HappyDOM](https://github.com/capricorn86/happy-dom)
+- [DOM Testing Library](https://testing-library.com/docs/dom-testing-library/intro/)
+- [React Testing Library](https://testing-library.com/docs/react-testing-library/intro)
+
## Performance
Bun's test runner is fast.
diff --git a/docs/runtime/configuration.md b/docs/runtime/configuration.md
index 8dc2bfe24..e1572c990 100644
--- a/docs/runtime/configuration.md
+++ b/docs/runtime/configuration.md
@@ -63,13 +63,6 @@ logLevel = "debug"
# publicDir = "public"
# external = ["jquery"]
-[macros]
-# Remap any import like this:
-# import {graphql} from 'react-relay';
-# To:
-# import {graphql} from 'macro:bun-macro-relay';
-react-relay = { "graphql" = "bun-macro-relay" }
-
[define]
# Replace any usage of "process.env.bagel" with the string `lox`.
# The values are parsed as JSON, except single-quoted strings are supported and `'undefined'` becomes `undefined` in JS.
diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts
index 079595b19..1bbc89028 100644
--- a/packages/bun-types/bun.d.ts
+++ b/packages/bun-types/bun.d.ts
@@ -2764,7 +2764,7 @@ declare module "bun" {
* ```
*/
namespace?: string;
- external: boolean;
+ external?: boolean;
}
type OnResolveCallback = (
diff --git a/test/bundler/bundler_plugin.test.ts b/test/bundler/bundler_plugin.test.ts
index aabdb495a..f8e5d8d59 100644
--- a/test/bundler/bundler_plugin.test.ts
+++ b/test/bundler/bundler_plugin.test.ts
@@ -122,6 +122,34 @@ describe("bundler", () => {
"/foo.magic": [`123`],
},
});
+ itBundled("plugin/ResolveAndLoadDefaultExport", {
+ todo: true,
+ files: {
+ "index.ts": /* ts */ `
+ import foo from "./foo.magic";
+ console.log(foo);
+ `,
+ "foo.magic": `
+ hello world
+ `,
+ },
+ plugins(builder) {
+ builder.onResolve({ filter: /\.magic$/ }, async args => {
+ return {
+ path: path.resolve(args.importer, args.path),
+ };
+ });
+ builder.onLoad({ filter: /\.magic$/ }, async args => {
+ return {
+ contents: `export default "foo";`,
+ loader: "js",
+ };
+ });
+ },
+ run: {
+ stdout: "foo",
+ },
+ });
// Load Plugin Errors
itBundled("plugin/ResolveThrow", {