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