|
1 | | -import { value as directValue } from "./shared.js"; // non-defer import |
2 | | -import * as deferredShared from /* webpackDefer: true */ "./shared.js"; // defer import |
| 1 | +// The imports live in `entry.js` so this module stays synchronous: an async |
| 2 | +// index registers its tests where the runner cannot await them. |
| 3 | +it("should handle mixed defer/non-defer targets correctly", async () => { |
| 4 | + const { directValue, deferredShared } = await require("./entry.js"); |
3 | 5 |
|
4 | | -import { value as directValueAsync } from "./shared-async.js"; // non-defer import |
5 | | -import * as deferredSharedAsync from /* webpackDefer: true */ "./shared-async.js"; // defer import |
6 | | - |
7 | | -it("should handle mixed defer/non-defer targets correctly", () => { |
8 | | - // Test direct non-defer access |
9 | 6 | expect(typeof directValue).toBe("string"); |
10 | 7 | expect(directValue).toBe("shared-value"); |
11 | | - |
12 | | - // Test deferred access |
| 8 | + |
13 | 9 | expect(typeof deferredShared).toBe("object"); |
14 | 10 | expect(deferredShared).not.toBe(null); |
15 | 11 | expect(deferredShared.value).toBe("shared-value"); |
16 | | - |
| 12 | + |
17 | 13 | // Both should access the same underlying value |
18 | 14 | expect(directValue).toBe(deferredShared.value); |
19 | 15 | }); |
20 | 16 |
|
21 | | -it("should handle mixed defer/non-defer targets with async correctly", () => { |
22 | | - // Test direct non-defer access |
| 17 | +it("should handle mixed defer/non-defer targets with async correctly", async () => { |
| 18 | + const { directValueAsync, deferredSharedAsync } = |
| 19 | + await require("./entry.js"); |
| 20 | + |
23 | 21 | expect(typeof directValueAsync).toBe("string"); |
24 | 22 | expect(directValueAsync).toBe("shared-value-async"); |
25 | 23 |
|
26 | | - // Test deferred access |
27 | 24 | expect(deferredSharedAsync).not.toBeInstanceOf(Promise); |
28 | 25 | ((m) => { |
29 | 26 | expect(m.value).toBe("shared-value-async"); |
|
0 commit comments