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

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

                const originalCwd = process.cwd;

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

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

                it(`should execute with error with configType:${configType}`, async () => {
                    const formatterPath = getFixturePath("formatters", "file-does-not-exist.js");
                    const filePath = getFixturePath("passing.js");
                    const exit = await cli.execute(`--no-ignore -f ${formatterPath} ${filePath}`, null, useFlatConfig);

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

            describe("when given an async formatter path", () => {
                it(`should execute without any errors with configType:${configType}`, async () => {
                    const formatterPath = getFixturePath("formatters", "async.js");
                    const filePath = getFixturePath("passing.js");
                    const exit = await cli.execute(`-f ${formatterPath} ${filePath} --no-config-lookup`);

                    assert.strictEqual(log.info.getCall(0).args[0], "from async formatter");
                    assert.strictEqual(exit, 0);
                });
            });
        });

        describe("Exit Codes", () => {

            const originalCwd = process.cwd;

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

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

            describe("when executing a file with a lint error", () => {

                it(`should exit with error with configType:${configType}`, async () => {
                    const filePath = getFixturePath("undef.js");
                    const code = `--no-ignore --rule no-undef:2 ${filePath}`;


Review comment (suggestion):
```suggestion
                    const exit = await cli.execute(`-f ${formatterPath} ${filePath} ${flag}`, null, useFlatConfig);
```

To test both modes.

Code after:
            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);
                });
            });

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

                const originalCwd = process.cwd;

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

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

                it(`should execute with error with configType:${configType}`, async () => {
                    const formatterPath = getFixturePath("formatters", "file-does-not-exist.js");
                    const filePath = getFixturePath("passing.js");
                    const exit = await cli.execute(`--no-ignore -f ${formatterPath} ${filePath}`, null, useFlatConfig);

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

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

                    assert.strictEqual(log.info.getCall(0).args[0], "from async formatter");
                    assert.strictEqual(exit, 0);
                });
            });
        });

        describe("Exit Codes", () => {

            const originalCwd = process.cwd;

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