@brillout/test-e2e 0.5.27 → 0.5.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,14 +6,19 @@ const parallel_ci_1 = require("./parallel-ci");
6
6
  // Unit tests `**/*.spec.*` are handled by Vitest
7
7
  const testFilenamePattern = '**/*.test.ts';
8
8
  async function findTestFiles(findFilter) {
9
+ const testFilesAll = await findTestFilesAll();
10
+ const testFiles = (0, utils_1.filterFiles)(testFilesAll, findFilter);
11
+ return testFiles;
12
+ }
13
+ exports.findTestFiles = findTestFiles;
14
+ async function findTestFilesAll() {
9
15
  {
10
16
  const testFiles = (0, parallel_ci_1.getTestFilesForCurrentJob)();
11
17
  if (testFiles)
12
18
  return testFiles;
13
19
  }
14
20
  {
15
- const testFiles = (0, utils_1.findFiles)(testFilenamePattern, findFilter);
21
+ const testFiles = (0, utils_1.findFiles)(testFilenamePattern);
16
22
  return testFiles;
17
23
  }
18
24
  }
19
- exports.findTestFiles = findTestFiles;
@@ -17,14 +17,33 @@ async function testScreenshotFixture({ screenshotFixturePath, doNotTestLocally,
17
17
  const pngPaths = getPngPaths();
18
18
  const pngFixturPath = screenshotFixturePath || pngPaths.pngFixturPath;
19
19
  if (doNotTestLocally && !(0, utils_1.isCI)()) {
20
- console.log(`\n${picocolors_1.default.blue('INFO')} screenshot test skipped (because running test locally, i.e. not in a CI environment): ${pngFixturPath}`);
20
+ console.log(`\n${picocolors_1.default.blue('INFO')} test screenshot fixture ${pngFixturPath} ${picocolors_1.default.bold('skipped')}. (Because ${picocolors_1.default.cyan('doNotTestLocally: true')} and test is being run locally, i.e. not in a CI environment.)`);
21
21
  return;
22
22
  }
23
- if (!fs_1.default.existsSync(pngFixturPath)) {
23
+ const fixtureMissing = !fs_1.default.existsSync(pngFixturPath);
24
+ if (fixtureMissing) {
24
25
  const pngActual = await takeScreenshot();
25
26
  const fileContent = pngjs_1.PNG.sync.write(pngActual);
26
- fs_1.default.writeFileSync(pngFixturPath, fileContent);
27
- throw new Error(`Screenshot fixture missing. Screenshot fixture created at ${pngFixturPath}. You can now re-run the test and the screenshot fixture test will pass.`);
27
+ const { pngExpectPath } = pngPaths;
28
+ const filPath = (0, utils_1.isCI)() ? pngExpectPath : pngFixturPath;
29
+ fs_1.default.writeFileSync(filPath, fileContent);
30
+ console.log('Expect image written at', pngExpectPath);
31
+ const errMsgs = [
32
+ //
33
+ 'Screenshot fixture missing. Screenshot fixture created at:',
34
+ ` ${filPath}`,
35
+ ];
36
+ if (!(0, utils_1.isCI)()) {
37
+ errMsgs.push('You can now re-run the test and the screenshot fixture test will pass.');
38
+ }
39
+ else {
40
+ errMsgs.push([
41
+ 'The screnshot fixture was uploaded as GitHub Workflow Artifact.',
42
+ `(See ${picocolors_1.default.bold('Summary')} > ${picocolors_1.default.bold('Artifacts')}, and make sure to use the ${picocolors_1.default.bold('actions/upload-artifact@v3')} action.)`,
43
+ `Download the fixture, check it into the repository (so that it lives at ${pngFixturPath}), and try again: the test should now pass.`,
44
+ ].join(' '));
45
+ }
46
+ throw new Error(errMsgs.join('\n'));
28
47
  }
29
48
  const pngExpect = pngjs_1.PNG.sync.read(fs_1.default.readFileSync(pngFixturPath));
30
49
  const pngActual = await takeScreenshot();
@@ -39,16 +58,16 @@ async function testScreenshotFixture({ screenshotFixturePath, doNotTestLocally,
39
58
  catch (err) {
40
59
  const { pngExpectPath, pngActualPath, pngDifferPath } = pngPaths;
41
60
  {
42
- console.log('Actual image written at', pngActualPath);
43
61
  fs_1.default.writeFileSync(pngActualPath, pngjs_1.PNG.sync.write(pngActual));
62
+ console.log('Actual image written at', pngActualPath);
44
63
  }
45
64
  {
46
- console.log('Expect image written at', pngExpectPath);
47
65
  fs_1.default.writeFileSync(pngExpectPath, pngjs_1.PNG.sync.write(pngExpect));
66
+ console.log('Expect image written at', pngExpectPath);
48
67
  }
49
68
  {
50
- console.log('Differ image written at', pngDifferPath);
51
69
  fs_1.default.writeFileSync(pngDifferPath, pngjs_1.PNG.sync.write(pngDiffer));
70
+ console.log('Differ image written at', pngDifferPath);
52
71
  }
53
72
  throw err;
54
73
  }
@@ -1,9 +1,11 @@
1
1
  export { findFiles };
2
2
  export { findFilesParseCliArgs };
3
+ export { filterFiles };
3
4
  export type { FindFilter };
4
5
  declare type FindFilter = {
5
6
  terms: string[];
6
7
  exclude: boolean;
7
8
  };
8
- declare function findFiles(pattern: string, findFilter: null | FindFilter): Promise<string[]>;
9
+ declare function findFiles(pattern: string): Promise<string[]>;
10
+ declare function filterFiles(files: string[], findFilter: null | FindFilter): string[];
9
11
  declare function findFilesParseCliArgs(): null | FindFilter;
@@ -3,20 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.findFilesParseCliArgs = exports.findFiles = void 0;
6
+ exports.filterFiles = exports.findFilesParseCliArgs = exports.findFiles = void 0;
7
7
  const fast_glob_1 = __importDefault(require("fast-glob"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const runCommandShortLived_1 = require("./runCommandShortLived");
10
10
  const cwd = process.cwd();
11
11
  let gitFiles;
12
- async function findFiles(pattern, findFilter) {
13
- let files = (await (0, fast_glob_1.default)([pattern], { ignore: ['**/node_modules/**', '**/.git/**'], cwd, dot: true }))
14
- .filter((filePathRelative) => applyFilter(filePathRelative, findFilter))
15
- .map((filePathRelative) => path_1.default.join(cwd, filePathRelative));
12
+ async function findFiles(pattern) {
13
+ let files = (await (0, fast_glob_1.default)([pattern], { ignore: ['**/node_modules/**', '**/.git/**'], cwd, dot: true })).map((filePathRelative) => path_1.default.join(cwd, filePathRelative));
16
14
  files = await filterGitIgnoredFiles(files);
17
15
  return files;
18
16
  }
19
17
  exports.findFiles = findFiles;
18
+ function filterFiles(files, findFilter) {
19
+ return files
20
+ .map((p) => path_1.default.relative(cwd, p))
21
+ .filter((filePathRelative) => applyFilter(filePathRelative, findFilter))
22
+ .map((p) => path_1.default.join(cwd, p));
23
+ }
24
+ exports.filterFiles = filterFiles;
20
25
  async function filterGitIgnoredFiles(files) {
21
26
  if (!gitFiles) {
22
27
  const stdout1 = await (0, runCommandShortLived_1.runCommandShortLived)('git ls-files', { cwd });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.5.27",
3
+ "version": "0.5.29",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -10,15 +10,24 @@
10
10
  "build": "rm -rf dist/ && tsc",
11
11
  "// === Release ===": "",
12
12
  "prepublishOnly": "pnpm run build",
13
- "release": "npm version patch && npm publish && git push && git push --tags"
13
+ "release": "npm version patch && npm publish && git push && git push --tags",
14
+ "========= Clean": "",
15
+ "reset": "git clean -Xdf && pnpm install && pnpm run build",
16
+ "========= Formatting": "",
17
+ "format": "pnpm run format:biome",
18
+ "format:prettier": "git ls-files | egrep '\\.(json|js|jsx|css|ts|tsx|vue|mjs|cjs)$' | grep --invert-match package.json | xargs pnpm exec prettier --write",
19
+ "format:biome": "biome format --write .",
20
+ "format:check": "biome format . || echo Fix formatting by running: $ pnpm run format",
21
+ "========= Only allow pnpm; forbid yarn & npm": "",
22
+ "preinstall": "npx only-allow pnpm"
14
23
  },
15
24
  "dependencies": {
16
25
  "@brillout/part-regex": "^0.1.3",
26
+ "@brillout/picocolors": "^1.0.9",
17
27
  "chai": "^4.3.6",
18
28
  "esbuild": "^0.16.5",
19
29
  "fast-glob": "^3.2.12",
20
30
  "node-fetch": "^2.6.1",
21
- "@brillout/picocolors": "^1.0.9",
22
31
  "pixelmatch": "^5.3.0",
23
32
  "playwright-chromium": "^1.22.2",
24
33
  "pngjs": "^6.0.0",
@@ -26,14 +35,17 @@
26
35
  "strip-ansi": "^6.0.1"
27
36
  },
28
37
  "devDependencies": {
38
+ "@biomejs/biome": "^1.5.3",
29
39
  "@types/chai": "^4.3.3",
30
40
  "@types/node": "^15.6.1",
31
41
  "@types/node-fetch": "^2.5.12",
32
42
  "@types/pixelmatch": "^5.2.4",
33
43
  "@types/pngjs": "^6.0.1",
34
44
  "@types/source-map-support": "^0.5.6",
45
+ "prettier": "^3.2.5",
35
46
  "typescript": "^4.8.3"
36
47
  },
48
+ "packageManager": "pnpm@8.15.1",
37
49
  "repository": "github:brillout/test-e2e",
38
50
  "files": [
39
51
  "dist/"