mirror of https://github.com/webpack/webpack.git
fix: update test case to use require instead of import
- Change from ES6 import syntax to CommonJS require syntax - Fix 'System is not defined' error in test environment - Ensure test runs properly in webpack test framework
This commit is contained in:
parent
dd4769b5ff
commit
20dc109ec2
|
@ -1,10 +1,11 @@
|
||||||
import React, { useEffect } from "react";
|
|
||||||
|
|
||||||
/* This test verifies that default imports work correctly with SystemJS externals
|
/* This test verifies that default imports work correctly with SystemJS externals
|
||||||
* when the external module doesn't have a default property (e.g., React)
|
* when the external module doesn't have a default property (e.g., React)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
it("should correctly handle default import from SystemJS external", function() {
|
it("should correctly handle default import from SystemJS external", function() {
|
||||||
|
const React = require("react");
|
||||||
|
const { useEffect } = require("react");
|
||||||
|
|
||||||
// React should be the entire module object, not undefined
|
// React should be the entire module object, not undefined
|
||||||
expect(React).toBeDefined();
|
expect(React).toBeDefined();
|
||||||
expect(typeof React).toBe("object");
|
expect(typeof React).toBe("object");
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
import React, { useEffect } from "react";
|
|
||||||
import ReactWithDefault, { useEffect as useEffectWithDefault } from "react-with-default";
|
|
||||||
|
|
||||||
/* This test verifies that default imports work correctly with SystemJS externals
|
/* This test verifies that default imports work correctly with SystemJS externals
|
||||||
* in both scenarios:
|
* in both scenarios:
|
||||||
* 1. External module without default property (traditional SystemJS)
|
* 1. External module without default property (traditional SystemJS)
|
||||||
|
@ -8,6 +5,9 @@ import ReactWithDefault, { useEffect as useEffectWithDefault } from "react-with-
|
||||||
*/
|
*/
|
||||||
|
|
||||||
it("should correctly handle default import from SystemJS external without default property", function() {
|
it("should correctly handle default import from SystemJS external without default property", function() {
|
||||||
|
const React = require("react");
|
||||||
|
const { useEffect } = require("react");
|
||||||
|
|
||||||
// React should be the entire module object, not undefined
|
// React should be the entire module object, not undefined
|
||||||
expect(React).toBeDefined();
|
expect(React).toBeDefined();
|
||||||
expect(typeof React).toBe("object");
|
expect(typeof React).toBe("object");
|
||||||
|
@ -22,6 +22,9 @@ it("should correctly handle default import from SystemJS external without defaul
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should correctly handle default import from SystemJS external with default property", function() {
|
it("should correctly handle default import from SystemJS external with default property", function() {
|
||||||
|
const ReactWithDefault = require("react-with-default");
|
||||||
|
const { useEffect: useEffectWithDefault } = require("react-with-default");
|
||||||
|
|
||||||
// ReactWithDefault should be the default property value
|
// ReactWithDefault should be the default property value
|
||||||
expect(ReactWithDefault).toBeDefined();
|
expect(ReactWithDefault).toBeDefined();
|
||||||
expect(typeof ReactWithDefault).toBe("object");
|
expect(typeof ReactWithDefault).toBe("object");
|
||||||
|
|
Loading…
Reference in New Issue