Skip to content

Commit

Permalink
test: make test-results appear in own dir of each test
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Dec 11, 2023
1 parent 64de7be commit 613996f
Show file tree
Hide file tree
Showing 47 changed files with 154 additions and 9 deletions.
24 changes: 24 additions & 0 deletions scripts/copy-pkg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Script to copy package.json to all test dirs.
* Used once, but can be useful futher.
*
* Usage:
* npx ts-node scripts/copy-pkg
*/
import fs from 'node:fs';

const SOURCE_FILE = 'test/package.json';
const EXCLUDE_DIRS = ['node_modules', 'cjs', 'esm', 'esm-ts'];

const testDirs = fs
.readdirSync('./test', { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.filter((entry) => !EXCLUDE_DIRS.includes(entry.name))
.map((entry) => entry.name);

testDirs.forEach((dir) => {
const dest = `test/${dir}/package.json`;
fs.copyFileSync(SOURCE_FILE, dest);
// eslint-disable-next-line no-console
console.log(`Copied ${SOURCE_FILE} -> ${dest}`);
});
3 changes: 3 additions & 0 deletions test/bdd-syntax-cucumber-style/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/bdd-syntax/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/cli-command-env/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/cli-command-export/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/cli-option-tags/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/cli-option-verbose/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/component-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/cucumber-config-file/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/custom-fixtures/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/custom-world/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/decorators-duplicate-fixture-name/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/decorators-plus-steps/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/decorators-snippets/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/decorators-unsure-fixtures/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/decorators/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/default-world/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/duplicate-steps/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/error-import-test-from-steps/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/error-import-test-not-from-bdd/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/features-root-error/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/features-root/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/fixtures/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
4 changes: 0 additions & 4 deletions test/helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ export function ensureNodeVersion(version) {
}
}

export function removeDir(dir) {
if (fs.existsSync(dir)) fs.rmSync(dir, { recursive: true, force: true });
}

export class TestDir {
constructor(importMeta) {
this.importMeta = importMeta;
Expand Down
3 changes: 3 additions & 0 deletions test/hooks-custom-world/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/hooks-order/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/hooks-tags/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/hooks-timeout/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/i18n/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/no-config-file/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/no-define-bdd-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/no-import-test-from/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/output-dir-structure/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 0 additions & 3 deletions test/package.json

This file was deleted.

3 changes: 3 additions & 0 deletions test/parse-error/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/paths-relative-to-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/quotes/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/report/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 1 addition & 2 deletions test/setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
* Test setup
*/
import { execSync } from 'node:child_process';
import { ensureNodeVersion, getPackageVersion, removeDir } from './helpers.mjs';
import { ensureNodeVersion, getPackageVersion } from './helpers.mjs';

!process.env.CI && ensureNodeVersion(20);
showVersion('@playwright/test');
showVersion('@playwright/experimental-ct-react');
showVersion('@cucumber/cucumber');
removeDir('./test-results');
// must build project before tests as we run tests without ts-node
execSync('npm run build', { stdio: 'inherit' });

Expand Down
3 changes: 3 additions & 0 deletions test/several-projects-no-outputdir/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/several-projects/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/snapshots/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/snippets-cucumber-style/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/snippets-playwright-style/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/use-fixture-error/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/warn-ts-node-register/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}
3 changes: 3 additions & 0 deletions test/without-custom-fixtures/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"description": "This file is required for Playwright to consider this dir as a <package-json dir>. It ensures to load 'playwright-bdd' from './test/node_modules/playwright-bdd' and output './test-results' here to avoid conficts."
}

0 comments on commit 613996f

Please sign in to comment.