Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: create monorepo e2e spec #1079

Merged
merged 11 commits into from
Jan 6, 2025
Prev Previous commit
Next Next commit
Incorporate #1101
  • Loading branch information
rmarscher committed Jan 5, 2025
commit 358f71dcee6c86ff5752ee2f0a306da5e4dccb0e
28 changes: 15 additions & 13 deletions e2e/monorepo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ import { test, prepareStandaloneSetup } from './utils.js';
const startApp = prepareStandaloneSetup('monorepo');

for (const mode of ['DEV', 'PRD'] as const) {
test.describe(`monorepo: ${mode}`, () => {
let port: number;
let stopApp: () => Promise<void>;
test.beforeAll(async () => {
({ port, stopApp } = await startApp(mode, 'packages/waku-project'));
});
test.afterAll(async () => {
await stopApp();
});
for (const packageManager of ['npm', 'pnpm', 'yarn'] as const) {
test.describe(`monorepo: ${mode}`, () => {
let port: number;
let stopApp: () => Promise<void>;
test.beforeAll(async () => {
({ port, stopApp } = await startApp(mode, packageManager, 'packages/waku-project'));
});
test.afterAll(async () => {
await stopApp();
});

test('renders the home page', async ({ page }) => {
await page.goto(`http://localhost:${port}`);
await expect(page.getByTestId('header')).toHaveText('Waku');
test('renders the home page', async ({ page }) => {
await page.goto(`http://localhost:${port}`);
await expect(page.getByTestId('header')).toHaveText('Waku');
});
});
});
}
}
11 changes: 10 additions & 1 deletion e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ export const prepareNormalSetup = (fixtureName: string) => {
return startApp;
};

const PACKAGE_INSTALL = {
npm: (path: string) => `npm add ${path}`,
pnpm: (path: string) => `pnpm add ${path}`,
yarn: (path: string) => `yarn add ${path}`,
} as const;

export const prepareStandaloneSetup = (fixtureName: string) => {
const wakuDir = fileURLToPath(new URL('../packages/waku', import.meta.url));
const { version } = createRequire(import.meta.url)(
Expand All @@ -151,7 +157,7 @@ export const prepareStandaloneSetup = (fixtureName: string) => {
const tmpDir = process.env.TEMP_DIR || tmpdir();
let standaloneDir: string | undefined;
let built = false;
const startApp = async (mode: 'DEV' | 'PRD' | 'STATIC', packageDir = '') => {
const startApp = async (mode: 'DEV' | 'PRD' | 'STATIC', packageManager: 'npm' | 'pnpm' | 'yarn' = 'npm', packageDir = '') => {
if (!standaloneDir) {
standaloneDir = mkdtempSync(join(tmpDir, fixtureName));
cpSync(fixtureDir, standaloneDir, {
Expand All @@ -164,6 +170,9 @@ export const prepareStandaloneSetup = (fixtureName: string) => {
cwd: wakuDir,
stdio: 'inherit',
});
const wakuPackageTgz = join(standaloneDir, `waku-${version}.tgz`);
const installScript = PACKAGE_INSTALL[packageManager](wakuPackageTgz);
execSync(installScript, { cwd: standaloneDir, stdio: 'inherit' });
execSync(
`npm install --force ${join(standaloneDir, `waku-${version}.tgz`)}`,
{ cwd: standaloneDir, stdio: 'inherit' },
Expand Down
Loading