Commit 204a8faa authored by David Sveningsson's avatar David Sveningsson

fix: change config merge order in `toHTMLValidate`

instead of applying passed config first it is not applied last allowing users to
rely on config from `.htmlvalidate.json` and then override it instead of
vice-versa which in most cases prevented users from disabling rules enabled in
`.htmlvalidate.json`
parent 6e62852c
Pipeline #118171902 passed with stages
in 10 minutes and 48 seconds
......@@ -44,14 +44,14 @@ expect("<p></i>").toHTMLValidate({
```
By default configuration is also read from `.htmlvalidate.json` files where the test-case filename is used to match.
If you need to override this (perhaps because the test-case isn't in the same folder) you can pass in a custom filename as the third argument:
This means you can apply transformations using patterns such as `^.*\\.(spec|test).js$`.
If you need to override the filename (perhaps because the test-case isn't in the same folder) you can pass in a custom filename as the third argument:
```js
expect("<p></i>").toHTMLValidate(null, "path/to/my-file.html");
```
This can also be used to apply transformations to the markup.
Additionally, the `root` configuration property can be used to skip loading from `.htmlvalidate.json` but remember to actually include the rules you need:
```js
......
......@@ -152,8 +152,9 @@ function toHTMLValidate(
actual = actual.outerHTML;
}
const htmlvalidate = new HtmlValidate(config);
const report = htmlvalidate.validateString(actual, filename || this.testPath);
const actualFilename = filename || this.testPath;
const htmlvalidate = new HtmlValidate();
const report = htmlvalidate.validateString(actual, actualFilename, config);
const pass = report.valid;
if (pass) {
return { pass, message: () => "HTML is valid when an error was expected" };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment