0
  1. JSON data in json file:

    { "appenders": { "out": {"type": "console", "layout": { "type": "coloured" } }, "app": {"type": "dateFile", "filename": "cypress-logs/logger/info.log", "maxLogSize": 10485760, "layout": {"type":"pattern", "pattern":"[%d{dd-MM-yyyy hh:mm:ss}] [%p] - %m"} } }, "categories": { "default": { "appenders": ["out", "app"], "level": "info" } } }

  2. .js file code:


"use strict";

function log4js_logger() {
    var log4js = require("log4js");  //importing log4js
    log4js.configure("cypress/fixtures/log4js.json");  //loading the json data here
    var logs = log4js.getLogger();
    //logs.info("Logger has implemented !!")
    return logs; 
}

module.exports = {log4js_logger}
  1. js file where I'm using this logger.info: ---------------------------------------------
"use strict";
var logGenerator = require("../generic_utils/logger")
var logger = logGenerator.log4js_logger()


-----some js functions ---------------------------
-----using logger.info() within those functions---

Error when running cypress test:

An uncaught error was detected outside of a test: TypeError: The following error originated from your test code, not from Cypress.

Cannot read properties of undefined (reading 'native')

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure. at ./node_modules/streamroller/node_modules/fs-extra/lib/fs/index.js (https://mcmp-cd2-int-testfra-apiauto.multicloud-ibm.com/__cypress/tests?p=cypress\e2e\common_inventory\aws\awsInventoryResourceDetails_cy.js:49841:24) at webpack_require (https://mcmp-cd2-int-testfra-apiauto.multicloud-ibm.com/__cypress/tests?p=cypress\e2e\common_inventory\aws\awsInventoryResourceDetails_cy.js:20:30) at ./node_modules/streamroller/node_modules/fs-extra/lib/index.js (https://mcmp-cd2-int-testfra-apiauto.multicloud-ibm.com/__cypress/tests?p=cypress\e2e\common_inventory\aws\awsInventoryResourceDetails_cy.js:49861:3) at webpack_require (https://mcmp-cd2-int-testfra-apiauto.multicloud-ibm.com/__cypress/tests?p=cypress\e2e\common_inventory\aws\awsInventoryResourceDetails_cy.js:20:30) at Object.eval (https://mcmp-cd2-int-testfra-apiauto.multicloud-ibm.com/__cypress/tests?p=cypress\e2e\common_inventory\aws\awsInventoryResourceDetails_cy.js:48187:12) at ./node_modules/streamroller/lib/RollingFileWriteStream.js (https://mcmp-cd2-int-testfra-apiauto.multicloud-ibm.com/__cypress/tests?p=cypress\e2e\common_inventory\aws\awsInventoryResourceDetails_cy.js:48525:30) at webpack_require (https://mcmp-cd2-int-testfra-apiauto.multicloud-ibm.com/__cypress/tests?p=cypress\e2e\common_inventory\aws\awsInventoryResourceDetails_cy.js:20:30) at ./node_modules/streamroller/lib/index.js (https://mcmp-cd2-int-testfra-apiauto.multicloud-ibm.com/__cypress/tests?p=cypress\e2e\common_inventory\aws\awsInventoryResourceDetails_cy.js:48694:27) at webpack_require (https://mcmp-cd2-int-testfra-apiauto.multicloud-ibm.com/__cypress/tests?p=cypress\e2e\common_inventory\aws\awsInventoryResourceDetails_cy.js:20:30) at Object.eval (https://mcmp-cd2-int-testfra-apiauto.multicloud-ibm.com/__cypress/tests?p=cypress\e2e\common_inventory\aws\awsInventoryResourceDetails_cy.js:44945:17)

Observation:

when I'm running js file with node command where log4js code is present, It is working fine but giving above error when running the cypress test

  • Have you searched your test source code for references to an object property named "native"? – Pointy Jan 10 '23 at 13:02
  • @Pointy I don't have anything with name 'native' in my source code. – Satyam Agrawal Jan 11 '23 at 06:48
  • Well then it could be that there's an unexpected `undefined` in some parameter or configuration you're passing to some other library. It's impossible to tell from what is posted in your question. – Pointy Jan 11 '23 at 13:08

0 Answers0