Skip to content

BUG: Getting error when trying to implement "logToConsole(..)" #858

Closed
@padmavemulapati

Description

@padmavemulapati

Product

react

Product Version

4.7.4-62fd241.0

Latest Version

  • I have tested the issue with the latest version of the product

Issue Description

Expectation

logToConsole(axeResults), should return axe-results

Actual

Giving Error:

console.group
      New axe issues

      at Function.logToConsole (node_modules/@axe-core/react/dist/index.js:284:11)

 FAIL  src/App.test.js
  ✕ renders learn react link (44 ms)

  ● renders learn react link

    TypeError: Cannot read properties of undefined (reading 'forEach')

       6 | test('renders learn react link', () => {
       7 |   const result = render(<App />);
    >  8 |   axe.logToConsole(result);
         |       ^
       9 |   
      10 | });
      11 |

      at Function.logToConsole (node_modules/@axe-core/react/dist/index.js:285:22)
      at Object.<anonymous> (src/App.test.js:8:7)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        1.774 s, estimated 2 s
Ran all test suites related to changed files.

Watch Usage: Press w to show more.

How to Reproduce

Tried with React

  1. React code - App.test.js
import App from './App';
import axe from '@axe-core/react';


test('renders learn react link', () => {
  const result = render(<App />);
  axe.logToConsole(result);

});
import React from 'react';
import Button from './Button.mjs';


const App = () => {
  const handleClick = () => {
    alert('Button clicked!');
  };

  return (
    <div>
      <h1>Welcome to my app</h1>
      <Button onClick={handleClick}>Click me</Button>
    </div>
  );
};

export default App;

Issues:

console.group
      New axe issues

      at Function.logToConsole (node_modules/@axe-core/react/dist/index.js:284:11)

 FAIL  src/App.test.js
  ✕ renders learn react link (44 ms)

  ● renders learn react link

    TypeError: Cannot read properties of undefined (reading 'forEach')

       6 | test('renders learn react link', () => {
       7 |   const result = render(<App />);
    >  8 |   axe.logToConsole(result);
         |       ^
       9 |   
      10 | });
      11 |

      at Function.logToConsole (node_modules/@axe-core/react/dist/index.js:285:22)
      at Object.<anonymous> (src/App.test.js:8:7)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        1.774 s, estimated 2 s
Ran all test suites related to changed files.

Watch Usage: Press w to show more.

Screenshot

image

It identified the function logToConsole(result) and started looking for the New issues - but unable to return the value

image

Environment:

Label Value
Product axe-core-npm/react
Version 4.7.4-62fd241.0
OS-Details _MAC- Intel Core i7 - 11.6.8 & Windows11 _
BrowserDetails Chrome Version 117.0.5938.88 (Official Build) (64-bit) & Firefox 117.0

Metadata

Metadata

Assignees

Labels

PRIORITY: highHigh priority item; should be scheduled in this or next sprintTYPE: qa bugBug that was found during the QA process

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions