-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: proper imports in esm context (#718)
- Loading branch information
Showing
10 changed files
with
135 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,34 @@ | ||
import defaultExport, { AxePuppeteer } from './dist/index.mjs'; | ||
import assert from 'assert'; | ||
import puppeteer from 'puppeteer'; | ||
import { fileURLToPath, pathToFileURL } from 'url'; | ||
import { join } from 'path'; | ||
|
||
const exportIsFunction = typeof(defaultExport) === 'function'; | ||
const exportIsSame = defaultExport === AxePuppeteer; | ||
assert(exportIsFunction, 'export is not a function'); | ||
assert(exportIsSame, 'default and named export is not the same'); | ||
|
||
|
||
const options = {}; | ||
|
||
if (process.env.CI) { | ||
options.args = []; | ||
options.args.push('--no-sandbox', '--disable-setuid-sandbox'); | ||
options.executablePath = '/usr/bin/google-chrome-stable'; | ||
} | ||
|
||
async function integrationTest() { | ||
let path = fileURLToPath(new URL('.', import.meta.url)); | ||
path = join(path, './node_modules/axe-test-fixtures/fixtures/index.html'); | ||
|
||
const browser = await puppeteer.launch(options); | ||
const page = await browser.newPage(); | ||
await page.setBypassCSP(true); | ||
await page.goto(pathToFileURL(path)); | ||
const results = await new AxePuppeteer(page).analyze(); | ||
assert(results.violations.length > 0, 'could not find violations'); | ||
await page.close(); | ||
await browser.close(); | ||
} | ||
integrationTest(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,33 @@ | ||
import defaultExport from './dist/index.mjs'; | ||
import assert from 'assert'; | ||
import * as webdriverio from 'webdriverio'; | ||
import { fileURLToPath, pathToFileURL } from 'url'; | ||
import { join } from 'path'; | ||
|
||
const exportIsFunction = typeof(defaultExport) === 'function'; | ||
assert(exportIsFunction, 'export is not a function'); | ||
|
||
|
||
async function integrationTest() { | ||
let path = fileURLToPath(new URL('.', import.meta.url)); | ||
path = join(path, './node_modules/axe-test-fixtures/fixtures/index.html'); | ||
|
||
const options = { | ||
automationProtocol: 'devtools', | ||
path: '/', | ||
capabilities: { | ||
browserName: 'chrome', | ||
'goog:chromeOptions': { | ||
args: ['--headless'] | ||
} | ||
}, | ||
logLevel: 'error' | ||
}; | ||
const client = await webdriverio.remote( options ); | ||
await client.url(pathToFileURL(path).toString()); | ||
|
||
const results = await new defaultExport({ client }).analyze(); | ||
assert(results.violations.length > 0, 'could not find violations'); | ||
process.exit(0); | ||
} | ||
integrationTest() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters