diff --git a/src/generator.ts b/src/generator.ts index 028bc92..d4227e9 100644 --- a/src/generator.ts +++ b/src/generator.ts @@ -273,7 +273,7 @@ export class Generator { gitIgnore = fs.readFileSync(gitIgnorePath, 'utf-8').trimEnd() + '\n'; const valuesToAdd = { 'node_modules/': /^node_modules\/?/m, - '/test-results/': /^test-results\/?$/m, + '/test-results/': /^\/?test-results\/?$/m, '/playwright-report/': /^\/playwright-report\/?$/m, '/blob-report/': /^\/blob-report\/?$/m, '/playwright/.cache/': /^\/playwright\/\.cache\/?$/m diff --git a/tests/integration.spec.ts b/tests/integration.spec.ts index 4206240..afc86dc 100644 --- a/tests/integration.spec.ts +++ b/tests/integration.spec.ts @@ -37,7 +37,7 @@ test('should generate a project in the current directory', async ({ run, dir, pa expect(playwrightConfigContent).toContain('tests'); expect(fs.existsSync(path.join(dir, '.github/workflows/playwright.yml'))).toBeTruthy(); expect(fs.existsSync(path.join(dir, '.gitignore'))).toBeTruthy(); - expect(fs.readFileSync(path.join(dir, '.gitignore'), { encoding: 'utf8' })).toMatch(validGitignore); + expect(fs.readFileSync(path.join(dir, '.gitignore'), { encoding: 'utf8' }).trim()).toBe(validGitignore); if (packageManager === 'npm') { expect(stdout).toContain('Initializing NPM project (npm init -y)…'); expect(stdout).toContain('Installing Playwright Test (npm install --save-dev @playwright/test)…'); @@ -115,7 +115,7 @@ test('should not duplicate gitignore entries', async ({ run, dir }) => { fs.writeFileSync(path.join(dir, '.gitignore'), validGitignore); await run([], { installGitHubActions: false, testDir: 'tests', language: 'TypeScript', installPlaywrightDependencies: false, installPlaywrightBrowsers: false }); - expect(fs.readFileSync(path.join(dir, '.gitignore'), { encoding: 'utf8' })).toMatch(validGitignore); + expect(fs.readFileSync(path.join(dir, '.gitignore'), { encoding: 'utf8' }).trim()).toBe(validGitignore); }) test('should install with "npm ci" in GHA when using npm with package-lock enabled', async ({ dir, run, packageManager }) => {