@public-ui/visual-tests 1.7.0-rc.5 → 1.7.0-rc.6
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/dist/index.js +43 -0
- package/package.json +5 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import child_process from 'node:child_process';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import * as crypto from 'crypto';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import portfinder from 'portfinder';
|
|
7
|
+
import * as process from 'process';
|
|
8
|
+
process.env.KOLIBRI_CWD = process.cwd();
|
|
9
|
+
const tempDir = process.env.RUNNER_TEMP || process.env.TMPDIR;
|
|
10
|
+
if (!process.env.THEME_MODULE) {
|
|
11
|
+
throw new Error('Environment variable THEME_MODULE not specified.');
|
|
12
|
+
}
|
|
13
|
+
if (!tempDir) {
|
|
14
|
+
throw new Error('Neither environment variable RUNNER_TEMP or TMPDIR specified.');
|
|
15
|
+
}
|
|
16
|
+
process.env.THEME_MODULE = path.join(process.cwd(), process.env.THEME_MODULE);
|
|
17
|
+
const visualsTestModulePath = fileURLToPath(new URL('..', import.meta.url));
|
|
18
|
+
const binaryPath = fileURLToPath(new URL('../node_modules/.bin', import.meta.url));
|
|
19
|
+
const buildPath = path.join(tempDir, `kolibri-visual-testing-build-${crypto.randomUUID()}`);
|
|
20
|
+
process.env.KOLIBRI_VISUAL_TESTS_BUILD_PATH = buildPath;
|
|
21
|
+
console.log('Building React Sample App...');
|
|
22
|
+
child_process.execFileSync(path.join(binaryPath, 'kolibri-sample-react-test-build'), [buildPath], {
|
|
23
|
+
encoding: 'utf-8',
|
|
24
|
+
});
|
|
25
|
+
console.log(`React Sample App build finished. Directory:`, buildPath);
|
|
26
|
+
void (async () => {
|
|
27
|
+
process.env.KOLIBRI_VISUAL_TEST_PORT = String(await portfinder.getPortPromise());
|
|
28
|
+
const playwright = child_process.spawn(path.join(binaryPath, 'playwright'), ['test', ...process.argv.slice(2)], {
|
|
29
|
+
cwd: visualsTestModulePath,
|
|
30
|
+
});
|
|
31
|
+
playwright.stdout.on('data', (data) => {
|
|
32
|
+
console.log('Playwright: ' + data.toString());
|
|
33
|
+
});
|
|
34
|
+
playwright.stderr.on('data', (data) => {
|
|
35
|
+
console.log('Playwright stderr: ' + data.toString());
|
|
36
|
+
});
|
|
37
|
+
playwright.on('exit', (code) => {
|
|
38
|
+
console.log(`Playwright test finished with exit code ${code}.`);
|
|
39
|
+
console.log('Cleaning up build folder...');
|
|
40
|
+
fs.rmSync(buildPath, { recursive: true, force: true });
|
|
41
|
+
process.exit(code !== null && code !== void 0 ? code : 1);
|
|
42
|
+
});
|
|
43
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@public-ui/visual-tests",
|
|
3
|
-
"version": "1.7.0-rc.
|
|
3
|
+
"version": "1.7.0-rc.6",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"homepage": "https://public-ui.github.io",
|
|
6
6
|
"repository": "https://github.com/public-ui/kolibri",
|
|
@@ -38,9 +38,11 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@playwright/test": "1.37.1",
|
|
41
|
-
"@public-ui/sample-react": "1.7.0-rc.
|
|
41
|
+
"@public-ui/sample-react": "1.7.0-rc.6",
|
|
42
42
|
"http-server": "14.1.1",
|
|
43
43
|
"portfinder": "1.0.32"
|
|
44
44
|
},
|
|
45
|
-
"files": [
|
|
45
|
+
"files": [
|
|
46
|
+
"dist"
|
|
47
|
+
]
|
|
46
48
|
}
|