Repository: eslint/eslint
File: tests/lib/cli.js (JavaScript)

Code before:
                            { maxWarnings: 1, foundWarnings: 2 }
                        );
                    });
                });

                describe("and warnings do not exceed the limit", () => {
                    it(`should omit \`maxWarningsExceeded\` metadata from the formatter with configType:${configType}`, async () => {
                        const exit = await cli.execute(
                            `--no-ignore -f json-with-metadata --max-warnings 1 --rule 'quotes: warn' ${flag}`,
                            "'hello world';",
                            useFlatConfig
                        );

                        assert.strictEqual(exit, 0);

                        const { metadata } = JSON.parse(log.info.args[0][0]);

                        assert.notProperty(metadata, "maxWarningsExceeded");
                    });
                });
            });

            describe("when given an invalid built-in formatter name", () => {
                it(`should execute with error: with configType:${configType}`, async () => {
                    const filePath = getFixturePath("passing.js");
                    const exit = await cli.execute(`-f fakeformatter ${filePath} ${flag}`, null, configType === "flat");

                    assert.strictEqual(exit, 2);
                });
            });

            describe("when given a valid formatter path", () => {
                it(`should execute without any errors with configType:${configType}`, async () => {
                    const formatterPath = getFixturePath("formatters", "simple.js");
                    const filePath = getFixturePath("passing.js");
                    const exit = await cli.execute(`-f ${formatterPath} ${filePath} ${flag}`, null, configType === "flat");

                    assert.strictEqual(exit, 0);
                });
            });

            describe("when given an invalid formatter path", () => {

                const originalCwd = process.cwd;

                beforeEach(() => {
                    process.cwd = () => getFixturePath();
                });

                afterEach(() => {
                    process.cwd = originalCwd;

Review comment (suggestion):
```suggestion
                    const exit = await cli.execute(`-f fakeformatter ${filePath} ${flag}`, null, useFlatConfig);
```

Just for consistency with other tests.

Code after:
                            "'hello' + 'world';",
                            useFlatConfig
                        );

                        assert.strictEqual(exit, 1);

                        const { metadata } = JSON.parse(log.info.args[0][0]);

                        assert.deepStrictEqual(
                            metadata.maxWarningsExceeded,
                            { maxWarnings: 1, foundWarnings: 2 }
                        );
                    });
                });

                describe("and warnings do not exceed the limit", () => {
                    it(`should omit \`maxWarningsExceeded\` metadata from the formatter with configType:${configType}`, async () => {
                        const exit = await cli.execute(
                            `--no-ignore -f json-with-metadata --max-warnings 1 --rule 'quotes: warn' ${flag}`,
                            "'hello world';",
                            useFlatConfig
                        );

                        assert.strictEqual(exit, 0);

                        const { metadata } = JSON.parse(log.info.args[0][0]);

                        assert.notProperty(metadata, "maxWarningsExceeded");
                    });
                });
            });

            describe("when given an invalid built-in formatter name", () => {
                it(`should execute with error: with configType:${configType}`, async () => {
                    const filePath = getFixturePath("passing.js");
                    const exit = await cli.execute(`-f fakeformatter ${filePath} ${flag}`, null, useFlatConfig);

                    assert.strictEqual(exit, 2);
                });
            });

            describe("when given a valid formatter path", () => {
                it(`should execute without any errors with configType:${configType}`, async () => {
                    const formatterPath = getFixturePath("formatters", "simple.js");
                    const filePath = getFixturePath("passing.js");
                    const exit = await cli.execute(`-f ${formatterPath} ${filePath} ${flag}`, null, useFlatConfig);

                    assert.strictEqual(exit, 0);
                });
            });