Add setup file to integration test (#12855)

This commit is contained in:
fisker Cheung authored and GitHub committed 2022-05-21 11:11:06 +08:00
1 parent 142d5c382e
commit ee17a2ff8b
34 files changed
+6 -62

No files matched your search

+2 -1
View File
@@ -237,7 +237,8 @@ module.exports = {
"unicorn/prefer-array-flat-map": "off",
},
globals: {
run_spec: false,
run_spec: "readonly",
runPrettier: "readonly",
},
},
{
+1
View File
@@ -3,6 +3,7 @@ import baseConfig from "./jest.config.mjs";
const config = {
...baseConfig,
testRegex: "tests/integration/__tests__/.*\\.js$",
setupFiles: ["<rootDir>/tests/integration/integration-test-setup.js"],
projects: [],
moduleNameMapper: {
...baseConfig.moduleNameMapper,
@@ -1,4 +1,3 @@
import runPrettier from "../run-prettier.js";
import jestPathSerializer from "../path-serializer.js";
expect.addSnapshotSerializer(jestPathSerializer);
-2
View File
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("checks stdin with --check", () => {
runPrettier("cli/with-shebang", ["--check", "--parser", "babel"], {
input: "0",
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("write cursorOffset to stderr with --cursor-offset <int>", () => {
runPrettier("cli", ["--cursor-offset", "2", "--parser", "babel"], {
input: " 1",
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("doesn't crash when --debug-check is passed", () => {
runPrettier("cli/with-shebang", ["issue1890.js", "--debug-check"]).test({
stdout: "issue1890.js\n",
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("prints information for debugging AST --debug-print-ast", () => {
runPrettier("cli/with-shebang", ["--debug-print-ast", "--parser", "babel"], {
input: "const foo = 'foo';",
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("prints information for debugging comment attachment with --debug-print-comments", () => {
runPrettier(
"cli/with-shebang",
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("prints doc with --debug-print-doc", () => {
runPrettier("cli/with-shebang", ["--debug-print-doc", "--parser", "babel"], {
input: "0",
@@ -1,6 +1,4 @@
import prettier from "prettier-local";
import runPrettier from "../run-prettier.js";
describe("show version with --version", () => {
runPrettier("cli/with-shebang", ["--version"]).test({
stdout: prettier.version + "\n",
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("no error on unmatched pattern", () => {
runPrettier("cli/error-on-unmatched-pattern", [
"--no-error-on-unmatched-pattern",
@@ -1,7 +1,5 @@
import path from "node:path";
import createEsmUtils from "esm-utils";
import runPrettier from "../run-prettier.js";
const { __dirname } = createEsmUtils(import.meta);
describe("support absolute filename", () => {
@@ -1,8 +1,6 @@
import path from "node:path";
import fs from "node:fs";
import createEsmUtils from "esm-utils";
import runPrettier from "../run-prettier.js";
const { __dirname } = createEsmUtils(import.meta);
fs.writeFileSync(
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("ignore-unknown dir", () => {
runPrettier("cli/ignore-unknown", [
".",
@@ -1,6 +1,4 @@
import prettier from "prettier-local";
import runPrettier from "../run-prettier.js";
const { jest } = import.meta;
describe("stdin no path and no parser", () => {
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("checks stdin with --list-different", () => {
runPrettier("cli/with-shebang", ["--list-different", "--parser", "babel"], {
input: "0",
-2
View File
@@ -1,6 +1,4 @@
import stripAnsi from "strip-ansi";
import runPrettier from "../run-prettier.js";
test("do not show logs with --loglevel silent", async () => {
await runPrettierWithLogLevel("silent", null);
});
@@ -1,6 +1,4 @@
import prettier from "prettier-local";
import runPrettier from "../run-prettier.js";
test("allows custom parser provided as object", async () => {
const output = await prettier.format("1", {
parser(text) {
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("should not write file or print code when `--debug-benchmark` or `--debug-repeat` found", () => {
const assertStderr = (message) => {
expect(
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("output with --check + unformatted differs when piped", () => {
const cli0 = runPrettier(
"cli/write",
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("plugin default options should work", () => {
runPrettier(
"plugins/defaultOptions",
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("flush all line-suffix content", () => {
runPrettier("plugins/flushLineSuffix", ["*.foo", "--plugin=./plugin.cjs"], {
ignoreLineEndings: true,
@@ -1,6 +1,4 @@
import snapshotDiff from "snapshot-diff";
import runPrettier from "../run-prettier.js";
test("show external options with `--help`", async () => {
const originalStdout = await runPrettier("plugins/options-string", ["--help"])
.stdout;
@@ -1,6 +1,4 @@
import snapshotDiff from "snapshot-diff";
import runPrettier from "../run-prettier.js";
test("show external options with `--help`", async () => {
const originalStdout = await runPrettier("plugins/options", ["--help"])
.stdout;
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("json-stringify takes precedence over json for package.json", () => {
runPrettier("plugins", ["--stdin-filepath=package.json"], {
input:
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("plugin search should not crash when prettier isn't inside a directory", () => {
runPrettier(
"plugins/virtualDirectory",
@@ -1,7 +1,5 @@
import { isCI } from "ci-info";
import { outdent } from "outdent";
import runPrettier from "../run-prettier.js";
describe("format correctly if stdin content compatible with stdin-filepath", () => {
runPrettier(
"cli",
@@ -1,6 +1,4 @@
import prettier from "prettier-local";
import runPrettier from "../run-prettier.js";
test("API getSupportInfo()", async () => {
expect(await getCoreInfo()).toMatchSnapshot();
});
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("exits with non-zero code when input has a syntax error", () => {
runPrettier("cli/with-shebang", ["--parser", "babel"], {
input: "a.2",
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("CLI overrides take precedence without --config-precedence", () => {
runPrettier("cli/config/", [
"--end-of-line",
@@ -1,7 +1,5 @@
import prettier from "prettier-local";
import { outdent } from "outdent";
import runPrettier from "../run-prettier.js";
describe("infers postcss parser", () => {
runPrettier("cli/with-parser-inference", ["--end-of-line", "lf", "*"]).test({
status: 0,
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("preserves shebang", () => {
runPrettier("cli/with-shebang", ["--end-of-line", "lf", "issue1890.js"]).test(
{
-2
View File
@@ -1,5 +1,3 @@
import runPrettier from "../run-prettier.js";
describe("write file with --write + unformatted file", () => {
runPrettier("cli/write", ["--write", "unformatted.js"]).test({
status: 0,
@@ -0,0 +1,3 @@
import runPrettier from "./run-prettier.js";
globalThis.runPrettier = runPrettier;