@@ -511,3 +511,37 @@ test('should allow props children', async ({ runInlineTest }) => {
511
511
expect ( result . exitCode ) . toBe ( 0 ) ;
512
512
expect ( result . passed ) . toBe ( 1 ) ;
513
513
} ) ;
514
+
515
+ test ( 'should allow import from shared file' , async ( { runInlineTest } ) => {
516
+ const result = await runInlineTest ( {
517
+ 'playwright.config.ts' : playwrightCtConfigText ,
518
+ 'playwright/index.html' : `<script type="module" src="./index.ts"></script>` ,
519
+ 'playwright/index.ts' : `` ,
520
+ 'src/component.tsx' : `
521
+ export const Component = (props: { content: string }) => {
522
+ return <div>{props.content}</div>
523
+ };
524
+ ` ,
525
+ 'src/component.shared.tsx' : `
526
+ export const componentMock = { content: 'This is a content.' };
527
+ ` ,
528
+ 'src/component.render.tsx' : `
529
+ import {Component} from './component';
530
+ import {componentMock} from './component.shared';
531
+ export const ComponentTest = () => {
532
+ return <Component content={componentMock.content} />;
533
+ };
534
+ ` ,
535
+ 'src/component.spec.tsx' : `
536
+ import { expect, test } from '@playwright/experimental-ct-react';
537
+ import { ComponentTest } from './component.render';
538
+ import { componentMock } from './component.shared';
539
+ test('component renders', async ({ mount }) => {
540
+ const component = await mount(<ComponentTest />);
541
+ await expect(component).toContainText(componentMock.content)
542
+ })`
543
+ } , { workers : 1 } ) ;
544
+
545
+ expect ( result . exitCode ) . toBe ( 0 ) ;
546
+ expect ( result . passed ) . toBe ( 1 ) ;
547
+ } ) ;
0 commit comments