Skip to content

Commit

Permalink
Test behaviour when no configuration file is present
Browse files Browse the repository at this point in the history
Update the CLI tests to include a test for the case where a project does
not have a configuration file. This test currently fails because this is
currently not supported due to a bug introduced in v2.2.0.

To accomodate testing this, the configuration file that was present at
the root of the project has been moved and related tests updated
accordingly. This is necessary because svglint automatically searches
for a configuration file up the file tree, so having a configuration
file at the root of the project makes it impossible to test the scenario

The new tests matches against a string because unfortunately the error
is silent - it doesn't exit with a non-zero exit code. Improvements to
this are welcome as contributions.
  • Loading branch information
ericcornelissen committed Apr 5, 2023
1 parent 1df672e commit 89ec927
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("CLI", function(){
});

it("should fail with an invalid SVG", async function(){
const { failed, exitCode } = await execCliWith([INVALID_SVG]);
const { failed, exitCode } = await execCliWith([INVALID_SVG], "test/projects/with-config");
expect(failed).toBeTruthy();
expect(exitCode).toBe(1);
});
Expand Down Expand Up @@ -101,4 +101,9 @@ describe("Configuration files", function() {
const { failed } = await execCliWith([VALID_SVG], "test/projects/cjs/bar/a/b/c");
expect(failed).toBeFalsy();
});

it("should succeed in a project without a config file", async function () {
const { stdout } = await execCliWith([VALID_SVG], "test/projects/without-config");
expect(stdout).toNotMatch("Failed to lint");
});
});
File renamed without changes.
Empty file.

0 comments on commit 89ec927

Please sign in to comment.