在赛普拉斯/plugins/index.js我有代码来查询 oracleDB
module.exports = (on, config) => {
on('task', {
'registration': async (email) => {
const oracledb = require('oracledb');
oracledb.initOracleClient({libDir: './oracleClient'});
let result;
let connection;
connection = await oracledb.getConnection( {
user : process.env.ORACLEDB_USER,
password : process.env.ORACLEDB_PASSWORD,
connectString : "localhost/STORE"
});
result = await connection.execute(
"select ..."
);
console.log(result.rows)
var extractedUrlText = JSON.stringify((await result).rows).extract('/VerifiedRegistrationFormView','\"');
console.log('Extracted URL: \r\n' + extractedUrlText);
return cy.wrap(extractedUrlText);
}
});
}
这会在 Node 终端中返回正确提取的 URL。
但是在我的赛普拉斯测试中,当我尝试使用那个 extractedUrlText 字符串值时,我得到了错误cy is not defined:
it('Register a new user', () => {
cy.task('registration', emailAddress, { timeout: 10000 }).then(value => cy.log(value)) // cy is not defined
})
我使用类似的方法来使用返回值并且support/commands.js Cypress.Commands.add()它在那里工作,但不是来自 cy.task() 使用 cy.wrap()
慕尼黑8549860
相关分类