I am testing the encoding of url.search(): url = new URL("http://google.com/search/?q=\\") url.search  // should result in '?q=\\' By writing a test where the first two strings are evaluated by the JS engine and the result is compared with the last string: 1    QTest::newRow("base case") 2            << "var url = new URL(\"http://www.google.com/searchq=\\\");" 3               "url.search" 4            << "?q=\\"; In this case I get an error from the engine parsing the string on line 2: "SyntaxError: Expected token `)'" If I instead write:  1    QTest::newRow("base case") 2            << "var url = new URL(\"http://www.google.com/search?q=\\ \");" // space added 3               "url.search" 4            << "?q=\\"; Then there is no parsing error. Both inputs should be valid js strings to pass to the engine (even if the test itself may be wrong).