File tree Expand file tree Collapse file tree 2 files changed +13
-14
lines changed Expand file tree Collapse file tree 2 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -38,11 +38,12 @@ Object.keys(queries).forEach(queryName => {
38
38
} )
39
39
40
40
export const within = async sel => {
41
+ const sanitizedSel = sel . replace ( / " / g, "'" )
41
42
await ClientFunction (
42
43
new Function (
43
44
`
44
- const elem = document.querySelector("${ sel } ");
45
- window.TestCafeTestingLibrary["within_${ sel } "] = DomTestingLibrary.within(elem);
45
+ const elem = document.querySelector("${ sanitizedSel } ");
46
+ window.TestCafeTestingLibrary["within_${ sanitizedSel } "] = DomTestingLibrary.within(elem);
46
47
47
48
` ,
48
49
) ,
@@ -52,21 +53,10 @@ export const within = async sel => {
52
53
Object . keys ( queries ) . forEach ( queryName => {
53
54
container [ queryName ] = Selector (
54
55
new Function (
55
- `return window.TestCafeTestingLibrary["within_${ sel } "].${ queryName } (...arguments)` ,
56
+ `return window.TestCafeTestingLibrary["within_${ sanitizedSel } "].${ queryName } (...arguments)` ,
56
57
) ,
57
58
)
58
59
} )
59
60
60
61
return container
61
- // const container = {}
62
-
63
- // Object.keys(queries).forEach(queryName => {
64
- // container[queryName] = Selector(
65
- // new Function(
66
- // `return DomTestingLibrary.within(document.querySelector("${sel}")).${queryName}(...arguments)`,
67
- // ),
68
- // )
69
- // })
70
-
71
- // return container
72
62
}
Original file line number Diff line number Diff line change @@ -18,3 +18,12 @@ test("queryByPlaceholder doesn't find anything", async t => {
18
18
19
19
await t . expect ( queryByPlaceholderText ( 'Placeholder Text' ) . exists ) . notOk ( )
20
20
} )
21
+
22
+ test ( 'quotes in selector' , async t => {
23
+ const { getByText} = await within ( 'div[id="nested"]' )
24
+
25
+ await t
26
+ . click ( getByText ( 'Button Text' ) )
27
+ . expect ( Selector ( 'button' ) . withExactText ( 'Button Clicked' ) . exists )
28
+ . ok ( )
29
+ } )
You can’t perform that action at this time.
0 commit comments