dequelabs / axe-core-npm

Mozilla Public License 2.0
592 stars 67 forks source link

fix(webdriverio): fix types between v8 and <v8 #962

Closed straker closed 8 months ago

straker commented 8 months ago

This change brings the types from webdriverio v8 and makes them compatible with the types from <= v7. This change also prepares us to take the latest webdriverio v8 type changes which were causing our builds to break.

This also upgrades the version of @wdio packages in test/wdio in order to not have multiple copies across packages. We should update all these types together so they don't go out-of-sync.

QA notes:

With this change we should be able to run @axe-core/webdriverio package in webdriverio v5+. Using the following code, install each version of webdriverio from v5 to v8, and then compile and run using typescript to verify working

import { AxeBuilder } from '@axe-core/webdriverio'
import { remote } from 'webdriverio'

(async () => {
  const client = await remote({
    logLevel: 'error',
    capabilities: {
      browserName: 'chrome',
      'goog:chromeOptions': {
        args: ['headless', 'disable-gpu']
      }
    }
  })
  await client.url('https://dequeuniversity.com/demo/mars/')

  try {
    const results = await new AxeBuilder({ client }).analyze()
    console.log(results)
  } catch (e) {
    console.error(e)
  }

  client.deleteSession()
})()

Additional notes:

Webdriverio v7 cannot run in node v18/20, so you'll need to use node v16 in order to test <=v7. For webdriverio v5, the code above should compile but may not open a browser and run. This is a set up issue with the webdriverio and not our code so we are OK if the builds but doesn't run in v5.

Closes: https://github.com/dequelabs/axe-core-npm/issues/829