Skip to content

Commit ba977ef

Browse files
committed
fix: Restore missing PlaywrightReactVueLocator.js and convert to ESM
- File was lost during ESM conversion - Restored from origin/3.x - Converted module.exports to export syntax - Fixed dry-run command tests (13/13 passing) All dry-run tests now pass.
1 parent e0bf8d6 commit ba977ef

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
async function findReact(matcher, locator) {
2+
let _locator = `_react=${locator.react}`;
3+
let props = '';
4+
5+
if (locator.props) {
6+
props += propBuilder(locator.props);
7+
_locator += props;
8+
}
9+
return matcher.locator(_locator).all();
10+
}
11+
12+
async function findVue(matcher, locator) {
13+
let _locator = `_vue=${locator.vue}`;
14+
let props = '';
15+
16+
if (locator.props) {
17+
props += propBuilder(locator.props);
18+
_locator += props;
19+
}
20+
return matcher.locator(_locator).all();
21+
}
22+
23+
async function findByPlaywrightLocator(matcher, locator) {
24+
if (locator && locator.toString().includes(process.env.testIdAttribute)) return matcher.getByTestId(locator.pw.value.split('=')[1]);
25+
return matcher.locator(locator.pw).all();
26+
}
27+
28+
function propBuilder(props) {
29+
let _props = '';
30+
31+
for (const [key, value] of Object.entries(props)) {
32+
if (typeof value === 'object') {
33+
for (const [k, v] of Object.entries(value)) {
34+
_props += `[${key}.${k} = "${v}"]`;
35+
}
36+
} else {
37+
_props += `[${key} = "${value}"]`;
38+
}
39+
}
40+
return _props;
41+
}
42+
43+
export { findReact, findVue, findByPlaywrightLocator };

0 commit comments

Comments
 (0)