运行集成测试时出现错误:
0 passing (17s)
1 failure
1) Registration page
register new users allowed and update status in the database:
TypeError: Net.connect is not a function
at new Connection (webpack:///./node_modules/mysql2/lib/connection.js:50:0)
at ./node_modules/mysql2/index.js.exports.createConnection (webpack:///./node_modules/mysql2/index.js:10:0)
at Context.eval (webpack:///./cypress/integration/registration.spec.js:23:34)
Run Code Online (Sandbox Code Playgroud)
这是我的环境:
MySQL Workbench
MySQL Server 8.0.29
Run Code Online (Sandbox Code Playgroud)
我提出了本地后端,我可以访问数据库。这是我的代码:
const mysql2 = require('mysql2');
describe('Registration page', () => {
beforeEach(() => {
// visit the registration page
cy.visit('http://localhost:3000/registration');
});
it('register new users allowed and update status in the database', () => {
// fill out the registration form …Run Code Online (Sandbox Code Playgroud)