cherry-pick(#23211): chore: allow stub JSX instances in type module
This commit is contained in:
parent
bc9f9b79c8
commit
55eebadfa2
|
|
@ -28,7 +28,10 @@ function jsxs(type, props) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Fragment = {};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Fragment,
|
||||||
jsx,
|
jsx,
|
||||||
jsxs,
|
jsxs,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
21
packages/playwright-test/jsx-runtime.mjs
Normal file
21
packages/playwright-test/jsx-runtime.mjs
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) Microsoft Corporation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import jsxRuntime from './jsx-runtime.js';
|
||||||
|
|
||||||
|
export const jsx = jsxRuntime.jsx;
|
||||||
|
export const jsxs = jsxRuntime.jsxs;
|
||||||
|
export const Fragment = jsxRuntime.Fragment;
|
||||||
|
|
@ -22,7 +22,11 @@
|
||||||
"./lib/internalsForTest": "./lib/internalsForTest.js",
|
"./lib/internalsForTest": "./lib/internalsForTest.js",
|
||||||
"./lib/experimentalLoader": "./lib/experimentalLoader.js",
|
"./lib/experimentalLoader": "./lib/experimentalLoader.js",
|
||||||
"./lib/plugins": "./lib/plugins/index.js",
|
"./lib/plugins": "./lib/plugins/index.js",
|
||||||
"./jsx-runtime": "./jsx-runtime.js",
|
"./jsx-runtime": {
|
||||||
|
"import": "./jsx-runtime.mjs",
|
||||||
|
"require": "./jsx-runtime.js",
|
||||||
|
"default": "./jsx-runtime.js"
|
||||||
|
},
|
||||||
"./lib/util": "./lib/util.js",
|
"./lib/util": "./lib/util.js",
|
||||||
"./lib/utilsBundle": "./lib/utilsBundle.js",
|
"./lib/utilsBundle": "./lib/utilsBundle.js",
|
||||||
"./reporter": "./reporter.js"
|
"./reporter": "./reporter.js"
|
||||||
|
|
|
||||||
|
|
@ -488,6 +488,34 @@ test('should load a jsx/tsx files', async ({ runInlineTest }) => {
|
||||||
expect(exitCode).toBe(0);
|
expect(exitCode).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should load a jsx/tsx files in ESM mode', async ({ runInlineTest }) => {
|
||||||
|
const { exitCode, passed } = await runInlineTest({
|
||||||
|
'package.json': JSON.stringify({
|
||||||
|
type: 'module'
|
||||||
|
}),
|
||||||
|
'playwright.config.ts': `
|
||||||
|
import { defineConfig } from '@playwright/test';
|
||||||
|
export default defineConfig({ projects: [{name: 'foo'}] });
|
||||||
|
`,
|
||||||
|
'a.spec.tsx': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
const component = () => <div></div>;
|
||||||
|
test('succeeds', () => {
|
||||||
|
expect(1 + 1).toBe(2);
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
'b.spec.jsx': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
const component = () => <div></div>;
|
||||||
|
test('succeeds', () => {
|
||||||
|
expect(1 + 1).toBe(2);
|
||||||
|
});
|
||||||
|
`
|
||||||
|
});
|
||||||
|
expect(passed).toBe(2);
|
||||||
|
expect(exitCode).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
test('should load jsx with top-level component', async ({ runInlineTest }) => {
|
test('should load jsx with top-level component', async ({ runInlineTest }) => {
|
||||||
const { exitCode, passed } = await runInlineTest({
|
const { exitCode, passed } = await runInlineTest({
|
||||||
'a.spec.tsx': `
|
'a.spec.tsx': `
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue