webpack/test/configCases/web/fetch-priority-2/index.js

17 lines
582 B
JavaScript
Raw Normal View History

2023-04-23 08:36:14 +08:00
it("should set fetchPriority", () => {
import("./a");
2023-05-24 09:32:37 +08:00
expect(document.head._children).toHaveLength(1);
const script1 = document.head._children[0];
expect(script1._attributes.fetchpriority).toBe("low");
2023-04-23 08:36:14 +08:00
2023-05-24 09:32:37 +08:00
import("./b");
2023-04-23 08:36:14 +08:00
expect(document.head._children).toHaveLength(2);
2023-05-24 09:32:37 +08:00
const script2 = document.head._children[1];
expect(script2._attributes.fetchpriority).toBe("low");
2023-04-23 08:40:29 +08:00
2023-05-24 09:32:37 +08:00
import(/* webpackFetchPriority: "high" */ "./c");
2023-04-23 08:40:29 +08:00
expect(document.head._children).toHaveLength(3);
2023-05-24 09:32:37 +08:00
const script3 = document.head._children[2];
expect(script3._attributes.fetchpriority).toBe("high");
2023-04-23 08:40:29 +08:00
});