From 783d8d70d8fb3c0e6c6e6901ff15d9cf58357c8a Mon Sep 17 00:00:00 2001 From: tanhauhau Date: Mon, 22 Apr 2024 16:42:52 +0800 Subject: [PATCH] feat: add test case --- .../playwright.ct-react.spec.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/playwright-test/playwright.ct-react.spec.ts b/tests/playwright-test/playwright.ct-react.spec.ts index 6f1780ce55..fad204b865 100644 --- a/tests/playwright-test/playwright.ct-react.spec.ts +++ b/tests/playwright-test/playwright.ct-react.spec.ts @@ -545,3 +545,30 @@ test('should allow import from shared file', async ({ runInlineTest }) => { expect(result.exitCode).toBe(0); expect(result.passed).toBe(1); }); + +test('should allow import from node modules', async ({ runInlineTest }) => { + const result = await runInlineTest({ + 'playwright.config.ts': playwrightCtConfigText, + 'playwright/index.html': ``, + 'playwright/index.ts': ``, + 'node_modules/test-module/index.js': ` + export function Component() { + return "hello playwright"; + }; + `, + 'node_modules/test-module/package.json': `{ + "name": "test-module", + "main": "./index.js" + }`, + 'src/component.spec.tsx': ` + import { expect, test } from '@playwright/experimental-ct-react'; + import { Component } from 'test-module'; + test('component renders', async ({ mount }) => { + const component = await mount(); + await expect(component).toContainText("hello playwright") + })` + }, { workers: 1 }); + + expect(result.exitCode).toBe(0); + expect(result.passed).toBe(1); +});