feat(test): added e2e tests

This commit is contained in:
Corentin Thomasset 2023-04-09 17:59:57 +02:00 committed by Corentin THOMASSET
parent ebfdb64fde
commit ec7cb9351c
11 changed files with 245 additions and 5 deletions

View file

@ -5,6 +5,7 @@ import { fileURLToPath } from 'url';
const currentDirname = dirname(fileURLToPath(import.meta.url));
const toolsDir = join(currentDirname, '..', 'src', 'tools');
// eslint-disable-next-line no-undef
const toolName = process.argv[2];
if (!toolName) {
@ -73,6 +74,28 @@ import { expect, describe, it } from 'vitest';
`,
);
createToolFile(
`${toolName}.e2e.spec.ts`,
`
import { test, expect } from '@playwright/test';
test.describe('Tool - ${toolNameTitleCase}', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/${toolName}');
});
test('Has correct title', async ({ page }) => {
await expect(page).toHaveTitle('${toolNameTitleCase} - IT Tools');
});
test('', async ({ page }) => {
});
});
`,
);
const toolsIndex = join(toolsDir, 'index.ts');
const indexContent = await readFile(toolsIndex, { encoding: 'utf-8' }).then((r) => r.split('\n'));