diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 749441e..feff784 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/playwright.config.ts b/playwright.config.ts index cf87857..18fbc68 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -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({ 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' } }, { diff --git a/tests/baseFixtures.ts b/tests/baseFixtures.ts index 285d19d..be5dbe9 100644 --- a/tests/baseFixtures.ts +++ b/tests/baseFixtures.ts @@ -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; @@ -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'; } diff --git a/tests/component-testing.spec.ts b/tests/component-testing.spec.ts index ffab684..35de7e6 100644 --- a/tests/component-testing.spec.ts +++ b/tests/component-testing.spec.ts @@ -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' }); { diff --git a/tests/integration.spec.ts b/tests/integration.spec.ts index 534811a..865b737 100644 --- a/tests/integration.spec.ts +++ b/tests/integration.spec.ts @@ -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(); @@ -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(); @@ -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 }); @@ -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);