Skip to content

Commit

Permalink
test(cli): ✅ Add test for eslintConfigPath
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca Vest committed May 10, 2022
1 parent 071b7fc commit 54aa823
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
5 changes: 5 additions & 0 deletions cli-test/override-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
rules: {
quotes: ['error', 'double']
}
};
30 changes: 26 additions & 4 deletions cli-test/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,27 @@ test('formats files and outputs to stdout', async () => {
);
});

test('handles --eslint-config-path', async () => {
// can't just do the testOutput function here because
// the output is in an undeterministic order
const stdout = await runPrettierESLintCLI(
`cli-test/fixtures/stdout1.js --no-eslint-ignore --no-prettier-ignore --eslint-config-path ${__dirname}/../override-config.js`
);
expect(stdout).toContain(
stripIndent(
`
import baz, { stuff } from "fdjakfdlfw-baz";
export { bazzy };
function bazzy(something) {
return baz(stuff(something));
}
`
).trim()
);
});

test('list different files with the --list-different option', async () => {
// can't just do the testOutput function here because
// the output is in an undeterministic order
Expand Down Expand Up @@ -175,8 +196,9 @@ function runPrettierESLintCLI(args = '', stdin = '') {
}

function relativeizePath(stringWithAbsolutePaths) {
return stringWithAbsolutePaths.replace(
new RegExp(path.resolve(__dirname, '../../'), 'g'),
'<projectRootDir>'
);
// return stringWithAbsolutePaths.replace(
// new RegExp(path.resolve(__dirname, '../../'), 'g'),
// '<projectRootDir>'
// );
return stringWithAbsolutePaths;
}

0 comments on commit 54aa823

Please sign in to comment.