mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
This ensures that we can keep overriding what runtime to use by resetting modules while still using the automatic JSX plugin. This is like the "inline requires" transform but just for JSX. I got sick of trying to figure out workarounds to hide the extra stack frame that appears due to the wrappers.
31 lines
821 B
JavaScript
31 lines
821 B
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
'use strict';
|
|
|
|
describe('transform-lazy-jsx-import', () => {
|
|
it('should use the mocked version of the "react" runtime in jsx', () => {
|
|
jest.resetModules();
|
|
const mock = jest.fn(type => 'fakejsx: ' + type);
|
|
if (__DEV__) {
|
|
jest.mock('react/jsx-dev-runtime', () => {
|
|
return {
|
|
jsxDEV: mock,
|
|
};
|
|
});
|
|
} else {
|
|
jest.mock('react/jsx-runtime', () => ({
|
|
jsx: mock,
|
|
jsxs: mock,
|
|
}));
|
|
}
|
|
// eslint-disable-next-line react/react-in-jsx-scope
|
|
const x = <div />;
|
|
expect(x).toBe('fakejsx: div');
|
|
expect(mock).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|