component-driven / cypress-axe

Test accessibility with axe-core in Cypress
MIT License
622 stars 86 forks source link

Solving : Fix required not defined #169

Open linediconsine opened 10 months ago

linediconsine commented 10 months ago

Hi, This patch aim to solve https://github.com/component-driven/cypress-axe/issues/170

the actual code rely on required be defined in the browser but this is not the case in my tests on Chrome browser:

Actual code

(typeof require?.resolve === 'function'
            ? require.resolve('axe-core/axe.min.js')
            : 'node_modules/axe-core/axe.min.js');

console log

VM87:1 Uncaught ReferenceError: require is not defined
    at <anonymous>:1:1
(anonymous) @ VM87:1

Screenshot on Chrome error

Patch proposed :

(typeof require != 'undefined' && typeof require?.resolve === 'function'
            ? require.resolve('axe-core/axe.min.js')
            : 'node_modules/axe-core/axe.min.js');

console log

'node_modules/axe-core/axe.min.js'

after patch

tagging last active developers @MehmetYararVX @johnhwhite for a review on this if possible

linediconsine commented 10 months ago

Let me know any feedback on this

thanks

linediconsine commented 10 months ago

On local nom run test give me


  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  test.cy.js                               699ms        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        699ms        1        1        -        -        -  

I see a timeout error on nom run test logs in pipeline testing, is it there a way to re-test?

courentin commented 6 months ago

@linediconsine thanks for your fix! Maybe you can push an empty commit to trigger the CI or create another PR?

@bmordue any chance to merge this one-liner and trigger a new release? This would help us :)

Thanks a lot!

adamnorbacker commented 5 months ago

Any news on this PR? Also have this issue in our project.