fix(ct): restore public folder deployment (#15594)

This commit is contained in:
Pavel Feldman 2022-07-12 15:14:48 -08:00 committed by GitHub
parent a6daf600a9
commit 00848b1bcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 3 deletions

View File

@ -27,7 +27,7 @@ import { assert, calculateSha1 } from 'playwright-core/lib/utils';
import type { AddressInfo } from 'net';
let previewServer: PreviewServer;
const VERSION = 5;
const VERSION = 6;
type CtConfig = {
ctPort?: number;
@ -88,7 +88,6 @@ export function createPlugin(
const sourcesDirty = !buildExists || hasNewComponents || await checkSources(buildInfo);
viteConfig.root = rootDir;
viteConfig.publicDir = false;
viteConfig.preview = { port };
viteConfig.build = {
outDir

View File

@ -26,7 +26,6 @@ test('should work with TSX', async ({ runInlineTest }) => {
//@no-header
export const Button = () => <button>Button</button>;
`,
'src/button.test.tsx': `
//@no-header
import { test, expect } from '@playwright/experimental-ct-react';
@ -321,3 +320,39 @@ test('should respect default property values', async ({ runInlineTest }) => {
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);
});
test('should bundle public folder', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright/index.html': `<script type="module" src="/playwright/index.ts"></script>`,
'playwright/index.ts': `
//@no-header
`,
'public/logo.svg': `
//@no-header
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<circle cx="50" cy="50" r="50"/>
</svg>`,
'src/image.tsx': `
//@no-header
export const Image = () => <img src='/logo.svg' className="App-logo" alt="logo" />;
`,
'src/image.test.tsx': `
//@no-header
import { test, expect } from '@playwright/experimental-ct-react';
import { Image } from './image';
test('pass', async ({ mount, page }) => {
const urls = [];
const [response] = await Promise.all([
page.waitForResponse('**/*.svg'),
mount(<Image></Image>)
]);
const data = await response.body();
await expect(data.toString()).toContain('</svg>');
});
`,
}, { workers: 1 });
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);
});