Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm i -g yarn@latest
- run: npm i -g yarn@1
- run: npm i -g pnpm@8
- run: npm ci
Expand Down
10 changes: 10 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,27 @@
*/
import { defineConfig } from '@playwright/test';
import type { TestFixtures } from './tests/baseFixtures';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';

export default defineConfig<TestFixtures>({
timeout: 120 * 1000,
testDir: './tests',
reporter: 'list',
workers: process.env.CI ? 1 : undefined,
outputDir: fs.mkdtempSync(path.join(os.tmpdir(), 'create-playwright-test-')), // place test dir outside to prevent influece from `yarn.lock` or `package.json` in repo
projects: [
{
name: 'npm',
use: {
packageManager: 'npm'
},
},
{
name: 'yarn-classic',
use: {
packageManager: 'npx yarn@1'
}
},
{
Expand Down
4 changes: 3 additions & 1 deletion tests/baseFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import path from 'path';
import fs from 'fs';
import type { PromptOptions } from '../src/generator';

export type PackageManager = 'npm' | 'pnpm' | 'yarn';
export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'npx yarn@1';

export type TestFixtures = {
packageManager: PackageManager;
Expand Down Expand Up @@ -106,6 +106,8 @@ export function packageManagerToNpxCommand(packageManager: PackageManager): stri
return 'npx';
case 'yarn':
return 'yarn';
case 'npx yarn@1':
return 'npx yarn@1';
case 'pnpm':
return 'pnpm dlx';
}
Expand Down
1 change: 1 addition & 0 deletions tests/component-testing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import path from 'path';
import fs from 'fs';

test('should be able to generate and run a CT React project', async ({ run, dir, exec, packageManager }) => {
test.skip(packageManager === 'yarn');
test.slow();
await run(['--ct'], { installGitHubActions: true, testDir: 'tests', language: 'TypeScript', installPlaywrightDependencies: false, installPlaywrightBrowsers: true, framework: 'react' });
{
Expand Down
8 changes: 5 additions & 3 deletions tests/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const validGitignore = [
].join('\n');

test('should generate a project in the current directory', async ({ run, dir, packageManager }) => {
test.skip(packageManager === 'yarn');
test.slow();
const { stdout } = await run([], { installGitHubActions: true, testDir: 'tests', language: 'TypeScript', installPlaywrightDependencies: false, installPlaywrightBrowsers: true });
expect(fs.existsSync(path.join(dir, 'tests/example.spec.ts'))).toBeTruthy();
Expand Down Expand Up @@ -56,6 +57,7 @@ test('should generate a project in the current directory', async ({ run, dir, pa
});

test('should generate a project in a given directory', async ({ run, dir, packageManager }) => {
test.skip(packageManager === 'yarn');
await run(['foobar'], { installGitHubActions: true, testDir: 'tests', language: 'TypeScript', installPlaywrightDependencies: false, installPlaywrightBrowsers: true });
expect(fs.existsSync(path.join(dir, 'foobar/tests/example.spec.ts'))).toBeTruthy();
expect(fs.existsSync(path.join(dir, 'foobar/package.json'))).toBeTruthy();
Expand Down Expand Up @@ -113,7 +115,7 @@ test('should generate in the root of pnpm workspace', async ({ run, packageManag
});

test('should generate in the root of yarn workspaces', async ({ run, packageManager }) => {
test.skip(packageManager !== 'yarn');
test.skip(packageManager !== 'npx yarn@1');

const dir = test.info().outputDir;
fs.mkdirSync(dir, { recursive: true });
Expand All @@ -126,9 +128,9 @@ test('should generate in the root of yarn workspaces', async ({ run, packageMana
for (const pkg of ['foo', 'bar']) {
const packageDir = path.join(dir, 'packages', pkg);
fs.mkdirSync(packageDir, { recursive: true });
childProcess.execSync('yarn init -y', { cwd: packageDir });
childProcess.execSync(`${packageManager} init -y`, { cwd: packageDir });
}
childProcess.execSync('yarn install', { cwd: dir });
childProcess.execSync(`${packageManager} install`, { cwd: dir });

await run([], { installGitHubActions: false, testDir: 'tests', language: 'TypeScript', installPlaywrightDependencies: false, installPlaywrightBrowsers: false });
assertLockFilesExist(dir, packageManager);
Expand Down