Add test to confirm prettier . work with plugins (#8835)

This commit is contained in:
fisker Cheung authored and GitHub committed 2020-08-06 23:15:19 +08:00
1 parent 74b5f65565
commit 770ecfbabc
7 files changed
+52

No files matched your search

@@ -7,6 +7,7 @@ module.exports = {
{
name,
parsers: [name],
extensions: [`.${name}`],
},
],
parsers: {
@@ -148,3 +148,20 @@ exports[`Negative patterns with explicit files: prettier dir1/a1.js dir2/a2.js '
"dir2/a2.js
"
`;
exports[`plugins \`*\` (stderr) 1`] = `
"[error] No parser could be inferred for file: unknown.unknown
"
`;
exports[`plugins \`*\` (stdout) 1`] = `
"javascript.js
plugin.uppercase-rocks
"
`;
exports[`plugins \`.\` (stdout) 1`] = `
"javascript.js
plugin.uppercase-rocks
"
`;
@@ -3,6 +3,7 @@
const path = require("path");
const fs = require("fs");
const runPrettier = require("../runPrettier");
const { projectRoot } = require("../env");
expect.addSnapshotSerializer(require("../path-serializer"));
@@ -58,6 +59,34 @@ testPatterns("Exclude yarn.lock when expanding directories", ["."], {
stdout: expect.not.stringContaining("yarn.lock"),
});
const uppercaseRocksPlugin = path.join(
projectRoot,
"tests_config/prettier-plugins/prettier-plugin-uppercase-rocks"
);
describe("plugins `.`", () => {
runPrettier("cli/dirs/plugins", [
".",
"-l",
"--plugin",
uppercaseRocksPlugin,
]).test({
write: [],
stderr: "",
status: 1,
});
});
describe("plugins `*`", () => {
runPrettier("cli/dirs/plugins", [
"*",
"-l",
"--plugin",
uppercaseRocksPlugin,
]).test({
write: [],
status: 1,
});
});
if (path.sep === "/") {
// Don't use snapshots in these tests as they're conditionally executed on non-Windows only.
@@ -0,0 +1 @@
const foo = 'bar'
@@ -0,0 +1 @@
PrEtTiEr
Whitespace-only changes.
+3
View File
@@ -15,7 +15,10 @@ const thirdParty = isProduction
? path.join(prettierRootDir, "./third-party")
: path.join(prettierRootDir, "./src/common/third-party");
const projectRoot = path.join(__dirname, "..");
module.exports = {
thirdParty,
prettierCli,
projectRoot,
};