Skip to content

Commit 8234fc3

Browse files
committed
added possible fixes for playwright code
1 parent a3b7898 commit 8234fc3

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

core/src/main/kotlin/org/evomaster/core/output/service/ApiTestCaseWriter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ abstract class ApiTestCaseWriter : TestCaseWriter() {
328328
val instruction = when {
329329
format.isJavaOrKotlin() -> ".body(\"${fieldPath}\", nullValue())"
330330
format.isPlaywright() -> "expect(($field)${if (fieldPath.isEmpty()) "" else if (fieldPath.startsWith("[")) fieldPath else ".$fieldPath"}).toBe(null);"
331-
format.isJavaScript() -> "expect(($field)$fieldPath).toBe(null);"
331+
format.isJavaScript() -> "expect($field$fieldPath).toBe(null);" // ($field$)fieldPath
332332
format.isCsharp() -> "Assert.True($responseVariableName$fieldPath == null);"
333333
format.isPython() -> "assert $responseVariableName.json()$fieldPath is None"
334334
else -> throw IllegalStateException("Format not supported yet: $format")
@@ -386,7 +386,7 @@ abstract class ApiTestCaseWriter : TestCaseWriter() {
386386
val assertionContent = if (format.isPython()) {
387387
"assert $responseVariableName.json()$fieldPath == $toPrint"
388388
}else { // javascript
389-
"expect(($field)$fieldPath).toBe($toPrint);"
389+
"expect($field$fieldPath).toBe($toPrint);" // ($field$)fieldPath
390390
}
391391

392392
if (flakyValue == null || flakyValue == value){
@@ -578,7 +578,7 @@ abstract class ApiTestCaseWriter : TestCaseWriter() {
578578
if (format.isPlaywright()) {
579579
"expect(await $responseVariableName.json()).toHaveLength($expectedSize);"
580580
} else {
581-
"expect(($field)$fieldPath.length).toBe($expectedSize);"
581+
"expect($field$fieldPath.length).toBe($expectedSize);" // ($field$)fieldPath
582582
}
583583
}
584584
format.isCsharp() ->

core/src/main/kotlin/org/evomaster/core/output/service/HttpWsTestCaseWriter.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ abstract class HttpWsTestCaseWriter : ApiTestCaseWriter() {
104104
when {
105105
format.isKotlin() -> lines.append("val $resVarName: ValidatableResponse = ")
106106
format.isJava() -> lines.append("ValidatableResponse $resVarName = ")
107-
format.isJavaScript() && format.isPlaywright()-> lines.append("const $resVarName = ")
107+
format.isPlaywright() -> lines.append("const $resVarName = ")
108+
format.isJavaScript() -> lines.append("const $resVarName = ")
108109
format.isPython() -> lines.append("$resVarName = ")
109110
format.isCsharp() -> lines.append("var $resVarName = ")
110111
}
@@ -113,7 +114,7 @@ abstract class HttpWsTestCaseWriter : ApiTestCaseWriter() {
113114
when {
114115
format.isJavaOrKotlin() -> lines.append("given()")
115116
format.isPlaywright() -> lines.append("await request")
116-
format.isJavaScript() && !format.isPlaywright() -> lines.append("await superagent")
117+
format.isJavaScript() -> lines.append("await superagent")
117118
format.isCsharp() -> lines.append("await Client")
118119
format.isPython() -> lines.append("requests \\")
119120
}
@@ -333,7 +334,7 @@ abstract class HttpWsTestCaseWriter : ApiTestCaseWriter() {
333334
}
334335
lines.addEmpty()
335336
lines.add("const body = await $responseVariableName.json();")
336-
lines.add("$responseVariableName.body = body;")
337+
lines.add(" = body;")
337338
lines.addEmpty()
338339
}
339340

0 commit comments

Comments
 (0)