Skip to content

Commit 59bf024

Browse files
authored
test: add coverage for external script in EnvironmentNotSupportAsyncWarning (#20525)
1 parent 4c79ac2 commit 59bf024

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
it("should have warnings for environment not support async/await when using asyncModule", () => {
2-
return import("./reexport").then(({ number, getNumber, importRequest, moduleRequest, promiseRequest }) => {
2+
globalThis.scriptGlobal = "script.js";
3+
return import("./reexport").then(({ number, getNumber, importRequest, moduleRequest, promiseRequest, scriptRequest }) => {
34
expect(number).toBe(1);
45
expect(getNumber()).toBe(42);
56
expect(importRequest).toBe("import.js");
67
expect(moduleRequest).toBe("module.js");
78
expect(promiseRequest).toBe("promise.js");
9+
expect(scriptRequest).toBe("script.js");
810
});
911
});

test/configCases/async-module/environment-not-support-async-warning/reexport.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export { getNumber } from "./wasm.wat"
33
export { default as moduleRequest } from "external-module"
44
export { default as importRequest } from "external-import"
55
export { default as promiseRequest } from "external-promise"
6+
export { default as scriptRequest } from "external-script"
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use strict";
22

3+
const supportsGlobalThis = require("../../../helpers/supportsGlobalThis");
34
const supportsWebAssembly = require("../../../helpers/supportsWebAssembly");
45

5-
module.exports = () => supportsWebAssembly();
6+
module.exports = () => supportsWebAssembly() && supportsGlobalThis();

test/configCases/async-module/environment-not-support-async-warning/warnings.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ module.exports = [
2121
/The generated code contains 'async\/await'/,
2222
/"external promise"/
2323
],
24+
[
25+
{
26+
moduleName: /external "scriptGlobal@https:\/\/example\.com\/script\.js"/
27+
},
28+
/The generated code contains 'async\/await'/,
29+
/"external script"/
30+
],
2431
[
2532
{ moduleName: /wasm\.wat/ },
2633
/The generated code contains 'async\/await'/,

test/configCases/async-module/environment-not-support-async-warning/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ module.exports = {
2121
externals: {
2222
"external-module": ["module module.js", "request"],
2323
"external-import": ["import import.js", "request"],
24-
"external-promise": "promise Promise.resolve('promise.js')"
24+
"external-promise": "promise Promise.resolve('promise.js')",
25+
"external-script": "script scriptGlobal@https://example.com/script.js"
2526
},
2627
experiments: {
2728
asyncWebAssembly: true

0 commit comments

Comments
 (0)