|
| 1 | +import { test } from '@playwright/test' |
| 2 | +import { setupInlineFixture, useFixture } from './fixture' |
| 3 | +import { defineStarterTest } from './starter' |
| 4 | +import fs from 'node:fs' |
| 5 | +import path from 'node:path' |
| 6 | + |
| 7 | +test.describe(() => { |
| 8 | + const root = 'examples/e2e/temp/root' |
| 9 | + |
| 10 | + test.beforeAll(async () => { |
| 11 | + await setupInlineFixture({ |
| 12 | + src: 'examples/starter', |
| 13 | + dest: root, |
| 14 | + files: { |
| 15 | + 'vite.config.base.ts': { cp: 'vite.config.ts' }, |
| 16 | + 'vite.config.ts': /* js */ ` |
| 17 | + import baseConfig from './vite.config.base.ts' |
| 18 | + import path from "node:path"; |
| 19 | + baseConfig.root = "./custom-root"; |
| 20 | + for (const e of Object.values(baseConfig.environments)) { |
| 21 | + e.build.rollupOptions.input.index = path.resolve( |
| 22 | + 'custom-root', |
| 23 | + e.build.rollupOptions.input.index, |
| 24 | + ); |
| 25 | + } |
| 26 | + export default baseConfig; |
| 27 | + `, |
| 28 | + }, |
| 29 | + }) |
| 30 | + fs.mkdirSync(`${root}/custom-root`, { recursive: true }) |
| 31 | + fs.renameSync(`${root}/src`, `${root}/custom-root/src`) |
| 32 | + fs.renameSync(`${root}/public`, `${root}/custom-root/public`) |
| 33 | + }) |
| 34 | + |
| 35 | + test.describe('dev-root', () => { |
| 36 | + const f = useFixture({ root, mode: 'dev' }) |
| 37 | + const oldCreateEditor = f.createEditor |
| 38 | + f.createEditor = (filePath: string) => |
| 39 | + oldCreateEditor(path.resolve(root, 'custom-root', filePath)) |
| 40 | + defineStarterTest(f) |
| 41 | + }) |
| 42 | + |
| 43 | + test.describe('build-root', () => { |
| 44 | + const f = useFixture({ root, mode: 'build' }) |
| 45 | + defineStarterTest(f) |
| 46 | + }) |
| 47 | +}) |
0 commit comments