我试图运行cypher查询对来自cypress测试的neo4j数据库。我在想最好的办法是什么。在用cy。task()为这个建议?这将有助于实现这一点。
我试着使用下面的方法运行一个基本的查询,但这似乎不像是Cypress的正确方式,即使查询确实执行:
function runCypher(query) {
const driver = neo4j.driver(Cypress.env('NEO4J_QA'), neo4j.auth.basic(Cypress.env('NEO4J_USER'), Cypress.env('NEO4J_PASSWORD')));
const session = driver.session();
session.run(query);
}
1条答案
按热度按时间hzbexzde1#
查看neo4j-driver的注解,使用Promise API消费记录中的示例似乎很有用。
因此,您的函数只需要返回会话调用并通过
.then()
回调访问结果。你可以在浏览器中使用它,所以我认为你不需要任务。