Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axe Options RunOnlyObject not being recognized in Angular 6 project. #894

Closed
Bmahecha123 opened this issue May 15, 2018 · 8 comments
Closed
Assignees
Labels
docs Documentation changes typescript TypeScript issues
Milestone

Comments

@Bmahecha123
Copy link

Bmahecha123 commented May 15, 2018

Hello everyone,
When I am running Axe.Run(ElementContext, Options): Promise I am getting the following error in my Angular test using Jasmine.

Error: runOnly.values must be a non-empty array

Checking the Axe Core code this object should be recognized but it is not for whatever reason. Any help with this would be greatly appreciated.

interface RunOnly {
		type: RunOnlyType,
		values?: TagValue[] | RunOnlyObject
	}
	interface RunOptions {
		runOnly?: RunOnly,
		rules?: Object,
		iframes?: Boolean,
		elementRef?: Boolean,
		selectors?: Boolean
	}

Here is my test case:


axe-core version: 3.0.2

For Tooling issues:
- Node version: v9.8.0
- Platform:  Mac

it('should have no a11y violations', async() => {

    const rules: Axe.RunOnlyObject = {
      include: ['wcag2a', 'wcag2aa'],
      exclude: ['section508']
    };

    const options: Axe.RunOptions = {
      runOnly: {
        type: 'tags',
        values: rules
      }
    }
   
    let axeTest = await Axe.run(fixture.debugElement.nativeElement, options);
    console.dir(axeTest.violations);
    expect(axeTest.violations.length).toEqual(3);
  });
@marcysutton
Copy link
Contributor

You're passing an object to runOnly, while it expects an array of strings. I'd suggest referring to the axe-core API documentation to configure it. https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#api-name-axeconfigure

@Bmahecha123
Copy link
Author

Thank you for the reply but if you refer to the API documentation for the RunOnly object you will see that it can accept an Array of Strings matching TagValue OR it expects a RunOnlyObject which is what I'm passing.

interface RunOnly {
		type: RunOnlyType,
		values?: TagValue[] | RunOnlyObject
	}

type TagValue = "wcag2a" | "wcag2aa" | "section508" | "best-practice";

type RunOnlyObject = {
		include?: string[] | string[][],
		exclude?: string[] | string[][]
	}

@marcysutton
Copy link
Contributor

marcysutton commented May 15, 2018

Ah yes, I see that now. I'll reopen it. @WilcoFiers looks like we forgot an API option in #774. I guess there were no tests for that? :(

@marcysutton marcysutton reopened this May 15, 2018
@WilcoFiers WilcoFiers added the docs Documentation changes label Jun 9, 2018
@Bmahecha123
Copy link
Author

Bmahecha123 commented Sep 27, 2018

Morning! What's the status for this issue?

@jeeyyy
Copy link
Contributor

jeeyyy commented Sep 27, 2018

@Bmahecha123

I will revert with an update.
In the interim, if you could extend the axe interface to the type it is expecting should help with the failure.

@jeeyyy jeeyyy self-assigned this Sep 27, 2018
@WilcoFiers
Copy link
Contributor

I think it needs to be this:

    type ContextObject = {
		include?: string[] | string[][];
		exclude?: string[] | string[][];
	};

	type RunCallback = (error: Error, results: AxeResults) => void;

	type ElementContext = Node | string | ContextObject;

	interface RunOnly {
		type: RunOnlyType;
		values: TagValue[] | string[];
	}
  • Renamed RunOnlyObject to ContextObject.
  • Removed RunOnlyObject from RunOnly that doesn't take an object with include/exclude.
  • Made values required. Axe complains if you don't set it.

@Bmahecha123
Copy link
Author

Thank you for the reply; I will experiment with this as soon as I can!

@jeeyyy jeeyyy removed their assignment Oct 10, 2018
@straker straker added this to the Axe-core 3.5 milestone Sep 4, 2019
@straker straker added typescript TypeScript issues and removed docs Documentation changes labels Sep 4, 2019
@straker straker self-assigned this Nov 8, 2019
@padmavemulapati
Copy link

Dev task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation changes typescript TypeScript issues
Projects
None yet
Development

No branches or pull requests

7 participants