@neovici/cfg 1.41.0 → 1.43.0
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/package.json +3 -1
- package/web/perform.js +18 -0
- package/web/performer.mjs +24 -0
- package/web/test-runner.mjs +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cfg",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.43.0",
|
|
4
4
|
"description": "Configuration for Neovici packages",
|
|
5
5
|
"homepage": "https://github.com/Neovici/cfg#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -44,11 +44,13 @@
|
|
|
44
44
|
]
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
+
"@playwright/test": "^1.40.1",
|
|
47
48
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
48
49
|
"@typescript-eslint/parser": "^6.0.0",
|
|
49
50
|
"@web/dev-server": "^0.4.0",
|
|
50
51
|
"@web/dev-server-esbuild": "^1.0.0",
|
|
51
52
|
"@web/test-runner": "^0.18.0",
|
|
53
|
+
"@web/test-runner-commands": "^0.9.0",
|
|
52
54
|
"@web/test-runner-playwright": "^0.11.0",
|
|
53
55
|
"eslint": "^8.42.0",
|
|
54
56
|
"eslint-config-prettier": "^9.0.0",
|
package/web/perform.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { executeServerCommand } from '@web/test-runner-commands';
|
|
2
|
+
|
|
3
|
+
let i = 0;
|
|
4
|
+
export const perform = async (fn, ...args) => {
|
|
5
|
+
let result;
|
|
6
|
+
|
|
7
|
+
const resultGrabber = `__grabCommandResult${++i}`;
|
|
8
|
+
window[resultGrabber] = (_result) => (result = _result);
|
|
9
|
+
|
|
10
|
+
await executeServerCommand('cz-perform', {
|
|
11
|
+
fn: fn.toString(),
|
|
12
|
+
args,
|
|
13
|
+
resultGrabber,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
delete window[resultGrabber];
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
const perform = async (payload, context) => {
|
|
4
|
+
// eslint-disable-next-line no-eval
|
|
5
|
+
const fn = eval(payload.fn);
|
|
6
|
+
const result = await fn(context, ...payload.args);
|
|
7
|
+
await context.page.evaluate(
|
|
8
|
+
([grabber, result]) => window[grabber](result),
|
|
9
|
+
[payload.resultGrabber, result],
|
|
10
|
+
);
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const performer = () => ({
|
|
15
|
+
name: 'cz-performer',
|
|
16
|
+
// eslint-disable-next-line max-statements
|
|
17
|
+
async executeCommand({ command, payload, session }) {
|
|
18
|
+
if (command !== 'cz-perform') return;
|
|
19
|
+
if (session.browser.type !== 'playwright') return;
|
|
20
|
+
|
|
21
|
+
const page = session.browser.getPage(session.id);
|
|
22
|
+
return perform(payload, { session, page, expect });
|
|
23
|
+
},
|
|
24
|
+
});
|
package/web/test-runner.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { playwrightLauncher } from '@web/test-runner-playwright';
|
|
2
2
|
import { esbuildPlugin } from '@web/dev-server-esbuild';
|
|
3
|
+
import { nodeResolve } from './rollup.mjs';
|
|
4
|
+
import { performer } from './performer.mjs';
|
|
3
5
|
|
|
4
6
|
export default {
|
|
5
|
-
nodeResolve: true,
|
|
6
7
|
browsers: process.env.HEADED
|
|
7
8
|
? [
|
|
8
9
|
playwrightLauncher({
|
|
@@ -25,5 +26,6 @@ export default {
|
|
|
25
26
|
},
|
|
26
27
|
files: ['**!(node_modules)/*.test.(j|t)s'],
|
|
27
28
|
testFramework: { config: { ui: 'tdd' } },
|
|
28
|
-
|
|
29
|
+
nodeResolve,
|
|
30
|
+
plugins: [esbuildPlugin({ ts: true }), performer()],
|
|
29
31
|
};
|