File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,9 @@ export class Extension implements StringifyExtension {
46
46
switch ( step . type ) {
47
47
case "click" :
48
48
out . appendLine (
49
- `userEvent.click(${ stringifySelector ( step . selectors [ 0 ] ) } ")` ,
49
+ `userEvent.click(${ JSON . stringify (
50
+ stringifySelector ( step . selectors [ 0 ] ) ,
51
+ ) } )`,
50
52
)
51
53
break
52
54
case "navigate" :
@@ -56,7 +58,9 @@ export class Extension implements StringifyExtension {
56
58
out . appendLine ( `expect(location.href).toBe("${ url } ")` )
57
59
}
58
60
if ( title ) {
59
- out . appendLine ( `expect(document.title).toBe("${ title } ")` )
61
+ out . appendLine (
62
+ `expect(document.title).toBe(${ JSON . stringify ( title ) } )` ,
63
+ )
60
64
}
61
65
}
62
66
} else {
@@ -82,9 +86,9 @@ function stringifySelector(selector: Selector) {
82
86
const selectorString = Array . isArray ( selector ) ? selector [ 0 ] : selector
83
87
84
88
if ( selectorString . startsWith ( "aria/" ) ) {
85
- return `screen.getByText(" ${ selectorString . slice ( 5 ) } " )`
89
+ return `screen.getByText(${ JSON . stringify ( selectorString . slice ( 5 ) ) } )`
86
90
} else {
87
- return `document.querySelector(" ${ selectorString } " )`
91
+ return `document.querySelector(${ JSON . stringify ( selectorString ) } )`
88
92
}
89
93
}
90
94
You can’t perform that action at this time.
0 commit comments