Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Cypress任务为Postgres数据库中的变量赋值时出现问题_Cypress - Fatal编程技术网

使用Cypress任务为Postgres数据库中的变量赋值时出现问题

使用Cypress任务为Postgres数据库中的变量赋值时出现问题,cypress,Cypress,我试图从DB查询的结果中为变量赋值,设置了以下内容 关于Cypress.json { "db": { "host": "localhost", "user": "postgres", "port" : 5432, "password": "postgres", "database": "

我试图从DB查询的结果中为变量赋值,设置了以下内容

关于Cypress.json

{
  "db": {
  "host": "localhost",
  "user": "postgres",
  "port" : 5432,
  "password": "postgres",
  "database": "5.0RC3"
  }
}
关于index.js

const pg = require("pg");
module.exports = (on, config ) => {
  on( "task", {
      query ({ sql, values }) {
        const pool = new pg.Pool(config.db);
        try {
            return pool.query(sql, values)
        } catch (e) {
        }
      }
  });
}
规范文件

/// <reference types="cypress" />

describe('Login', function(){
    it('T01 - Failure Fields', function(){
        cy.visit('https://localhost:8443/Perfo/#/'); // Visiting the website
        cy.task("query", {sql: "SELECT username FROM users "}).then((resp) => {
            const username = resp.username;
        })
    })
})
当我尝试运行spec文件时,我得到了以下错误:

我在cypress.json中提供了正确的用户名和密码,但它显示身份验证错误