cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.1k stars 3.19k forks source link

Compatibility Issue with node-oracledb Library #30528

Open merveodabasi opened 3 weeks ago

merveodabasi commented 3 weeks ago

Current behavior

When we run our tests, we encounter the following error message from thenode-oracledb library:

NJS-069: node-oracledb 6.6.0 requires Node.js 14.6 or later.

Cypress reports this error as originating from our test code, causing our tests to automatically fail.

System Details

• Node.js Version: 20.17.0, then upgraded to v22.11.0.

node -v v20.17.0
npm -v 10.8.2
• oracledb Library Version: 6.6.0

Solutions We Have Tried

  1. Node.js Version Update: We upgraded Node.js using nvm, first to 20.17.0 and then to v22.11.0, but the issue persisted.
  2. Reinstalling the Library: We uninstalled and reinstalled oracledb (using npm uninstall oracledb and npm install oracledb), but no changes were observed.
  3. Project Cleanup: We deleted the node_modules folder and package-lock.jsonfile, then reinstalled the project dependencies with npm install.
  4. Environmental Variables Check: We confirmed that environment variables like ORACLE_HOME and LD_LIBRARY_PATH are properly set.

Desired behavior

We expect tests verifying Oracle database connections to work smoothly with the node-oracledb library in Cypress. Ideally, the tests should validate database connections successfully without any compatibility errors and proceed as expected.

Test code to reproduce

const oracledb = require('oracledb');

// Veritabanı bağlantısını oluşturma
async function createPool() {
  try {
    await oracledb.createPool({
      user: 'AAAA,
      password: 'AAAA',
      connectString: '10.10.10.10:1010/AAA'
    });
    console.log('Successfully connected to Oracle Database!');
  } catch (err) {
    console.error('Error connecting to Oracle Database:', err);
    throw err;
  }
}

// Sorgu çalıştırma fonksiyonu
async function runQuery(query) {
  let connection;
  try {
    connection = await oracledb.getConnection();
    const result = await connection.execute(query);
    await connection.commit();
    return result;
  } catch (err) {
    console.error('Query error:', err);
    throw err;
  } finally {
    if (connection) {
      try {
        await connection.close();
      } catch (err) {
        console.error('Error closing connection:', err);
      }
    }
  }
}

// Sorguları çalıştır
async function init() {
  try {
    await createPool();
    // İlk sorgu
    await runQuery("DELETE FROM error_message_content WHERE ERROR_MESSAGE IN (SELECT id FROM ERROR_MESSAGE WHERE key='otomasyonAnahtar')");
    // İkinci sorgu
    await runQuery("DELETE FROM ERROR_MESSAGE WHERE key='otomasyonAnahtar'");
  } catch (err) {
    console.error('Failed to execute delete queries:', err);
  }
}

// Bağlantı havuzunu kapatma
async function closePool() {
  await oracledb.getPool().close(0);
}

module.exports = { runQuery, init, closePool };

Cypress Version

13.15.1

Node version

v20.17.0

Operating System

macOS 14.7

Debug Logs

No response

Other

No response

jennifer-shehane commented 3 weeks ago

@merveodabasi Are you requiring this file in your tests? Do you see this error outside of Cypress? I'm not understanding how this code is related to Cypress tests.