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
15 changes: 11 additions & 4 deletions src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import path from 'path';
import fs from 'fs';
import path from 'path';

import { prompt } from 'enquirer';
import colors from 'ansi-colors';
import { prompt } from 'enquirer';
import ini from 'ini';

import { executeCommands, createFiles, executeTemplate, Command, languageToFileExtension, getFileExtensionCT } from './utils';
import { type PackageManager, determinePackageManager } from './packageManager';
import { Command, createFiles, executeCommands, executeTemplate, getFileExtensionCT, languageToFileExtension } from './utils';

export type PromptOptions = {
testDir: string,
Expand Down Expand Up @@ -271,7 +271,9 @@ export class Generator {
let gitIgnore = '';
if (fs.existsSync(gitIgnorePath))
gitIgnore = fs.readFileSync(gitIgnorePath, 'utf-8').trimEnd() + '\n';
const valuesToAdd = {

let thisIsTheFirstLineWeAreAdding = true;
const valuesToAdd = {
'node_modules/': /^node_modules\/?/m,
'/test-results/': /^\/?test-results\/?$/m,
'/playwright-report/': /^\/playwright-report\/?$/m,
Expand All @@ -280,6 +282,11 @@ export class Generator {
};
Object.entries(valuesToAdd).forEach(([value, regex]) => {
if (!gitIgnore.match(regex)) {
if (thisIsTheFirstLineWeAreAdding) {
gitIgnore += `\n# Playwright\n`;
thisIsTheFirstLineWeAreAdding = false;
}

gitIgnore += `${value}\n`;
}
});
Expand Down
9 changes: 5 additions & 4 deletions tests/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { test, expect, packageManagerToNpxCommand, assertLockFilesExist } from './baseFixtures';
import path from 'path';
import fs from 'fs';
import childProcess from 'child_process';
import fs from 'fs';
import path from 'path';
import { assertLockFilesExist, expect, packageManagerToNpxCommand, test } from './baseFixtures';

const validGitignore = [
'# Playwright',
'node_modules/',
'/test-results/',
'/playwright-report/',
Expand Down Expand Up @@ -120,7 +121,7 @@ test('should not duplicate gitignore entries', async ({ run, dir }) => {

test('should install with "npm ci" in GHA when using npm with package-lock enabled', async ({ dir, run, packageManager }) => {
test.skip(packageManager !== 'npm');
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add automatic formatting to this repository to reduce noise from changes like this one.


await run([], { installGitHubActions: true, testDir: 'tests', language: 'JavaScript', installPlaywrightDependencies: false, installPlaywrightBrowsers: true });
expect(fs.existsSync(path.join(dir, '.github/workflows/playwright.yml'))).toBeTruthy();

Expand Down