kryptheon 0.1.70 → 0.1.71
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.
- package/LICENSE +38 -38
- package/kryptheon-api.js +131 -13
- package/kryptheon-baselines.js +232 -232
- package/kryptheon-changes.js +222 -222
- package/kryptheon-fonts-OFL.txt +98 -98
- package/kryptheon-probe-reporter.js +29 -29
- package/kryptheon-probe.config.js +37 -37
- package/kryptheon-project.js +600 -600
- package/kryptheon-roles.js +54 -17
- package/kryptheon-selectors.js +301 -301
- package/kryptheon-store.js +334 -334
- package/kryptheon-testfiles.js +98 -98
- package/package.json +4 -2
- package/playwright.config.js +73 -73
package/kryptheon-testfiles.js
CHANGED
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
// Which files in tests/ are Kryptheon's recordings, and what a new one is
|
|
2
|
-
// called.
|
|
3
|
-
//
|
|
4
|
-
// Found in blind round 13 (a TypeScript service with vitest): its own unit
|
|
5
|
-
// test, tests/incidents.test.ts, was taken for a recording - check said it
|
|
6
|
-
// "only opens a page and stops", and the dashboard showed "Record your main
|
|
7
|
-
// flows: Done, 1 recording held" before anything was recorded. Then the
|
|
8
|
-
// first real recording, saved as tests/<name>.spec.js, was picked up by the
|
|
9
|
-
// project's own `npm test` (vitest), which failed on it: "Playwright Test did
|
|
10
|
-
// not expect test() to be called here". A tool that breaks the app's own
|
|
11
|
-
// tests is one nobody keeps.
|
|
12
|
-
//
|
|
13
|
-
// So: a recording is a file that uses Playwright or Kryptheon's fixture -
|
|
14
|
-
// anything else in tests/ belongs to the project and is left alone. And in a
|
|
15
|
-
// project whose unit-test runner collects *.spec.js / *.test.js, a new
|
|
16
|
-
// recording is saved as <name>.kryptheon.js, which only Kryptheon runs.
|
|
17
|
-
|
|
18
|
-
const fs = require('fs');
|
|
19
|
-
const path = require('path');
|
|
20
|
-
|
|
21
|
-
const SPEC_NAME = /\.(spec|test)\.[cm]?[jt]sx?$/;
|
|
22
|
-
const OWN_NAME = /\.kryptheon\.js$/;
|
|
23
|
-
// What a recording imports: Playwright directly (older or hand-made ones,
|
|
24
|
-
// repaired by check) or the fixture - by package name, or by any path that
|
|
25
|
-
// ends in kryptheon-fixture(.js), relative or absolute.
|
|
26
|
-
const USES_PLAYWRIGHT = /(['"`])(?:@playwright\/test|[^'"`\r\n]*kryptheon-fixture(?:\.js)?)\1/;
|
|
27
|
-
|
|
28
|
-
/** Whether this file in tests/ is one of Kryptheon's recordings. */
|
|
29
|
-
function isRecordingFile(name, source) {
|
|
30
|
-
if (!SPEC_NAME.test(name) && !OWN_NAME.test(name)) return false;
|
|
31
|
-
return USES_PLAYWRIGHT.test(String(source || ''));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** The recordings in a tests folder, as paths relative to it. */
|
|
35
|
-
function recordingNames(testsDir) {
|
|
36
|
-
let entries = [];
|
|
37
|
-
try {
|
|
38
|
-
entries = fs.readdirSync(testsDir, { recursive: true });
|
|
39
|
-
} catch (err) {
|
|
40
|
-
try {
|
|
41
|
-
entries = fs.readdirSync(testsDir);
|
|
42
|
-
} catch (err2) {
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return entries.map(String).filter((name) => {
|
|
47
|
-
if (!SPEC_NAME.test(name) && !OWN_NAME.test(name)) return false;
|
|
48
|
-
try {
|
|
49
|
-
return isRecordingFile(name, fs.readFileSync(path.join(testsDir, name), 'utf8'));
|
|
50
|
-
} catch (err) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* The unit-test runner this project uses that would also collect
|
|
58
|
-
* tests/*.spec.js or tests/*.test.js: 'vitest', 'jest', 'mocha' - or null.
|
|
59
|
-
*/
|
|
60
|
-
function unitRunnerOf(projectDir) {
|
|
61
|
-
let pkg = {};
|
|
62
|
-
try {
|
|
63
|
-
pkg = JSON.parse(fs.readFileSync(path.join(projectDir, 'package.json'), 'utf8'));
|
|
64
|
-
} catch (err) {
|
|
65
|
-
pkg = {};
|
|
66
|
-
}
|
|
67
|
-
const deps = Object.assign({}, pkg.dependencies, pkg.devDependencies);
|
|
68
|
-
const script = String((pkg.scripts && pkg.scripts.test) || '');
|
|
69
|
-
let files = [];
|
|
70
|
-
try {
|
|
71
|
-
files = fs.readdirSync(projectDir);
|
|
72
|
-
} catch (err) {
|
|
73
|
-
files = [];
|
|
74
|
-
}
|
|
75
|
-
const has = (re) => files.some((f) => re.test(f));
|
|
76
|
-
if (deps.vitest || /\bvitest\b/.test(script) || has(/^vitest\.config\./)) return 'vitest';
|
|
77
|
-
if (deps.jest || pkg.jest || /\bjest\b/.test(script) || has(/^jest\.config\./)) return 'jest';
|
|
78
|
-
if (deps.mocha || /\bmocha\b/.test(script) || has(/^\.mocharc/)) return 'mocha';
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** What a new recording's file name ends in, in this project. */
|
|
83
|
-
function recordingExtension(projectDir) {
|
|
84
|
-
return unitRunnerOf(projectDir) ? '.kryptheon.js' : '.spec.js';
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** A recording's name without its ending: "login" for login.spec.js or login.kryptheon.js. */
|
|
88
|
-
function bareName(name) {
|
|
89
|
-
return String(name).replace(OWN_NAME, '').replace(/\.spec\.js$/, '');
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
module.exports = {
|
|
93
|
-
isRecordingFile: isRecordingFile,
|
|
94
|
-
recordingNames: recordingNames,
|
|
95
|
-
unitRunnerOf: unitRunnerOf,
|
|
96
|
-
recordingExtension: recordingExtension,
|
|
97
|
-
bareName: bareName,
|
|
98
|
-
};
|
|
1
|
+
// Which files in tests/ are Kryptheon's recordings, and what a new one is
|
|
2
|
+
// called.
|
|
3
|
+
//
|
|
4
|
+
// Found in blind round 13 (a TypeScript service with vitest): its own unit
|
|
5
|
+
// test, tests/incidents.test.ts, was taken for a recording - check said it
|
|
6
|
+
// "only opens a page and stops", and the dashboard showed "Record your main
|
|
7
|
+
// flows: Done, 1 recording held" before anything was recorded. Then the
|
|
8
|
+
// first real recording, saved as tests/<name>.spec.js, was picked up by the
|
|
9
|
+
// project's own `npm test` (vitest), which failed on it: "Playwright Test did
|
|
10
|
+
// not expect test() to be called here". A tool that breaks the app's own
|
|
11
|
+
// tests is one nobody keeps.
|
|
12
|
+
//
|
|
13
|
+
// So: a recording is a file that uses Playwright or Kryptheon's fixture -
|
|
14
|
+
// anything else in tests/ belongs to the project and is left alone. And in a
|
|
15
|
+
// project whose unit-test runner collects *.spec.js / *.test.js, a new
|
|
16
|
+
// recording is saved as <name>.kryptheon.js, which only Kryptheon runs.
|
|
17
|
+
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
const path = require('path');
|
|
20
|
+
|
|
21
|
+
const SPEC_NAME = /\.(spec|test)\.[cm]?[jt]sx?$/;
|
|
22
|
+
const OWN_NAME = /\.kryptheon\.js$/;
|
|
23
|
+
// What a recording imports: Playwright directly (older or hand-made ones,
|
|
24
|
+
// repaired by check) or the fixture - by package name, or by any path that
|
|
25
|
+
// ends in kryptheon-fixture(.js), relative or absolute.
|
|
26
|
+
const USES_PLAYWRIGHT = /(['"`])(?:@playwright\/test|[^'"`\r\n]*kryptheon-fixture(?:\.js)?)\1/;
|
|
27
|
+
|
|
28
|
+
/** Whether this file in tests/ is one of Kryptheon's recordings. */
|
|
29
|
+
function isRecordingFile(name, source) {
|
|
30
|
+
if (!SPEC_NAME.test(name) && !OWN_NAME.test(name)) return false;
|
|
31
|
+
return USES_PLAYWRIGHT.test(String(source || ''));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The recordings in a tests folder, as paths relative to it. */
|
|
35
|
+
function recordingNames(testsDir) {
|
|
36
|
+
let entries = [];
|
|
37
|
+
try {
|
|
38
|
+
entries = fs.readdirSync(testsDir, { recursive: true });
|
|
39
|
+
} catch (err) {
|
|
40
|
+
try {
|
|
41
|
+
entries = fs.readdirSync(testsDir);
|
|
42
|
+
} catch (err2) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return entries.map(String).filter((name) => {
|
|
47
|
+
if (!SPEC_NAME.test(name) && !OWN_NAME.test(name)) return false;
|
|
48
|
+
try {
|
|
49
|
+
return isRecordingFile(name, fs.readFileSync(path.join(testsDir, name), 'utf8'));
|
|
50
|
+
} catch (err) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The unit-test runner this project uses that would also collect
|
|
58
|
+
* tests/*.spec.js or tests/*.test.js: 'vitest', 'jest', 'mocha' - or null.
|
|
59
|
+
*/
|
|
60
|
+
function unitRunnerOf(projectDir) {
|
|
61
|
+
let pkg = {};
|
|
62
|
+
try {
|
|
63
|
+
pkg = JSON.parse(fs.readFileSync(path.join(projectDir, 'package.json'), 'utf8'));
|
|
64
|
+
} catch (err) {
|
|
65
|
+
pkg = {};
|
|
66
|
+
}
|
|
67
|
+
const deps = Object.assign({}, pkg.dependencies, pkg.devDependencies);
|
|
68
|
+
const script = String((pkg.scripts && pkg.scripts.test) || '');
|
|
69
|
+
let files = [];
|
|
70
|
+
try {
|
|
71
|
+
files = fs.readdirSync(projectDir);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
files = [];
|
|
74
|
+
}
|
|
75
|
+
const has = (re) => files.some((f) => re.test(f));
|
|
76
|
+
if (deps.vitest || /\bvitest\b/.test(script) || has(/^vitest\.config\./)) return 'vitest';
|
|
77
|
+
if (deps.jest || pkg.jest || /\bjest\b/.test(script) || has(/^jest\.config\./)) return 'jest';
|
|
78
|
+
if (deps.mocha || /\bmocha\b/.test(script) || has(/^\.mocharc/)) return 'mocha';
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** What a new recording's file name ends in, in this project. */
|
|
83
|
+
function recordingExtension(projectDir) {
|
|
84
|
+
return unitRunnerOf(projectDir) ? '.kryptheon.js' : '.spec.js';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** A recording's name without its ending: "login" for login.spec.js or login.kryptheon.js. */
|
|
88
|
+
function bareName(name) {
|
|
89
|
+
return String(name).replace(OWN_NAME, '').replace(/\.spec\.js$/, '');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = {
|
|
93
|
+
isRecordingFile: isRecordingFile,
|
|
94
|
+
recordingNames: recordingNames,
|
|
95
|
+
unitRunnerOf: unitRunnerOf,
|
|
96
|
+
recordingExtension: recordingExtension,
|
|
97
|
+
bareName: bareName,
|
|
98
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kryptheon",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.71",
|
|
4
4
|
"description": "Record what you do in your app and get plain-language reports when it breaks.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"pg": "^8.23.0"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
|
-
"check": "node kryptheon-store.check.js && node kryptheon-code.check.js && node kryptheon-constdata.check.js && node kryptheon-listitems.check.js && node kryptheon-accept.check.js && node kryptheon-keys.check.js && node kryptheon-dashboard.check.js && node kryptheon-edge.check.js && node kryptheon-reliability.check.js && node kryptheon-fresh.check.js && node kryptheon-payments-dash.check.js && node kryptheon-embedded.check.js && node kryptheon-autostart.check.js && node kryptheon-changes.check.js && node kryptheon-look.check.js && node kryptheon-verify.check.js && node kryptheon-recheck.check.js && node kryptheon-reporter.check.js && node kryptheon-signature.check.js && node kryptheon-signature.stream.check.js && node kryptheon-signature.baseline.check.js && node kryptheon-signature.settle.check.js && node kryptheon-signature.number.check.js && node kryptheon-signature.rows.check.js && node kryptheon-env.check.js && node kryptheon-watchdog.check.js && node kryptheon-phone.check.js && node kryptheon-homedash.check.js && node kryptheon-record.check.js && node kryptheon-selectors.check.js && node kryptheon-recordings.check.js && node kryptheon-testfiles.check.js && node kryptheon-cleanup.check.js && node kryptheon-orphan.check.js && node kryptheon-project.check.js && node kryptheon-setup.check.js && node kryptheon-browser.check.js && node kryptheon-heal.check.js && node kryptheon-load.check.js && node kryptheon-authz.check.js && node kryptheon-roles.check.js && node kryptheon-map.check.js && node kryptheon-api.check.js && node kryptheon-webhook.check.js && node kryptheon-csv.check.js && node kryptheon-witness.check.js && node kryptheon-round34.check.js && node kryptheon-token.check.js && node kryptheon-questions.check.js && node kryptheon-daily.check.js && node kryptheon-live.check.js && node kryptheon-package.check.js && node kryptheon-newer.check.js",
|
|
76
|
+
"check": "node kryptheon-store.check.js && node kryptheon-code.check.js && node kryptheon-constdata.check.js && node kryptheon-listitems.check.js && node kryptheon-accept.check.js && node kryptheon-keys.check.js && node kryptheon-dashboard.check.js && node kryptheon-edge.check.js && node kryptheon-reliability.check.js && node kryptheon-fresh.check.js && node kryptheon-payments-dash.check.js && node kryptheon-embedded.check.js && node kryptheon-autostart.check.js && node kryptheon-changes.check.js && node kryptheon-look.check.js && node kryptheon-verify.check.js && node kryptheon-recheck.check.js && node kryptheon-reporter.check.js && node kryptheon-signature.check.js && node kryptheon-signature.stream.check.js && node kryptheon-signature.baseline.check.js && node kryptheon-signature.settle.check.js && node kryptheon-signature.number.check.js && node kryptheon-signature.rows.check.js && node kryptheon-env.check.js && node kryptheon-watchdog.check.js && node kryptheon-phone.check.js && node kryptheon-homedash.check.js && node kryptheon-record.check.js && node kryptheon-selectors.check.js && node kryptheon-recordings.check.js && node kryptheon-testfiles.check.js && node kryptheon-cleanup.check.js && node kryptheon-orphan.check.js && node kryptheon-project.check.js && node kryptheon-setup.check.js && node kryptheon-browser.check.js && node kryptheon-heal.check.js && node kryptheon-load.check.js && node kryptheon-authz.check.js && node kryptheon-roles.check.js && node kryptheon-map.check.js && node kryptheon-api.check.js && node kryptheon-webhook.check.js && node kryptheon-csv.check.js && node kryptheon-witness.check.js && node kryptheon-round34.check.js && node kryptheon-token.check.js && node kryptheon-questions.check.js && node kryptheon-daily.check.js && node kryptheon-live.check.js && node kryptheon-aim.check.js && node kryptheon-peruser.check.js && node kryptheon-package.check.js && node kryptheon-newer.check.js",
|
|
77
77
|
"check:store": "node kryptheon-store.check.js",
|
|
78
78
|
"check:code": "node kryptheon-code.check.js",
|
|
79
79
|
"check:constdata": "node kryptheon-constdata.check.js",
|
|
@@ -125,6 +125,8 @@
|
|
|
125
125
|
"check:questions": "node kryptheon-questions.check.js",
|
|
126
126
|
"check:daily": "node kryptheon-daily.check.js",
|
|
127
127
|
"check:live": "node kryptheon-live.check.js",
|
|
128
|
+
"check:aim": "node kryptheon-aim.check.js",
|
|
129
|
+
"check:peruser": "node kryptheon-peruser.check.js",
|
|
128
130
|
"check:newer": "node kryptheon-newer.check.js",
|
|
129
131
|
"check:account": "node kryptheon-account.check.js"
|
|
130
132
|
},
|
package/playwright.config.js
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { defineConfig } = require('@playwright/test');
|
|
4
|
-
|
|
5
|
-
// Tool files come from the installed package; anything belonging to the person
|
|
6
|
-
// running the command comes from the folder they ran it in.
|
|
7
|
-
const PACKAGE_DIR = __dirname;
|
|
8
|
-
const USER_DIR = process.cwd();
|
|
9
|
-
|
|
10
|
-
// Node's built-in .env loader (no dependency). This file is re-evaluated in
|
|
11
|
-
// each worker process, so the values reach the tests themselves. A missing
|
|
12
|
-
// .env is not fatal: CI can supply the same variables as real env vars.
|
|
13
|
-
// loadEnvFile only exists from Node 20.12, and the package supports 20.6, so
|
|
14
|
-
// fall back to a small parser rather than silently skipping the file.
|
|
15
|
-
// Deliberately not process.loadEnvFile, and this is the whole reason:
|
|
16
|
-
//
|
|
17
|
-
// On Windows, PowerShell's `Out-File -Encoding utf8` and Notepad's "Save as
|
|
18
|
-
// UTF-8" both write a byte order mark. loadEnvFile keeps it, so the first line
|
|
19
|
-
// of the file defines "KRYPTHEON_PASSWORD" rather than
|
|
20
|
-
// "KRYPTHEON_PASSWORD" - measured, not assumed. The variable then reads as
|
|
21
|
-
// undefined, the recording signs in with an empty password, and the login
|
|
22
|
-
// fails for a reason nothing in the report mentions. The file is right there,
|
|
23
|
-
// so nothing warns either.
|
|
24
|
-
//
|
|
25
|
-
// One parser, shared with the CLI, is also what stops the command that decides
|
|
26
|
-
// whether a password is present from disagreeing with the test that uses it.
|
|
27
|
-
function loadEnv(file) {
|
|
28
|
-
const secrets = require(path.join(PACKAGE_DIR, 'kryptheon-secrets.js'));
|
|
29
|
-
const values = secrets.readEnvFile(file);
|
|
30
|
-
for (const name of Object.keys(values)) {
|
|
31
|
-
// A real environment variable wins over the file - but only a real one.
|
|
32
|
-
// A variable that exists and is empty is how "unset" arrives from a shell
|
|
33
|
-
// or a CI job, and letting that beat the file would leave the password
|
|
34
|
-
// blank with the answer sitting right there on disk.
|
|
35
|
-
if (!secrets.isSet(process.env[name])) process.env[name] = values[name];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
loadEnv(path.join(USER_DIR, '.env'));
|
|
40
|
-
|
|
41
|
-
module.exports = defineConfig({
|
|
42
|
-
// The tests belong to the user, so they are found in their folder.
|
|
43
|
-
testDir: path.join(USER_DIR, 'tests'),
|
|
44
|
-
// Playwright's own pattern, plus <name>.kryptheon.js: the name a recording
|
|
45
|
-
// gets in a project whose unit-test runner would also collect *.spec.js.
|
|
46
|
-
testMatch: ['**/*.@(spec|test).?(c|m)[jt]s?(x)', '**/*.kryptheon.js'],
|
|
47
|
-
// Screenshots and other artefacts default to sitting next to the config,
|
|
48
|
-
// which once installed means inside node_modules. They belong to the user's
|
|
49
|
-
// project, so they go to its store - outside the project, where a commit of
|
|
50
|
-
// "everything that changed" cannot pick them up. Playwright empties this
|
|
51
|
-
// folder at the start of every run, so it never grows.
|
|
52
|
-
outputDir: require(path.join(PACKAGE_DIR, 'kryptheon-store.js')).pathsFor(USER_DIR).testResults,
|
|
53
|
-
// These tests all run against one live site, so in parallel they interfere
|
|
54
|
-
// with each other - a shared logged-in session, and rate limiting on the
|
|
55
|
-
// real endpoints. Serial is the safe default here.
|
|
56
|
-
fullyParallel: false,
|
|
57
|
-
workers: 1,
|
|
58
|
-
// Only the plain-language reporter: Playwright's 'list' reporter prints its
|
|
59
|
-
// own stack-trace block on failure, which is what we are hiding here.
|
|
60
|
-
// Resolved from the package so it is found wherever the command is run.
|
|
61
|
-
reporter: [[path.join(PACKAGE_DIR, 'kryptheon-reporter.js')]],
|
|
62
|
-
use: {
|
|
63
|
-
headless: true,
|
|
64
|
-
// The full Chromium, run headless - not Playwright's separate headless
|
|
65
|
-
// shell. Measured on a Windows 11 machine: the shell took 23 seconds to
|
|
66
|
-
// open each new page, every time, and that time counts against the 30
|
|
67
|
-
// second test timeout. A correct flow longer than about 7 seconds failed,
|
|
68
|
-
// and the report blamed the app. The full Chromium opened the same page in
|
|
69
|
-
// 1.5 seconds. It is also the browser `record` checks is installed.
|
|
70
|
-
channel: 'chromium',
|
|
71
|
-
screenshot: 'only-on-failure',
|
|
72
|
-
},
|
|
73
|
-
});
|
|
1
|
+
// @ts-check
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { defineConfig } = require('@playwright/test');
|
|
4
|
+
|
|
5
|
+
// Tool files come from the installed package; anything belonging to the person
|
|
6
|
+
// running the command comes from the folder they ran it in.
|
|
7
|
+
const PACKAGE_DIR = __dirname;
|
|
8
|
+
const USER_DIR = process.cwd();
|
|
9
|
+
|
|
10
|
+
// Node's built-in .env loader (no dependency). This file is re-evaluated in
|
|
11
|
+
// each worker process, so the values reach the tests themselves. A missing
|
|
12
|
+
// .env is not fatal: CI can supply the same variables as real env vars.
|
|
13
|
+
// loadEnvFile only exists from Node 20.12, and the package supports 20.6, so
|
|
14
|
+
// fall back to a small parser rather than silently skipping the file.
|
|
15
|
+
// Deliberately not process.loadEnvFile, and this is the whole reason:
|
|
16
|
+
//
|
|
17
|
+
// On Windows, PowerShell's `Out-File -Encoding utf8` and Notepad's "Save as
|
|
18
|
+
// UTF-8" both write a byte order mark. loadEnvFile keeps it, so the first line
|
|
19
|
+
// of the file defines "KRYPTHEON_PASSWORD" rather than
|
|
20
|
+
// "KRYPTHEON_PASSWORD" - measured, not assumed. The variable then reads as
|
|
21
|
+
// undefined, the recording signs in with an empty password, and the login
|
|
22
|
+
// fails for a reason nothing in the report mentions. The file is right there,
|
|
23
|
+
// so nothing warns either.
|
|
24
|
+
//
|
|
25
|
+
// One parser, shared with the CLI, is also what stops the command that decides
|
|
26
|
+
// whether a password is present from disagreeing with the test that uses it.
|
|
27
|
+
function loadEnv(file) {
|
|
28
|
+
const secrets = require(path.join(PACKAGE_DIR, 'kryptheon-secrets.js'));
|
|
29
|
+
const values = secrets.readEnvFile(file);
|
|
30
|
+
for (const name of Object.keys(values)) {
|
|
31
|
+
// A real environment variable wins over the file - but only a real one.
|
|
32
|
+
// A variable that exists and is empty is how "unset" arrives from a shell
|
|
33
|
+
// or a CI job, and letting that beat the file would leave the password
|
|
34
|
+
// blank with the answer sitting right there on disk.
|
|
35
|
+
if (!secrets.isSet(process.env[name])) process.env[name] = values[name];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
loadEnv(path.join(USER_DIR, '.env'));
|
|
40
|
+
|
|
41
|
+
module.exports = defineConfig({
|
|
42
|
+
// The tests belong to the user, so they are found in their folder.
|
|
43
|
+
testDir: path.join(USER_DIR, 'tests'),
|
|
44
|
+
// Playwright's own pattern, plus <name>.kryptheon.js: the name a recording
|
|
45
|
+
// gets in a project whose unit-test runner would also collect *.spec.js.
|
|
46
|
+
testMatch: ['**/*.@(spec|test).?(c|m)[jt]s?(x)', '**/*.kryptheon.js'],
|
|
47
|
+
// Screenshots and other artefacts default to sitting next to the config,
|
|
48
|
+
// which once installed means inside node_modules. They belong to the user's
|
|
49
|
+
// project, so they go to its store - outside the project, where a commit of
|
|
50
|
+
// "everything that changed" cannot pick them up. Playwright empties this
|
|
51
|
+
// folder at the start of every run, so it never grows.
|
|
52
|
+
outputDir: require(path.join(PACKAGE_DIR, 'kryptheon-store.js')).pathsFor(USER_DIR).testResults,
|
|
53
|
+
// These tests all run against one live site, so in parallel they interfere
|
|
54
|
+
// with each other - a shared logged-in session, and rate limiting on the
|
|
55
|
+
// real endpoints. Serial is the safe default here.
|
|
56
|
+
fullyParallel: false,
|
|
57
|
+
workers: 1,
|
|
58
|
+
// Only the plain-language reporter: Playwright's 'list' reporter prints its
|
|
59
|
+
// own stack-trace block on failure, which is what we are hiding here.
|
|
60
|
+
// Resolved from the package so it is found wherever the command is run.
|
|
61
|
+
reporter: [[path.join(PACKAGE_DIR, 'kryptheon-reporter.js')]],
|
|
62
|
+
use: {
|
|
63
|
+
headless: true,
|
|
64
|
+
// The full Chromium, run headless - not Playwright's separate headless
|
|
65
|
+
// shell. Measured on a Windows 11 machine: the shell took 23 seconds to
|
|
66
|
+
// open each new page, every time, and that time counts against the 30
|
|
67
|
+
// second test timeout. A correct flow longer than about 7 seconds failed,
|
|
68
|
+
// and the report blamed the app. The full Chromium opened the same page in
|
|
69
|
+
// 1.5 seconds. It is also the browser `record` checks is installed.
|
|
70
|
+
channel: 'chromium',
|
|
71
|
+
screenshot: 'only-on-failure',
|
|
72
|
+
},
|
|
73
|
+
});
|