Skip to content

Commit bd4a8dc

Browse files
authored
fix: use --preload for Bun instead of --import (#22)
* test: add test case for Bun --preload flag - Added test case verifying buildRunnerCommand uses --preload for Bun - Consistent with @pokujs/dom fix * fix: update test to expect --preload flag for Bun * deps: move @pokujs/dom to dependencies for CI * chore: refresh package-lock.json
1 parent 80367cf commit bd4a8dc

4 files changed

Lines changed: 24 additions & 5 deletions

File tree

package-lock.json

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"provenance": true
8080
},
8181
"dependencies": {
82+
"@pokujs/dom": "^1.3.0",
8283
"@testing-library/dom": "^10.4.1"
8384
},
8485
"peerDependencies": {
@@ -100,7 +101,7 @@
100101
"optional": true
101102
}
102103
},
103-
"devDependencies": {
104+
"devDependencies": {
104105
"@happy-dom/global-registrator": "^20.8.9",
105106
"@ianvs/prettier-plugin-sort-imports": "^4.7.0",
106107
"@pokujs/dom": "^1.3.0",

tests/plugin-command.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ test('buildRunnerCommand injects deno preload and avoids duplicates', async () =
5959
]);
6060
});
6161

62+
test('buildRunnerCommand injects --preload for Bun (not --import)', async () => {
63+
const result = buildRunnerCommand({
64+
runtime: 'bun',
65+
command: ['bun', 'tests/example.test.tsx'],
66+
file: 'tests/example.test.tsx',
67+
domSetupPath: '/tmp/react-dom-setup.ts',
68+
runtimeOptionArgs: [],
69+
});
70+
71+
assert.strictEqual(result.shouldHandle, true);
72+
assert.deepStrictEqual(result.command, [
73+
'bun',
74+
'--preload /tmp/react-dom-setup.ts',
75+
'tests/example.test.tsx',
76+
]);
77+
});
78+
6279
test('buildRunnerCommand leaves unsupported runtime unchanged', async () => {
6380
const original = ['python', 'tests/example.test.tsx'];
6481
const result = buildRunnerCommand({

tests/plugin-internals.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ test('buildRunnerCommand injects dom setup for bun without tsx import', async ()
5959
assert.strictEqual(result.shouldHandle, true);
6060
assert.deepStrictEqual(result.command, [
6161
'bun',
62-
'--import=/tmp/dom-setup.ts',
62+
'--preload /tmp/dom-setup.ts',
6363
'tests/example.test.tsx',
6464
'--poku-react-metrics=1',
6565
]);

0 commit comments

Comments
 (0)