Skip to content

Commit cff690d

Browse files
committed
test(plugin-axe): add E2E snapshot tests
1 parent 07234ac commit cff690d

File tree

12 files changed

+1155
-7
lines changed

12 files changed

+1155
-7
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import tseslint from 'typescript-eslint';
2+
import baseConfig from '../../eslint.config.js';
3+
4+
export default tseslint.config(...baseConfig, {
5+
files: ['**/*.ts'],
6+
languageOptions: {
7+
parserOptions: {
8+
projectService: true,
9+
tsconfigRootDir: import.meta.dirname,
10+
},
11+
},
12+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { join } from 'node:path';
2+
import { pathToFileURL } from 'node:url';
3+
import axePlugin from '@code-pushup/axe-plugin';
4+
import type { CoreConfig } from '@code-pushup/models';
5+
6+
const htmlFile = join(process.cwd(), 'index.html');
7+
const url = pathToFileURL(htmlFile).href;
8+
9+
export default {
10+
plugins: [axePlugin(url)],
11+
} satisfies CoreConfig;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Accessibility Test Page</title>
7+
<style>
8+
/* Poor color contrast for testing */
9+
.low-contrast {
10+
color: #777;
11+
background-color: #999;
12+
padding: 10px;
13+
}
14+
</style>
15+
</head>
16+
<body>
17+
<h1>Accessibility Test Page</h1>
18+
19+
<!-- Missing alt text on image -->
20+
<img src="test-image.jpg" width="200" height="150" />
21+
22+
<!-- Poor color contrast -->
23+
<div class="low-contrast">
24+
This text has poor color contrast and may be hard to read.
25+
</div>
26+
27+
<!-- Invalid ARIA attribute -->
28+
<div role="button" aria-invalid-attribute="true">
29+
Button with invalid ARIA attribute
30+
</div>
31+
32+
<!-- Form input missing label -->
33+
<form>
34+
<input type="text" name="username" placeholder="Enter username" />
35+
<button type="submit">Submit</button>
36+
</form>
37+
38+
<!-- Button without accessible name -->
39+
<button></button>
40+
41+
<!-- Link without accessible name -->
42+
<a href="#"></a>
43+
</body>
44+
</html>

e2e/plugin-axe-e2e/project.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "plugin-axe-e2e",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "e2e/plugin-axe-e2e/src",
5+
"projectType": "application",
6+
"targets": {
7+
"lint": {},
8+
"e2e": {
9+
"executor": "@nx/vite:test",
10+
"options": {
11+
"configFile": "{projectRoot}/vitest.e2e.config.ts"
12+
}
13+
}
14+
},
15+
"implicitDependencies": ["cli", "plugin-axe"],
16+
"tags": ["scope:plugin", "type:e2e"]
17+
}

0 commit comments

Comments
 (0)